{"id":19541465,"url":"https://github.com/genesisblock3301/deep_design_pattern","last_synced_at":"2026-06-07T21:02:06.343Z","repository":{"id":50468602,"uuid":"414929034","full_name":"GenesisBlock3301/deep_design_pattern","owner":"GenesisBlock3301","description":"Try to cover major principle of OOP and common design pattern using python.","archived":false,"fork":false,"pushed_at":"2024-01-23T07:36:14.000Z","size":28,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-01-08T18:45:42.879Z","etag":null,"topics":["design-patterns","factory-pattern","python","singleton-pattern","solid"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GenesisBlock3301.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-10-08T09:42:24.000Z","updated_at":"2022-08-29T07:24:24.000Z","dependencies_parsed_at":"2024-01-23T08:46:51.926Z","dependency_job_id":null,"html_url":"https://github.com/GenesisBlock3301/deep_design_pattern","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GenesisBlock3301%2Fdeep_design_pattern","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GenesisBlock3301%2Fdeep_design_pattern/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GenesisBlock3301%2Fdeep_design_pattern/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GenesisBlock3301%2Fdeep_design_pattern/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GenesisBlock3301","download_url":"https://codeload.github.com/GenesisBlock3301/deep_design_pattern/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240795204,"owners_count":19858767,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["design-patterns","factory-pattern","python","singleton-pattern","solid"],"created_at":"2024-11-11T03:10:39.277Z","updated_at":"2025-02-26T05:18:33.593Z","avatar_url":"https://github.com/GenesisBlock3301.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Design Pattern\n\nBefore learning desing pattern we should take deep knowledge about **Object Oriented Programming**.\n\n## Major aspects of OOP\n\n#### Encapsulation:\nThe key features of encapsulation:\n\n\u003cul\u003e\n\u003cli\u003eAn objects behavior is kept hidden from the outside world.\u003c/li\u003e\n\u003cli\u003eClient not directly change internal state acting on them rather client can send request to object. According to this request object change state such as set and get .\u003c/li\u003e\n\u003cli\u003eIn python doesn't have public, private and protected keywords but accessibility can be made using __(double underscore) in the variable or function name.\n\u003c/ul\u003e\n\n#### Polymorphism:\nThe key features of polymorphism:\n\n\u003cul\u003e\n\u003cli\u003eTwo types of polymorphism:\u003cul\u003e\n\u003cli\u003eAn object provides different implementation of the method based on input parameters.\u003c/li\u003e\n\u003cli\u003eThe same interface can be used by objects different types.\u003c/li\u003e\n\u003c/ul\u003e\u003c/li\u003e\n\u003cli\u003eIn python polymorphism build in feature.For example: + operator can add two or more integers and also concate string\u003c/li\u003e\n\u003c/ul\u003e\n\n\n#### Inheritance\nThe key features of inheritance:\n\n\u003cul\u003e\n\u003cli\u003eInheritance indicates that one class derives functionality from the parent class.\u003c/li\u003e\n\u003cli\u003eInheritance is described as an option to reuses functionality of parent class.\u003c/li\u003e\n\u003cli\u003eInheritance creates hierarchy via the relationships among objects of different classes.\u003c/li\u003e\n\u003c/ul\u003e\n\n#### Abstract\nThe key features of Abstruct:\n\n\u003cul\u003e\n\u003cli\u003eIt provides you simpe interface to the client , where the clients can interact with class objects and call methods defined in the interface.\u003c/li\u003e\n\u003cli\u003eAbstruct can create abstruct method as well as can implement method inside class but interface can't do that.\u003c/li\u003e\n\u003c/ul\u003e\n\n\n#### Composition\nThe key features of Composition:\n\n\u003cul\u003e\n\u003cli\u003eIt is way to combine objects or classes into more complex data structure or software implementation.\u003c/li\u003e\n\u003cli\u003eIn composition, an object is used to call member functions in other modules thereby making base functionality available across modules without inheritance.\u003c/li\u003e\n\u003c/ul\u003e\n\n```python\nclass A:\n    def a1(self):\n        print(\"a1\")\n\nclass B:\n    def b(self):\n        print(\"b\")\n        A().a1()\nobj = B()\nobj.b()\n```\n\n## Object Oriented Design Principles:\n\n\n#### The Single responsibility principle:\n\n\u003e  Single responsibility principle states that a class should have only one reason to change.\n\nIf a class taking care of two functionality, it is better to split them.\n\n#### The Open/Close principle:\n\u003e The open/close principle state that classes or objects and methods are open for extension but close from modifications.\n\nThat means when we develop our software make sure that our writing classes or modules in a generic way. That's you can do extend behavior of class but not change to class itself.\n\nFor example: In Django user has to create a class implementation by extending the base abstract class to implement the required behavior insteat of changing the abstract class.\n\n#### The inversion of control principle:\n\n\u003e The inversion of control principle states that hight level modules shouldn't be depend on low level modules; they should both dependent on abstractions. Details should depend on abstractions and not the other way round.\n\nThis principle suggested that any two modules shouldn't be dependent on each other(loose coupling or decouple).\n\nThis priciciples also suggested that the details of your class should represent the abstractions.\n\n#### The interface segregation principle:\n\u003e This principle states that clients shouldn't be forced to depend on interface they don't use.\n\nThis principle suggestes that Develop mothods relevant to functionality. If there any method that is not related to the interface, the class dependent on the interface has to implement it unnecessary. \n\n#### The substitute principle:\n\u003e This principle states that derived classes must be able to completely substitute the base classes.\n\n# The concept of design pattern:\n\n#### Advantage of design pattern:\n\n\u003cul\u003e\n\u003cli\u003eThey are reusable across multiple projects.\u003c/li\u003e\n\u003cli\u003eThe architectural level problems can be solved.\n\u003cli\u003e They are time-tested and well-proven, which is the experience of developers and architects.\n\u003cli\u003e They have reability and dependence.\n\u003c/ul\u003e\n\n\n## Classification of Patterns:\n\n \u003cul\u003e\n \u003cli\u003eCreational Patterns\n \u003cli\u003eStructural Patterns\n \u003cli\u003eBehavioral Patterns\n \u003c/ul\u003e\n\n#### Creational Patterns:\n\u003cul\u003e\n\u003cli\u003eThey work on basis of how objects can be created.\n\u003cli\u003e They isolate the details of objects creations.\n\u003cli\u003e Code is independent of the type of object\n\u003c/ul\u003e\n\n#### Structural Patterns:\n\u003cul\u003e\n\u003cli\u003eThey design the structure of objects and classes so that they can compose to achieve larger results.\n\u003cli\u003e The focus is on simplifiying the structure and identifying the relationship between classes and objects.\n\u003cli\u003e They focus on class inheritance and composition.\n\u003c/ul\u003e","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgenesisblock3301%2Fdeep_design_pattern","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgenesisblock3301%2Fdeep_design_pattern","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgenesisblock3301%2Fdeep_design_pattern/lists"}