{"id":21974948,"url":"https://github.com/blaze-b/java-design-patterns","last_synced_at":"2025-06-11T09:32:19.138Z","repository":{"id":149530176,"uuid":"335996787","full_name":"blaze-b/java-design-patterns","owner":"blaze-b","description":"A complete guide of all the Java Design patterns for better coding practices","archived":false,"fork":false,"pushed_at":"2021-03-04T10:18:09.000Z","size":64,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-22T23:41:54.004Z","etag":null,"topics":["codequality","design-patterns","java9","learning-exercise"],"latest_commit_sha":null,"homepage":"","language":"Java","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/blaze-b.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-02-04T15:28:56.000Z","updated_at":"2021-02-26T06:57:24.000Z","dependencies_parsed_at":null,"dependency_job_id":"af211eb0-cc60-4f68-a87b-9c9163b8a61f","html_url":"https://github.com/blaze-b/java-design-patterns","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/blaze-b%2Fjava-design-patterns","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blaze-b%2Fjava-design-patterns/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blaze-b%2Fjava-design-patterns/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blaze-b%2Fjava-design-patterns/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/blaze-b","download_url":"https://codeload.github.com/blaze-b/java-design-patterns/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blaze-b%2Fjava-design-patterns/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259238960,"owners_count":22826830,"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":["codequality","design-patterns","java9","learning-exercise"],"created_at":"2024-11-29T15:48:47.786Z","updated_at":"2025-06-11T09:32:19.119Z","avatar_url":"https://github.com/blaze-b.png","language":"Java","readme":"## JAVA Design Patterns\n\n- Code should be written like poetry\n- Authors of Design patterns are Gang of Four, Erich Gamma, Richard Helm, Ralph Johnson and John Vlissidies in the year\n  1994\n\n### Follow Pattern Categories\n\n- Whenever 'new' is called use - Creational\n- Use of class hierarchies and relationships - Structural\n- Increase the flexibility in carrying out communication - Behavioral\n\n### Better Coding Should bring in easier understandability\n\n### Design first Approach\n\n- Instead of beating around the bush and jumping to coding right away, first analyse the requirements and design the\n  solution\n- Before even making a single line of code change, understand the design flow, that might take time initially but would\n  save a lot of time later and avoid run necessary bugs and issues\n- Use flow charts, data flow diagrams, time sequence diagrams and all other design tools available to draw and\n  understand design\n\n### Successful Software\n\n- A successful software in one which is secure, usable, performs well and satisfies all user requirements\n- This can be achieved with correct design and accurate implementation\n\n### Journey of creating Successful Software\n\n- On the journey of creating successful software several engineers have faced commonly occurring design issues related\n  to memory leak, object creation, classes structuring, components communication and wiring.\n\n- Documented these problems and solutions for other engineers benefit as design patterns\n\n### Design Pattern\n\n- Design pattern is a general repeatable solution to a commonly occurring problem in a software design.\n- It includes some of the best practices adapted by experienced object-oriented software developers.\n- It describes the problem, the solution, when to apply the solution, and its consequences\n- It is a ready-made templates that can be applied to your own designs to solve common problems which could be related\n  to object creation, object communication, class structuring or anything else\n- It gives a leg-up in creating flexible and maintainable object-oriented systems\n\n### Advantages\n\n- Makes your life easier by not reinventing the wheel.\n- Use the power of a shared vocabulary\n- Solve issues even before they become visible\n- Better code quality\n- Improve your object-oriented skills\n- Recognise the patterns in libraries and languages\n- Give you an extra edge for job and promotion\n\n### Anti-pattern of Software\n\n- Spaghetti Code\n- Cut-and-Paste Programming\n\n## Design Patterns are language independent\n\n### Object Inheritance\n\n- It is a mechanism in which one object acquires all the properties and behaviours of the parent object\n- It allows programmers to create classes that are built upon existing classes, to specify a new implementation to\n  maintain the same behaviour to reuse code\n- Inheritance causes issues which coding as changes in the base classes will require more QA testing\n\n### Code Reusability\n\n- Is your code dry or wet?\n    - DRY - Don't Repeat Yourself is a software development principle, the main aim of which is to reduce repetition of\n      code\n    - WET - Write Every Time is a cheeky abbreviation to mean the opposite, that is, code that doesn't adhere to DRY\n      Principle\n    - Bad Software Characteristics - Rigidity, Fragility, Immobility\n    - Software Design Principles\n        - `S.O.L.I.D` acronym\n        - It stands for:\n            - `S` Single responsibility principle\n            - `O` Open Closed Principle\n            - `L` Liskov substitution principle\n            - `I` Interface segregation principle\n            - `D` Dependency inversion principle\n\n### Cyclomatic Complexity\n\n- Lower the program's cyclomatic complexity, lower the risk to modify and easier to understand\n- Formula - `E-N+2*P`\n    - `E` = number of edges in the flow graph\n    - `N` = number of nodes in the flow graph\n    - `P` = number of nodes that have exit points\n\n### Tight Coupling\n\n- It is when a group of classes is highly dependent on a one another\n- Minor changes in one class creates a ripple effect and causes modification in too many changes\n- Interface helps in decoupling\n\n### Recognise the pattern of problems ans design solutions\n\n- Be a software doctor\n- Understand the memory issue\n- Recognise the pattern of problems and design solutions around it\n\n### Design Patterns Categorization\n\n- What is an Object ?\n    - An object consist of:\n        - `State` represented by attributes or properties of an object\n        - `Behaviour` represented by methods of an object\n        - `Identity` gives a unique identifier to an object also called as reference object\n- Philosophy behind Categorization\n    - Object is created from a class which has certain behaviour and is structured in certain way to communicate:\n        - Creational Patterns,\n            - It defines the best possible way to instantiate an object while hiding the creation logic\n            - Types:\n                - Builder\n                - Singleton\n                - Factory Method\n                - Abstract Method\n                - Prototype\n        - Structural Patterns,\n            - It describes how objects and classes can be combined to form larger structures\n            - Types:\n                - Adaptor\n                - Bridge\n                - Composite\n                - Decorator\n                - Facade\n                - Proxy\n        - Behavioral Patterns,\n            - Patterns specifically concerned with communication (interaction) between the objects. The interactions\n              between the objects should be such that they are talking to each other and still are loosely coupled,\n            - Types\n                - Strategy\n                - Command\n                - Interpreter\n                - Iterator\n                - Chain of Responsibility\n                - Mediator\n                - Memento\n                - Observer\n                - State\n                - Template\n                - Visitor\n\n### Design Patterns used in the Spring Framework\n\n- Singleton Pattern\n- Factory Pattern\n- Template Patterns\n- Observer-Observable\n- Proxy","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblaze-b%2Fjava-design-patterns","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fblaze-b%2Fjava-design-patterns","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblaze-b%2Fjava-design-patterns/lists"}