Intro to Software Design patterns
This repository contains Java implementations of various design patterns and examples to illustrate its use and benefits.
So far, this repository covers the following design patterns:
-
Strategy Pattern
- Location:
strategy/
- The strategy pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it.
- Location:
-
Adapter Pattern
- Location:
adapter/
- The adapter pattern converts the interface of a class into another interface clients expect. Adapter lets classes work together that couldn't otherwise because of incompatible interfaces.
- Location:
-
Observer Pattern
- Location:
observer/
- The observer pattern defines a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.
- Location:
To run any of the pattern implementations:
-
Clone this repository:
git clone https://github.com/yourusername/design-patterns-java.git
-
Navigate to the pattern directory you are interested in:
cd design-patterns-java/strategy
- Compile and run the Java files (assuming you have JDK installed):
javac StrategyExample.java java StrategyExample