Loading repository dataβ¦
Loading repository dataβ¦
AllThingsSmitty / repository
π§ A collection of essential design pattern examples in JavaScript π§°
A transparent discovery signal based on current public GitHub metadata.
This score does not audit code, security, maintainers, documentation quality, or suitability. Verify the repository and its current documentation before adoption.
A collection of essential design patterns for software development using practical examples, such Singleton, Factory Method, Observer, and more, to help developers write more efficient and maintainable code.
Not sure which pattern to use? Here's a quick reference:
| Problem | Pattern | Use When |
|---|---|---|
| Need exactly one instance | Singleton | App needs a single shared resource (logger, config, DB) |
| Creating many similar objects | Factory Method | You have multiple types but want to hide the "new" keyword |
| Building complex objects step-by-step | Builder | Objects have many optional parameters or complex setup |
| Multiple ways to do something | Strategy | Algorithm choice varies; avoid massive if/else chains |
| Adding features to objects | Decorator | Wrapping objects with additional behavior (Java: logging, caching) |
| Simplifying complex systems | Facade | Hide complexity of subsystems behind simple interface |
| Working with tree/hierarchy | Composite | Folders/files, UI components, organization trees |
| Existing code doesn't match | Adapter | Integrating legacy code or third-party libraries |
| Tracking changes to objects | Observer | Event listeners, pub/sub systems, state changes |
| Different behavior per state |
| Objects behave differently based on internal state |
Learning Path (Recommended Order):