design-patterns

所属分类:Java编程
开发工具:Java
文件大小:0KB
下载次数:0
上传日期:2023-10-30 07:25:33
上 传 者sh-1993
说明:  这个GitHub存储库展示了流行设计模式的Java代码示例。代码有很好的文档记录,并对ea...
(This GitHub repository showcases Java code examples of popular design patterns. The code is well-documented with clear explanations of each pattern s purpose and usage, making it a valuable resource for Java developers looking to implement design patterns in their code.)

文件列表:
pom.xml (655, 2023-10-30)
src/ (0, 2023-10-30)
src/main/ (0, 2023-10-30)
src/main/java/ (0, 2023-10-30)
src/main/java/io/ (0, 2023-10-30)
src/main/java/io/nerd/ (0, 2023-10-30)
src/main/java/io/nerd/abstractfactory/ (0, 2023-10-30)
src/main/java/io/nerd/abstractfactory/Computer.java (314, 2023-10-30)
src/main/java/io/nerd/abstractfactory/ComputerAbstractFactory.java (112, 2023-10-30)
src/main/java/io/nerd/abstractfactory/ComputerFactoryProvider.java (197, 2023-10-30)
src/main/java/io/nerd/abstractfactory/DemoAbstractFactory.java (744, 2023-10-30)
src/main/java/io/nerd/abstractfactory/PC.java (498, 2023-10-30)
src/main/java/io/nerd/abstractfactory/PCFactory.java (405, 2023-10-30)
src/main/java/io/nerd/abstractfactory/Server.java (507, 2023-10-30)
src/main/java/io/nerd/abstractfactory/ServerFactory.java (416, 2023-10-30)
src/main/java/io/nerd/adapter/ (0, 2023-10-30)
src/main/java/io/nerd/adapter/AdapterDemo.java (1044, 2023-10-30)
src/main/java/io/nerd/adapter/Socket.java (208, 2023-10-30)
src/main/java/io/nerd/adapter/SocketAdapter.java (224, 2023-10-30)
src/main/java/io/nerd/adapter/SocketAdapterImpl.java (673, 2023-10-30)
src/main/java/io/nerd/adapter/Volt.java (349, 2023-10-30)
src/main/java/io/nerd/builder/ (0, 2023-10-30)
src/main/java/io/nerd/builder/Demo.java (535, 2023-10-30)
src/main/java/io/nerd/builder/UserAccount.java (1164, 2023-10-30)
src/main/java/io/nerd/builder/UserBuilder.java (872, 2023-10-30)
src/main/java/io/nerd/builder/UserBuilderImpl.java (2343, 2023-10-30)
src/main/java/io/nerd/command/ (0, 2023-10-30)
src/main/java/io/nerd/command/Command.java (75, 2023-10-30)
src/main/java/io/nerd/command/CommandDemo.java (336, 2023-10-30)
src/main/java/io/nerd/command/Light.java (198, 2023-10-30)
src/main/java/io/nerd/command/LightOnCommand.java (240, 2023-10-30)
src/main/java/io/nerd/command/SimpleRemoteControl.java (265, 2023-10-30)
src/main/java/io/nerd/decorator/ (0, 2023-10-30)
src/main/java/io/nerd/decorator/Beverage.java (230, 2023-10-30)
src/main/java/io/nerd/decorator/CondimentDecorator.java (190, 2023-10-30)
src/main/java/io/nerd/decorator/DecoratorDemo.java (628, 2023-10-30)
src/main/java/io/nerd/decorator/Espresso.java (232, 2023-10-30)
src/main/java/io/nerd/decorator/HouseBlend.java (217, 2023-10-30)
... ...

