• 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 minestrone View Post
    How in gods name does only using public methods break encapsulation?

    You are just speaking complete mince now love.
    Possibly he meant methods and data?
    As in to make all methods and data public would break encapsulation.
    "He's actually ripped" - Jared Padalecki

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

    Comment


      Originally posted by minestrone View Post
      How in gods name does only using public methods break encapsulation?

      You are just speaking complete mince now love.
      I can't answer that question. You just asked me 'why is water wet?'

      Comment


        Originally posted by SpontaneousOrder View Post
        For anything non-super trivial, the only way you can get away with only having public methods is to ignore encapsulation completely and just make all your would-be private methods public, OR you have to duplicate code all over the place.

        One of those is just dumb, and the other would prompt me to ask why you were even using Java in the first place?
        You can still have encapsulation with public methods, the caller of your public method doesn't know or care how you implement the method, as long as the signature never changes. Encapsulation to me more about the internal state of the object being hidden, so private variables etc.

        Comment


          Originally posted by MyUserName View Post
          Possibly he meant methods and data?
          As in to make all methods and data public would break encapsulation.
          Putting a public accessor/mutator in front of private data doesn't magically make it encapsulated either.

          Comment


            Originally posted by SpontaneousOrder View Post
            Putting a public accessor/mutator in front of private data doesn't magically make it encapsulated either.
            So making all private data public would break encapsulation? Isn't that what I said?
            Last edited by MyUserName; 7 January 2014, 11:33. Reason: I'm an idiot
            "He's actually ripped" - Jared Padalecki

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

            Comment


              Originally posted by MyUserName View Post
              Possibly he meant methods and data?
              As in to make all methods and data public would break encapsulation.
              Originally posted by MyUserName View Post
              So making all private data would break encapsulation? Isn't that what I said?
              Pick one
              Knock first as I might be balancing my chakras.

              Comment


                Originally posted by Unix View Post
                You can still have encapsulation with public methods, the caller of your public method doesn't know or care how you implement the method, as long as the signature never changes. Encapsulation to me more about the internal state of the object being hidden, so private variables etc.
                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.

                Comment


                  So he's of the "C with classes" school?
                  Originally posted by MaryPoppins
                  I'd still not breastfeed a nazi
                  Originally posted by vetran
                  Urine is quite nourishing

                  Comment


                    Originally posted by MyUserName View Post
                    So making all private data would break encapsulation? Isn't that what I said?
                    Sorry, i think i've misunderstood. I don't know what you are asking?

                    Comment


                      Originally posted by suityou01 View Post
                      Pick one
                      DOH!!!! Sorry have fixed it, well spotted!!
                      "He's actually ripped" - Jared Padalecki

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

                      Comment

                      Working...
                      X