This repo shows some examples of design patterns in ruby language. This is only for learning purposes and may contain failures or code that is not the best. This is intentionally to simplify the comprehension of the patterns.
I have been thinking about a global scenario in where I could show most part of examples. I have decided to apply examples to seller envoironment. But it is easy, we only are going to have invoices with seller or remitent info and line_concepts. this diagram will show you about it:
graph LR
Invoice[Invoice] -- has one --> SellerInfo[SellerInfo]
Invoice[Invoice] -- has one --> BuyerInfo[BuyerInfo]
Invoice[Invoice] -- has many --> LineConcept[LineConcept]
The patterns that are explained in this repository are:
- Adapters Pattern
- Builder Pattern
- Command Pattern
- Composite Pattern
- Decorator Pattern
- Facade Pattern
- Factory Pattern
- Iterator Pattern
- Observer Pattern
- Proxy Pattern
- Singleton Pattern
- Strategy Pattern
- Template Method Pattern
Feel free to add improvements or suggesting changes to the repo making requests.
Juan Manuel Jurado (jmjurado23)
-
I highly recommend read this book to understand design patterns in ruby: Desing patterns in Ruby (Russ Olsen)
-
Thanks to https://refactoring.guru for his effort explaining patterns in different languages.