# Design Patterns Implementation Repository Welcome to the Design Patterns Implementation repository! This repository contains a comprehensive implementation of various design patterns in the world of software development. Whether you're new to design patterns or looking to refresh your knowledge, this repository aims to provide clear and concise examples for each pattern. ## Table of Contents 1. [Introduction](https://github.com/hassanrefaat9/design-patterns/blob/master/#introduction) 2. [Design Patterns](https://github.com/hassanrefaat9/design-patterns/blob/master/#design-patterns) - [Creational Patterns](https://github.com/hassanrefaat9/design-patterns/blob/master/#creational-patterns) - [Structural Patterns](https://github.com/hassanrefaat9/design-patterns/blob/master/#structural-patterns) - [Behavioral Patterns](https://github.com/hassanrefaat9/design-patterns/blob/master/#behavioral-patterns) ## Introduction Design patterns are reusable solutions to common problems that developers face during software design and development. They provide well-tested approaches for solving specific types of problems and help in creating code that is more maintainable, modular, and flexible. This repository aims to cover a wide range of design patterns, categorized into three main groups: creational, structural, and behavioral patterns. Each pattern comes with a clear explanation and a practical implementation in a variety of programming languages. ## Design Patterns ### Creational Patterns 1. **Singleton**: Ensure a class has only one instance and provides a global point of access to it. 2. **Factory Method**: Define an interface for creating objects, but let subclasses decide which class to instantiate. 3. **Abstract Factory**: Provide an interface for creating families of related or dependent objects. 4. **Builder**: Separate the construction of a complex object from its representation, allowing the same construction process to create various representations. 5. **Prototype**: Specify the kinds of objects to create using a prototypical instance, creating new objects by copying this prototype. ### Structural Patterns 1. **Adapter**: Convert the interface of a class into another interface clients expect. Allows classes with incompatible interfaces to work together. 2. **Bridge**: Decouple an abstraction from its implementation, allowing both to evolve independently. 3. **Composite**: Compose objects into tree structures to represent part-whole hierarchies. Composite lets clients treat individual objects and compositions of objects uniformly. 4. **Decorator**: Attach additional responsibilities to objects dynamically. Provides a flexible alternative to subclassing for extending functionality. 5. **Facade**: Provide a unified interface to a set of interfaces in a subsystem. Defines a higher-level interface that makes the subsystem easier to use. 6. **Flyweight**: Use sharing to support a large number of fine-grained objects efficiently. ### Behavioral Patterns 1. **Chain of Responsibility**: Avoid coupling the sender of a request to its receiver by giving more than one object a chance to handle the request. 2. **Command**: Turn a request into a stand-alone object, containing all information about the request. This decouples sender and receiver. 3. [**Interpreter**: Provide a way to evaluate language grammar or expressions. Often used for DSLs (domain-specific languages). 4. **Iterator**: Provide a way to access elements of a collection sequentially without exposing its underlying representation. 5. **Mediator**: Define an object that encapsulates how a set of objects interact. Promotes loose coupling by preventing objects from referring to each other explicitly. 6. **Memento**: Capture and restore an object's internal state. Allows an object to be restored to its previous state. 7. **Observer**: Define a dependency between objects, so that when one object changes state, all its dependents are notified and updated automatically. 8. **State**: Allow an object to change its behavior when its internal state changes. 9. **Strategy**: Define a family of algorithms, encapsulate each one, and make them interchangeable. Lets the algorithm vary independently from clients using it. 10. **Template** Method: Define the program skeleton in a method, but let subclasses override certain steps of the algorithm. 11. **Visitor**: Define a new operation to a set of objects without changing their classes. Useful when adding new behaviors to classes is impractical or impossible. ## Getting Started To get started with this repository, follow these steps: 1. Clone the repository to your local machine: `git clone https://github.com/yourusername/design-patterns-implementation.git` 2. Navigate to the desired design pattern directory: `cd design-patterns-implementation/Creational/Singleton` (replace with the desired pattern) 3. Explore the code examples and accompanying explanations. 4. Choose your preferred programming language and explore the implementation details.

近期下载者

相关文件


收藏者