Skip to content

jadogeri/Design_Patterns_Java

Design Patterns JAVA

Version: 1.0.0

Date: September 28, 2025


Description

This repository is for learning and implementing software design patterns concepts.

Authors

@jadogeri

Repository

https://github.com/jadogeri/Design_Patterns_Java.git

Screenshots

Screenshot 1 screenshot 2

Table of Contents

  • 7. References
    • 1. Introduction

      1.1 Purpose

      The purpose of this project is to learn and apply software design patterns principles in java applications.

      1.2 Scope

      This project will allow users to :

      • Utilize code snippet in larger project.
      • Implement SOLID principles to promote clean code.

      1.3 Intended Audience

      • Junior or Senior backend developers.
      • Beginners learning (Java) and design patterns in software engineering.

      2. Technology Stack

      • Programming Languages: Java
      • IDE: IntelliJ and Visual Studio Code (VSCode)
      • Plugins: Early AI, Google AI
      • Version Control: Git and GitHub
      • Code Analsis: SonarQube

      3. Project Structure

      A Java project can be structured to demonstrate various design pattern implementations. This involves organizing code into packages and classes that exemplify the principles and structures of different patterns. Project Structure: A common approach is to create a top-level package for the project, such as com.example.designpatterns. Within this, sub-packages can be created for each category of design patterns (Creational, Structural, Behavioral) and further sub-packages for individual patterns.

      design-patterns
      └── src/main/java
          ├── creational
          │   ├── singleton
          │   │   ├── Connection.java
          │   │   ├── DatabaseClient.java
          │   │   ├── MySql.java
          │   │   ├── Oracle.java
          │   │   ├── MongoDB.java
          │   │   ├── PostgresSql.java
          │   │   └── SingletonRunner.java
          │   ├── factory
          │   │   ├── Game.java
          │   │   ├── GameFactory.java
          │   │   ├── PlayStation.java
          │   │   ├── Nintendo.java
          │   │   ├── Xbox.java
          │   │   ├── PlayStationFactory.java
          │   │   ├── NintendoFactory.java
          │   │   ├── XboxFactory.java
          │   │   └── FactoryRunner.java
          │   └── builder
          │       ├── Pizza.java
          │       ├── Product.java
          │       └── BuilderRunner.java
          ├── structural
          │   ├── adapter
          │   │   ├── LegacyPrintable.java
          │   │   ├── ModernPrintable.java
          │   │   ├── LegacyPrinter.java
          │   │   ├── PrinterAdapter.java
          │   │   └── AdapterRunner.java
          │   ├── decorator
          │   │   ├── Burger.java
          │   │   ├── RegularBurger.java
          │   │   ├── BurgerDecorator.java
          │   │   ├── MayoDecorator.java
          │   │   ├── OnionDecorator.java
          │   │   ├── PickleDecorator.java
          │   │   ├── CheeseDecorator.java
          │   │   └── DecoratorRunner.java
          │   └── facade
          │       ├── ApplePay.java
          │       ├── VisaCard.java
          │       ├── DHL.java
          │       ├── MonarchInventoryService.java
          │       ├── PaymentService.java
          │       ├── InventoryService.java
          │       ├── ShippingService.java
          │       ├── USPS.java
          │       ├── OrderFacade.java
          │       └── FacadeRunner.java
          └── behavioral
              ├── strategy
              │   ├── Card.java
              │   ├── CreditCardStrategy.java
              │   ├── DebitCardStrategy.java
              │   ├── PaypalStrategy.java
              │   ├── PaymentStrategy.java
              │   ├── InsufficientFundsException.java
              │   ├── ShoppingCart.java
              │   └── StrategyRunner.java
              ├── observer
              │   ├── Subject.java
              │   ├── Observer.java
              │   ├── ChatRoom.java
              │   ├── Message.java
              │   ├── User.java
              │   └── ObserverRunner.java
              └── command
                  ├── Command.java
                  ├── Device.java
                  ├── Radio.java
                  ├── Light.java
                  ├── Television.java
                  ├── Light.java
                  ├── TurnOnCommand.java
                  ├── TurnOffCommand.java
                  ├── AdjustvolumeCommand.java
                  ├── ChangeChannelCommand.java
                  ├── RemoteControl.java
                  └── CommandRunner.java
      
      

      Implementation Details:

        Creational Patterns:
      1. Singleton: Implement a class with a private constructor, a static instance, and a static getInstance() method to ensure only one instance exists.
      2. Factory Method: Define an interface or abstract class for products and concrete product implementations. Create a factory interface/abstract class and concrete factories to create product objects.
      3. Builder: Create a separate builder class to construct complex objects step-by-step, allowing for flexible object creation.
        Structural Patterns:
      1. Adapter: Create an adapter class that allows incompatible interfaces to work together by converting the interface of one class into another.
      2. Decorator: Use concrete decorator classes to add new responsibilities to objects dynamically without modifying their core structure.
      3. Facade: The primary class, subsystems the facade interacts with and a client component or application that uses the facade to access the subsystem's.
        Behavioral Patterns:
      1. Strategy: Define an interface for a family of algorithms, encapsulate each algorithm in a separate class, and allow clients to choose the desired algorithm at runtime.
      2. Observer: Implement a subject (publisher) and observer (subscriber) interface. The subject maintains a list of observers and notifies them of state changes.
      3. Command: Create Command objects (e.g., TurnOnLightCommand) to encapsulate requests, executed by a RemoteControl.

      4. Installation


      5. Usage

      Prerequisites :installation of IntelliJ IDE and Java.

      5.1 Run Application

      0 open intelliJ IDE.

      1 Select option CLONE REPOSITORY .

      2 Copy and paste url https://github.com/jadogeri/Design_Patterns_Java.git and choose location to save project then press clone.

      (Note!! choose empty folder : I created folder repo)

      clone project

      3 Change view to Project.

      4 Navigate to design_patterns --> src --> main -- java.

      5 To run any of the design patterns (using command pattern for illustration) Navigate to behavioral --> command --> CommandRunner .

      Note!! each pattern has a file ending in *.Runner.java to run the app.

      6 Press play button to start application.

      start application


      6. License

      LICENSE


      7. References

About

Utilizing Software Design Pattern Templates in Java and Explanation

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages