↓ Ir para o conteúdo principal

← todas as notas

📎 Webclip

Devs: Don’t Just Read About Design Patterns, Implement Them

The post says design patterns help document software, but they teach better through examples you can build. Its C# example uses hero animals, missions, and lairs to show extendable design as something that can change without breaking the system.

Reading notes
#

  • Design patterns are useful for confirming repeatable structures after you encounter them, but examples are better for learning how to solve new problems.
  • The article uses a light-hearted C# setup with hero animals on a mission to explain the strategy or command pattern idea.
  • Extendable design means knowing what can be altered or added without breaking the system.
  • The mission is separate from the roster of heroes, so the system can use any animal heroes you define.
  • The roster contains classes such as Penguin, Shark, Goat, and Gorilla.
  • HeroAnimal is an abstract class that defines skills like canFly, canSwim, canClimb, canCrawl, and a home biome.
  • Lair is an interface with a CanHeroBreakIn method.
  • A Castle lair can be broken into by a flying hero or a climbing hero.
  • Biomes are defined as Forest, Ice, Plains, Swamp, and Sea.
  • Fish and Bird serve as base classes for hero animals, and Shark and Penguin are concrete examples.
  • The system selects a team by list search and match, and the list could be mixed before each run.
  • New animal heroes, lairs, missions, and even biomes can be added, though removing biomes might break existing heroes.
  • The article closes by saying the Gang of Four should be respected after working on solutions yourself.