Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. The Weird and The Wonderful
  4. Could this copy/paste redundancy prove costly?

Could this copy/paste redundancy prove costly?

Scheduled Pinned Locked Moved The Weird and The Wonderful
questioncsharp
7 Posts 4 Posters 7 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jayart
    wrote on last edited by
    #1

    Recently a contractor(my View about Contractors - are supposed to good programmers!) worked in our project. Code written in C#-VS2005 He wrote public void RegisterEvents() { obj.CenterChanged += new CenterChangedEventHandler(OnCenterChanged); obj.CenterChanged += new CenterChangedEventHandler(OnCenterChanged); /// few more handlers } My question: Would registering the same event twice call the handler twice when event is raised? -rt

    J P T V 4 Replies Last reply
    0
    • J jayart

      Recently a contractor(my View about Contractors - are supposed to good programmers!) worked in our project. Code written in C#-VS2005 He wrote public void RegisterEvents() { obj.CenterChanged += new CenterChangedEventHandler(OnCenterChanged); obj.CenterChanged += new CenterChangedEventHandler(OnCenterChanged); /// few more handlers } My question: Would registering the same event twice call the handler twice when event is raised? -rt

      J Offline
      J Offline
      jayart
      wrote on last edited by
      #2

      I did a quick check myself and indeed the handler gets called twice if registered twice. The handler handled some drawing code which I am sure would redraw twice!

      1 Reply Last reply
      0
      • J jayart

        Recently a contractor(my View about Contractors - are supposed to good programmers!) worked in our project. Code written in C#-VS2005 He wrote public void RegisterEvents() { obj.CenterChanged += new CenterChangedEventHandler(OnCenterChanged); obj.CenterChanged += new CenterChangedEventHandler(OnCenterChanged); /// few more handlers } My question: Would registering the same event twice call the handler twice when event is raised? -rt

        P Offline
        P Offline
        Pete OHanlon
        wrote on last edited by
        #3

        Contractors aren't magic bullets for organisations. Like every other profession, some are good and some are bad. Remember that a lot of people are attracted to contracting for the perceived high remuneration and you can see why there is a lot of chaff among the wheat.

        Deja View - the feeling that you've seen this post before.

        V 1 Reply Last reply
        0
        • J jayart

          Recently a contractor(my View about Contractors - are supposed to good programmers!) worked in our project. Code written in C#-VS2005 He wrote public void RegisterEvents() { obj.CenterChanged += new CenterChangedEventHandler(OnCenterChanged); obj.CenterChanged += new CenterChangedEventHandler(OnCenterChanged); /// few more handlers } My question: Would registering the same event twice call the handler twice when event is raised? -rt

          T Offline
          T Offline
          Tim Yen
          wrote on last edited by
          #4

          Yeah it should get called twice I find a number of contractors are hackers because they just code to the contract with no thought to maintainability. I'm sure there are some good ones out there, but they are much more immediate result oriented, which can lead to bad code. I've seen it a few times, not to say permanent coders can't be hackers too. Tim

          V 1 Reply Last reply
          0
          • J jayart

            Recently a contractor(my View about Contractors - are supposed to good programmers!) worked in our project. Code written in C#-VS2005 He wrote public void RegisterEvents() { obj.CenterChanged += new CenterChangedEventHandler(OnCenterChanged); obj.CenterChanged += new CenterChangedEventHandler(OnCenterChanged); /// few more handlers } My question: Would registering the same event twice call the handler twice when event is raised? -rt

            V Offline
            V Offline
            Vasudevan Deepak Kumar
            wrote on last edited by
            #5

            Yes. But wasn't there a compiler warning or at least a peer code review to stamp out this? :sigh:

            Vasudevan Deepak Kumar Personal Homepage Tech Gossips

            1 Reply Last reply
            0
            • T Tim Yen

              Yeah it should get called twice I find a number of contractors are hackers because they just code to the contract with no thought to maintainability. I'm sure there are some good ones out there, but they are much more immediate result oriented, which can lead to bad code. I've seen it a few times, not to say permanent coders can't be hackers too. Tim

              V Offline
              V Offline
              Vasudevan Deepak Kumar
              wrote on last edited by
              #6

              True. Their sense of commitment to the organization is less since they know they would escape after a while. We need to be careful in getting the proper deliverables from them since our project is billed by them.

              Vasudevan Deepak Kumar Personal Homepage Tech Gossips

              1 Reply Last reply
              0
              • P Pete OHanlon

                Contractors aren't magic bullets for organisations. Like every other profession, some are good and some are bad. Remember that a lot of people are attracted to contracting for the perceived high remuneration and you can see why there is a lot of chaff among the wheat.

                Deja View - the feeling that you've seen this post before.

                V Offline
                V Offline
                Vasudevan Deepak Kumar
                wrote on last edited by
                #7

                I just posted a reply to the other thread in this message, which I guess applies to this too. http://www.codeproject.com/Feature/HallOfShame.asp?msg=2053494#xx2053494xx[^]

                Vasudevan Deepak Kumar Personal Homepage Tech Gossips

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups