Software Design Patterns

Software Design Patterns are commonly used on object-oriented software development, they are previously defined methods to design and code programs, used commonly by experts and corporations that benefit from structured and unified ways to develop and execute. They serve as a common framework for developers and promote good coding practices.

Source


They were not developed intentionally, they were instead created by trial and error and the prevalent ones are the ones that, by natural selection, were proven to be the best ones.
The Gang of Four, are the ones that wrote a book and set the SDP principles down, the book is called "Design Patterns - Elements of Reusable Object-Oriented Software". The two main principles are:

  • Program to an interface, not an implementation: Basically programming the classes in order for them to be implementable by other software, resuable and act as pieces of a bigger puzzle.
  • Favor composition over inheritance: Classes should implement other classes to complete their functionality, rather than inheriting from them.
There are a lot of desing patterns and not one is always the "correct" one, nonetheless, four main pattern types are defined:
  • Creational: Create objects on the go as they are being used.
  • Structural: The composition of objects is of most importance, mix and match to obtain new functionality.
  • Behavioral: Communication between objects is prioritized.
  • J2EE: Presentation layer.

Source: https://www.tutorialspoint.com/design_pattern/design_pattern_overview.htm