/patterns

Practiced patterns and some engineering stuff

Primary LanguagePython

Patterns

This repo is created based on reading design patterns GoF element of reusable object-oriented software and clean architecture: a craftman's guide to software structure and design, so practice concepts on Python.

It mixed with some engineering work that Python is one option to do with.

Design Pattern Glossary:

  1. Creational patterns: design patterns that involve instantiating concrete objects.
  2. Behavioural patterns: design patterns that focus on how objects distribute work.
  3. Polymorphism: the ability to interact with objects of different types in the same way.
  4. Subclass: a class that inherits from a parent class, called a superclass.
  5. Subtype: a data type that inherits from a parent type, called a supertype.
  6. Inheritance: when a subtype or subclass inherits behaviours and methods from the supertype or superclass.
  7. Adapter pattern: a design pattern that connects two incompatible interfaces by fitting between them and providing a compatible interface to both.
  8. Command pattern: a behavioural pattern for encapsulating requests as objects.
  9. Composite class: a class which is designed to contain other classes, including objects of the same type.
  10. Composite pattern: a design pattern for composing nested structures of objects and dealing with these objects uniformly.
  11. Decorator pattern: a design pattern allowing for added behaviour through wrapping.
  12. Facade pattern: a design pattern that involves encapsulating a complex system in a simple interface.
  13. Factory Method pattern: a pattern that delegates concrete instantiation to a method of a subclass.
  14. Factory Object: any object whose main purpose is concrete instantiation, i.e. actually creating objects.
  15. Observer pattern: a behavioural pattern for event handling.
  16. Singleton pattern: a design pattern that enforces a single instantiation of a class that is globally accessible.
  17. State pattern: a behavioural pattern for handling requests taking into account the current state of the object.
  18. structural patterns: design patterns that describe how objects are connected to one another.
  19. Template Method pattern: a behavioural pattern that allows for similar behaviour to be inherited by multiple subclasses.
  20. Composing objects principle: an alternative method of code reuse that uses aggregation rather than inheritance.
  21. Chain of Responsibility pattern: a behavioural pattern for allowing multiple entities to handle requests.
  22. Open/Closed principle: a design principle dictating that an object should be open to extension, but closed to modification.
  23. Principle of least knowledge: a design principle stating that classes should know about and interact with as few other classes as possible. Also called the Law of Demeter.
  24. Separation of concerns: a design principle dictating that a program should separate different concerns or functions into separate objects or processes. Allows for easier maintenance and loose coupling.
  25. Favor composition over inheritance, especially for FP.
  26. Program to interface, not an implementation.
  27. Refactoring: the process of changing code so that external behaviours and interfaces are unchanged but internal structure is improved.

Git usage:

git log 
git add -p "atomic" changes 
git stash save ""
git reset <commit hash>//restore changes to specific commits 
git reset --soft <commit hash> //keep changes like unstaged changes 
git reset --hard <commit hash> //will remove changes 
git rebase --interactive <commit hash> //get all the repo commits