Saturday, April 28, 2018

Command, Repository and Mediator design patterns.

This has a little write up on the three. We all know what the repository pattern is, right? A repository is the infrastructure project level machinery for getting an object of a particular type to and from the database in Onion Architecture. Command feels like the actions in the Redux stuff and Mediator is harder to understand. Rules wrapping objects defining how they are used? The copy in the first link I provide suggests it is like the Facade pattern which seems to be about having a front door like an interface or a wrapper "protecting" the guts of some machinery. It also suggests it may be used with the Observer pattern. Facade+Observer=Mediator? The Pragmatic Programmer by Andy Hunt and Dave Thomas is perhaps a book that goes into patterns some. This is all on mind after an exchange over lostechies.slack.com in which I roll my eyes at the patterns and offer:

  • I'm missing something with the patterns. Those old patterns like the decorator pattern which so violates DDD just seems like something I would never use. It is so niche. Most of them are, so particular they are impractical. Think of the first chapter in Head First Design Patterns which dips into the strategy pattern and has duck inheriting from rubber duck in a Liskov violation. I read that chapter and I stopped reading the book after that. I never see a pattern anywhere I work beyond the overall architecture. I never think "Oh, today I'm going to use the Observer pattern to solve this problem."
  • ugh, other way around ... the book had rubber duck inheriting from duck
  • I guess I see patterns in frameworks and perhaps in the architecture of a particular application but in both of those cases it isn't really put upon the average Joe developer to think of what pattern to use to solve a problem or see the way to cut through the hedge maze by picking the right chainsaw. Instead, downstream of big upfront decisions, there is little elegance or ingenuity. At that point everyone is just wandering inside of the hedge maze instead of trying to make it better.

It may have been a decoy duck instead of a rubber duck honestly...

No comments:

Post a Comment