https://github.com/aminul-islam-niloy/design-patterns-oodp-using-java
Design Pattern Lab using java
https://github.com/aminul-islam-niloy/design-patterns-oodp-using-java
design-patterns java oop
Last synced: 3 months ago
JSON representation
Design Pattern Lab using java
- Host: GitHub
- URL: https://github.com/aminul-islam-niloy/design-patterns-oodp-using-java
- Owner: aminul-islam-niloy
- Created: 2024-01-15T09:51:42.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-01-15T10:33:10.000Z (over 1 year ago)
- Last Synced: 2025-01-12T15:46:23.842Z (5 months ago)
- Topics: design-patterns, java, oop
- Language: Java
- Homepage:
- Size: 20.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Design-Pattern-OODP-using-Java
## Object-Oriented Analysis and Design
### Software Architect and Design Roles in the Industry
**Concept:** In software development, the roles of software architects and designers are crucial. Software architects are responsible for high-level decisions regarding the overall structure and functionality of a system, while designers focus on the detailed aspects of implementing these decisions.**Uses:** Architects define the system's architecture, ensuring it aligns with business goals and is scalable. Designers, on the other hand, use this architecture to create detailed technical designs for individual components, ensuring they meet specifications.
### Object-Oriented Modeling
**Concept:** Object-oriented modeling involves creating abstract representations of a system's components, their properties, and the relationships between them. It helps in visualizing and understanding the system before the actual implementation.**Uses:** Modeling aids in communication between stakeholders, captures essential requirements, and guides the design process. It includes creating conceptual and technical models to represent the system's structure and behavior.
### Competing Qualities and Tradeoffs
**Concept:** Competing qualities refer to the conflicting requirements in software development, such as performance vs. maintainability. Tradeoffs involve making decisions that balance these qualities to achieve the best overall outcome.**Uses:** Developers must navigate tradeoffs to achieve a balance between qualities like efficiency, flexibility, and maintainability. Understanding competing qualities helps in making informed design decisions that align with project goals.
## Object-Oriented Modeling
### Abstraction in Java and UML
**Concept:** Abstraction involves simplifying complex systems by modeling only the essential aspects while ignoring unnecessary details. In Java and UML, abstraction is achieved through interfaces, abstract classes, and UML class diagrams.**Uses:** Abstraction helps manage complexity, facilitates communication among team members, and allows for changes in implementation without affecting the system's overall structure.
### Generalization with Inheritance in Java and UML
**Concept:** Generalization represents the relationship between a more general class (superclass) and a more specialized class (subclass) in object-oriented programming. In Java, this is achieved through inheritance, and in UML, it's visualized using class diagrams.**Uses:** Inheritance promotes code reuse, enhances maintainability, and supports the creation of a hierarchy of classes with shared characteristics.
## Design Principles
### Coupling and Cohesion
**Concept:** Coupling measures the degree of dependency between components, while cohesion measures how closely the elements within a component are related. Low coupling and high cohesion are design goals.**Uses:** Minimizing coupling and maximizing cohesion enhance system maintainability and flexibility. Components with low coupling can be modified independently, and high cohesion ensures that related functions are grouped together.
### UML Sequence Diagram
**Concept:** A UML sequence diagram illustrates the interactions between objects in a system over time. It shows the sequence of messages exchanged among objects.**Uses:** Sequence diagrams help visualize the dynamic aspects of a system, making it easier to understand and analyze the flow of interactions during runtime.
# Design Patterns - Creational and Structural Patterns
## Creational Patterns
### Singleton Pattern:
**Intent:** Ensure a class has only one instance and provide a global point of access to it.
**Use Case:** When you want to control access to a single instance of a class, like a configuration manager or a connection pool.
### Factory Method Pattern:
**Intent:** Define an interface for creating an object, but let subclasses alter the type of objects that will be created.
**Use Case:** When a class cannot anticipate the class of objects it must create, or when a class wants its subclasses to specify the objects it creates.
### Abstract Factory Pattern:
**Intent:** Provide an interface for creating families of related or dependent objects without specifying their concrete classes.
**Use Case:** When a system must be independent of how its objects are created, composed, and represented, and the family of related objects is designed to be used together.
### Builder Pattern:
**Intent:** Separate the construction of a complex object from its representation so that the same construction process can create different representations.
**Use Case:** When an algorithm for creating a complex object should be independent of the parts that make up the object and how they're assembled.
### Prototype Pattern:
**Intent:** Specify the kinds of objects to create using a prototypical instance and create new objects by copying this prototype.
**Use Case:** When the cost of creating an object is more expensive or complex than copying an existing object.
## Structural Patterns
### Adapter Pattern:
**Intent:** Convert the interface of a class into another interface clients expect. Adapter lets classes work together that couldn't otherwise because of incompatible interfaces.
**Use Case:** When you want to use a class with an incompatible interface, or when you want to create a reusable class that cooperates with unrelated or unforeseen classes.
### Bridge Pattern:
**Intent:** Decouple an abstraction from its implementation so that the two can vary independently.
**Use Case:** When you want to avoid a permanent binding between an abstraction and its implementation, or when changes in the implementation should not affect clients.
### Composite Pattern:
**Intent:** Compose objects into tree structures to represent part-whole hierarchies. Composite lets clients treat individual objects and compositions of objects uniformly.
**Use Case:** When clients should be able to treat individual objects and compositions of objects uniformly, or when you want to represent part-whole hierarchies.
### Decorator Pattern:
**Intent:** Attach additional responsibilities to an object dynamically. Decorators provide a flexible alternative to subclassing for extending functionality.
**Use Case:** When you need to add new functionality to an object without altering its structure, or when you want to allow for the combination of behaviors.
### Proxy Pattern:
**Intent:** Provide a surrogate or placeholder for another object to control access to it.
**Use Case:** When you need to control access to an object, or when you need to add some additional functionality when an object is accessed.
## Working with Design Patterns & Anti-patterns
### MVC Pattern
**Concept:** The Model-View-Controller (MVC) Pattern separates an application into three interconnected components: the model (data and business logic), the view (user interface), and the controller (handles user input).**Uses:** Promotes modular design and maintainability by separating concerns related to data, presentation, and user interaction.
### Liskov Substitution Principle
**Concept:** The Liskov Substitution Principle states that objects of a superclass should be replaceable with objects of a subclass without affecting the correctness of the program.**Uses:** Ensures that derived classes can be used interchangeably with their base classes, promoting compatibility and flexibility.
### Code Smells
**Concept:** Code smells are signs in the source code that indicate potential design flaws, which might lead to maintainability or performance issues.**Uses:** Identifying and addressing code smells improves code quality and helps prevent potential issues in the software development lifecycle.