8
dUcKtYpEd
23d

Those of you who make an active effort to utilize patterns whenever possible, do you actually have this shit memorized or do you result back to the book like I do. My mind cannot retain the adaptor pattern for more then maybe a week before it is entirely lost on me again.

Comments
  • 11
    Eventually you just arrive at the patterns without having to recall them by name. Patterns are just ways that already exist to solve a problem.

    The other way to arrive at the right answer is to get as many of your associated functions as possible to be as close to O(1) as possible. Done this way, the right pattern manifests organically.
  • 1
    I feel bad about shoddy abstractions. If I move on to another task quickly I often leave mild chaos that's still better than improperly implemented design patterns. If I have time to spare I fix it until I can no longer think of a problem. At this point 95% of the time I can recognize a known pattern in the result.
  • 1
    I spent a week memorising Gof patterns, a few months applying whenever possible and making some mistakes. Now mostly memorised.

    Remembering the intent is the most important thing though. It's quite trivial to lookup how to implement a pattern if you remember which ones to consider...
  • 1
    Adapter is a little weird. Just read about it (I learned in college but it’s been years). If you want to create a class that uses an interface but uses functionality of other classes, you can create an adapter object that can create an object of those classes when it’s called. It’s kind of a headache I’ll admit. Lots of ring around the rosie
  • 1
    @d-fanelli that’s how I feel about it. Abstract factories too confusing to be practical too. Standard factory pattern, prototype, decorator, they make a lot of sense. Enough for me to utilize them when needed or at least know when to use them
  • 1
    @SortOfTested I envy that day. The more simple ones like factory And prototype I’ve been using forever but the more like he was saying “ring around the Rosie” ones I’m having trouble finding applicable usage for
  • 0
    @homo-lorens you saying your patterns emerge organically?
  • 0
    @dUcKtYpEd Yes, the majority design patterns are naturally occuring abstractions not arbitrarily designed tools that you have to learn. Learning about them allows the engineer to recognize the type of abstraction they need from a list, which is much faster than poking around and thus yields better results in less than ideal circumstances.
  • 0
    Adapters do help with cleaning up the code, so instead of if(thiscondition) {a.doThis()} else{b.doThis()} you can just pass the condition to the adapter and it will carry that out for you: adapter.doThis(thiscondition)
Add Comment