DEV Community

Discussion on: What dev topic do you think you should understand, but don't?

Collapse
 
somedood profile image
Basti Ortiz

Just to briefly answer two of the design patterns you mentioned:

  • Simply put, the Factory Design Pattern involves a method that returns an object based on the arguments given to it. It's basically an encapsulated way of instantiating objects. As a consequence of returning an object when invoking the factory, the new keyword is not needed to instantiate objects because the factory internally does that for you.
  • The Singleton Design Pattern is a way to make sure that classes are only instantiated once throughout the program. When attempting to instantiate a singleton, it either returns a new class instance (if it does not exist already) or returns the already instantiated singleton. This is not to be confused with static class properties.