The Daily WTF: Curious Perversions in Information Technology
Welcome to TDWTF Forums Sign in | Join | Help
in Search

Encapsulation is too global

Last post 11-04-2009 11:28 PM by savar. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 11-04-2009 11:23 AM

    Encapsulation is too global

    Our boss hired this offshore-H1B super-developer who swears he always uses the best design patterns because it's the right way of doing things.

    This guy wrote a class that has about 50 modest private methods, each with between 10 and 20+ parameters. Why? Because class-level encapsulation is (his words) "too global" - he was never able to explain what he meant by this.

    To get around that, he always passes every variable a method references as a parameter, and never uses instance variables.

    As with most mature systems, the call stack can be somewhat deep, so methods frequently pass through parameters (that they themselves don't need) on their way to lower level methods. Any time we need to omit a parameter from some method, we need to delete it from that methods' signature, then work backwards up the stack to see what breaks. Thankfully, at least we have IDEs to point out the errors; doing this in the days of vi-as-dev-environment would have been horrific. 

    Gotta love this profession!

     

    If you must burn our flag, please wrap yourself in it first!
  • 11-04-2009 12:44 PM In reply to

    Re: Encapsulation is too global

    Sounds like he really doesn't understand OO. Perhaps he should stop worrying about "patterns" and concentrate on OO basics.

    Sadly, I've seen this sort of code before. You have my sincerest sympathies.




  • 11-04-2009 1:28 PM In reply to

    • toth
    • Top 500 Contributor
    • Joined on 06-23-2009
    • Posts 57

    Re: Encapsulation is too global

    snoofle:
    Our boss hired this offshore-H1B super-developer who swears he always uses the best design patterns because it's the right way of doing things.

    This guy wrote a class that has about 50 modest private methods, each with between 10 and 20+ parameters. Why? Because class-level encapsulation is (his words) "too global" - he was never able to explain what he meant by this.

    To get around that, he always passes every variable a method references as a parameter, and never uses instance variables.

    As with most mature systems, the call stack can be somewhat deep, so methods frequently pass through parameters (that they themselves don't need) on their way to lower level methods. Any time we need to omit a parameter from some method, we need to delete it from that methods' signature, then work backwards up the stack to see what breaks. Thankfully, at least we have IDEs to point out the errors; doing this in the days of vi-as-dev-environment would have been horrific. 

    Gotta love this profession!

     

    Well that's...a pattern.
  • 11-04-2009 2:24 PM In reply to

    Re: Encapsulation is too global

    snoofle:

    To get around that, he always passes every variable a method references as a parameter, and never uses instance variables.

    But, don't you see, his methods are now referentially transparent, so the compiler can be far more aggresive optimising them :)

     

  • 11-04-2009 3:26 PM In reply to

    Re: Encapsulation is too global

    snoofle:
    This guy wrote a class that has about 50 modest private methods, each with between 10 and 20+ parameters
    Could've been worse.  Could have been 5 or 10 gigantic private methods.

  • 11-04-2009 11:28 PM In reply to

    Re: Encapsulation is too global

    Law Of Demeter http://en.wikipedia.org/wiki/Law_of_Demeter
Page 1 of 1 (6 items)
Powered by Community Server (Non-Commercial Edition), by Telligent Systems