↓ Ir para o conteúdo principal

← todas as notas

📎 Webclip

3 Design Patterns Every Developer Should Learn

The article treats design patterns as high-level ways to approach recurring software problems, not as code itself. It says they help make code easier to adapt, create a shared vocabulary, and become more important as developers build larger systems and microservices.

Reading notes
#

  • Design patterns are described as recurring approaches to common problems in software engineering, not as code.
  • They are presented as useful for making code more readable and adaptable.
  • They also create a shared vocabulary, so teams can communicate with names like Singleton.
  • The article recommends three patterns to learn: Strategy, Singleton, and Observer.
  • Strategy is used to choose between algorithms at runtime and supports the open-closed principle.
  • The delivery example shows separate strategies for bike, car, rail, air, and ship instead of one growing class.
  • Singleton is used when only one instance of a class is needed and when shared resources must be controlled.
  • The article mentions configuration settings, in-memory data, and comparators as examples of singleton use.
  • Observer is presented as a one-to-many relationship where one object notifies others about changes.
  • Examples given for Observer include Netflix subscriptions, email notifications, news alerts, Redux, CI builds, Kafka, RabbitMQ, Amazon SNS, and NATS.
  • The article warns that design patterns can be overused and should be chosen only when they fit the project.
  • It stresses that knowing a pattern’s name is not the same as understanding its constraints and tradeoffs.
  • The origin of the idea is traced to Christopher Alexander and later to the 1994 book by the Gang of Four, which popularized design patterns in software development.