• 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!

Code reviews

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

    Originally posted by SpontaneousOrder View Post
    Exactly - so for anything but the simplest class imaginable, if you don't want to duplicate code all over the place you will have smaller reusable methods. Those methods are not meant to be exposed to the outside world because they are for manipulating the internal state.
    So if you make them public you are breaking encapsulation because the outside world is now not restricted to interact via the appropriate public api; now they can **** about with the internal state of that object unrestricted.
    Yes, unless you don't use private methods, and just have whacking great spaghetti public methods. As long as they are declared in an interface def, you're good to go. Soupy is a visionary and so far ahead of his time.

    Tune in next week for his episode on "Inheritance isn't necessary", or "Abstraction is just an overhead".
    Knock first as I might be balancing my chakras.

    Comment


      Originally posted by MyUserName View Post
      DOH!!!! Sorry have fixed it, well spotted!!
      Knock first as I might be balancing my chakras.

      Comment


        Originally posted by suityou01 View Post
        Yes, unless you don't use private methods, and just have whacking great spaghetti public methods. As long as they are declared in an interface def, you're good to go. Soupy is a visionary and so far ahead of his time.

        Tune in next week for his episode on "Inheritance isn't necessary", or "Abstraction is just an overhead".
        Inheritance should be avoided at all costs.

        Comment


          Originally posted by minestrone View Post
          Inheritance should be avoided at all costs.


          Knock first as I might be balancing my chakras.

          Comment


            Originally posted by minestrone View Post
            Inheritance should be avoided at all costs.
            I agree, composition is better.

            Comment


              Originally posted by minestrone View Post
              Inheritance should be avoided at all costs.
              Why do you think that?
              "He's actually ripped" - Jared Padalecki

              https://youtu.be/l-PUnsCL590?list=PL...dNeCyi9a&t=615

              Comment


                Originally posted by Unix View Post
                Almost all IDE's/editors allow you to easily navigate between method calls. Code becomes much more readable when you have smaller methods that are properly named i.e.

                if (isCardVerified()) {

                //do stuff
                }

                rather than repeating the perhaps complex code inside isCardVerified every time.
                I agree with you but it could be argued in this example that IsCardVerified could be a public method on a class called CardVerification. CardVerification could be passed into your class in the constructor. This would enable this common code to be used through out your app and other apps. BUT I would only do this for code that would be reused out side of calling class.

                Comment


                  Originally posted by MyUserName View Post
                  So making all private data public would break encapsulation? Isn't that what I said?
                  Yes it would. I just mean that "encapsulating" data by making it private but then just adding a public mutator/accessor in front of it is not really encapsulation at all - it's a token gesture to make yourself feel better.

                  In those cases, if it weren't for java bean standards and things like that, you may as well just leave the data member public and not bother with the getter/setter. I'm not saying it's a bad thing to do - just that it isn't really a meaningful example of encapsulation.

                  Comment


                    Originally posted by MyUserName View Post
                    Why do you think that?
                    Because it marks things less flat.
                    Knock first as I might be balancing my chakras.

                    Comment


                      Originally posted by SpontaneousOrder View Post
                      Yes it would. I just mean that "encapsulating" data by making it private but then just adding a public mutator/accessor in front of it is not really encapsulation at all - it's a token gesture to make yourself feel better.

                      In those cases, if it weren't for java bean standards and things like that, you may as well just leave the data member public and not bother with the getter/setter. I'm not saying it's a bad thing to do - just that it isn't really a meaningful example of encapsulation.
                      Indeed. In C#4 et seq you don't even declare accessors as it just does it all for you. No clearer supporting argument for what you say IMVHO.
                      Knock first as I might be balancing my chakras.

                      Comment

                      Working...
                      X