Coding / Programming Videos

Post your favorite coding videos and share them with others!

[Design Pattern in JavaScript] Factory – Jyun-Han Lin – Medium

Source link


From wiki

it doesn’t explicitly require us to use a constructor. Instead, a Factory can provide a generic interface for creating objects, where we can specify the type of factory object we wish to be created.



When our object or component setup involves a high level of complexity

When we need to easily generate different instances of objects depending on the environment we are in

When we’re working with many small objects or components that share the same properties

When composing objects with instances of other objects that need only satisfy an API contract (aka, duck typing) to work. This is useful for decoupling.



Source link


Leave a Reply

Please Login to comment
Notify of
Translate »