Skip to content

eranga2000/designPatterns

Repository files navigation

DESIGN PATTERNS WITH JAVA

Java Design Patterns

This repository contains Java implementations of commonly used design patterns. The goal is to demonstrate how these patterns can be applied in real-world scenarios and help developers write more maintainable, flexible, and scalable code.

Design Patterns Implemented

1. Singleton Pattern

The Singleton pattern ensures that a class has only one instance and provides a global point of access to that instance. This implementation is useful when a single shared resource or configuration is required throughout an application.

  • Example: Database connection pool, Logging services, or Configuration settings.

2. Adapter Pattern

The Adapter pattern allows incompatible interfaces to work together by converting one interface to another. It helps in making two different interfaces compatible by creating a "wrapper" class.

  • Example: A legacy system interfacing with a new API, or different types of payment gateways integrated into a unified payment system.

3. Strategy Pattern

The Strategy pattern allows selecting an algorithm at runtime. It enables a class to change its behavior by changing its strategy without modifying the class itself.

  • Example: Sorting algorithms (QuickSort, MergeSort, etc.) or different payment strategies (Credit Card, PayPal, etc.) in an e-commerce platform.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages