• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

I think I am going to cry

Collapse
X
  •  
  • Filter
  • Time
  • Show
Clear All
new posts

    #41
    Observer pattern and param array. Simples.


    Sent from my iMinion using Tapatalk
    Knock first as I might be balancing my chakras.

    Comment


      #42
      Originally posted by suityou01 View Post
      Observer pattern and param array. Simples.


      Sent from my iMinion using Tapatalk
      Ok, please humour me because I'm genuinely interested in finding out how you've managed to avoid using them satisfactorily.

      So lets say your screen has ten buttons (Observables). That means you need to have either 10 Observers or 1 observer which will receive some kind of button ID and process the appropriate button click accordingly?

      Comment


        #43
        You could have 63 observers if you need. Humour me by reading up on the observer pattern.


        Sent from my iMinion using Tapatalk
        Knock first as I might be balancing my chakras.

        Comment


          #44
          Originally posted by suityou01 View Post
          You could have 63 observers if you need. Humour me by reading up on the observer pattern.


          Sent from my iMinion using Tapatalk
          I'm well aware of the observer pattern. I've been doing this for ten years.
          But... this is the bit i'm trying to get at now - So if I need to write 63 observers without using anonymous classes, and bearing in mind that you said
          Why does needing a named function immediately say to you you need to create a class?
          Then can I assume that you'll then expect to have 63 different classes already in existence (to handle the 63 different buttons), all of which are appropriate places to handle (in addition to fulfilling their 'day-job' purpose) particular button click-handling logic?

          Comment


            #45
            How are you not getting this?


            Sent from my iMinion using Tapatalk
            Knock first as I might be balancing my chakras.

            Comment


              #46
              Originally posted by suityou01 View Post
              How are you not getting this?


              Sent from my iMinion using Tapatalk
              A yes or no answer would determine whether or not I'm getting it.

              Comment


                #47
                No. You do not understand the observer pattern.


                Sent from my iMinion using Tapatalk
                Knock first as I might be balancing my chakras.

                Comment


                  #48
                  Originally posted by suityou01 View Post
                  No. You do not understand the observer pattern.


                  Sent from my iMinion using Tapatalk
                  Seriously?, The observer pattern is massive overkill for creating button event handlers, the language has much better support for this use case, called anonymous inner classes

                  Comment


                    #49
                    All event handlers in C hash use the observer pattern.

                    Hth.


                    Sent from my iMinion using Tapatalk
                    Knock first as I might be balancing my chakras.

                    Comment


                      #50
                      Originally posted by suityou01 View Post
                      No. You do not understand the observer pattern.


                      Sent from my iMinion using Tapatalk
                      I'm starting to doubt that you do.
                      I already asked: you have ten buttons that are observable. That's ten Observables. You then need Observers registered for each; So lets say either 1 registered with all ten, or 10 different observers - 1 registered with each Observable.

                      To this you agreed. Fine so far.


                      So then I say so if you had 63 buttons and 63 observers, as you suggested, then you need to code 63 methods to implement the Observer interface for each of the 63 buttons.

                      You suggested that we don't need to create new concrete classes for each, so we can either

                      A) have 63 existing objects that do whatever it is that they do AND also handle a particular button click. Or
                      B) have 1 single existing object with the capability to identify which particular button has notified it that it got clicked.

                      This is almost what you already agreed to with 10 buttons. We've just upped it to 63 and added the condition that we won't implement new handler/Observer classes.

                      I then implied that it might be a tall order to find 63 already existing classes that do whatever it is that they do, which ALSO can then handle a particular button click logic without violating lots of good SOLID principles.

                      At which point you just say that I don't understand the Observer pattern.

                      Comment

                      Working...
                      X