Skip to content

shihabmuhtasim/Pattern-Craft---Design-Patterns

Repository files navigation

PatternCraft – Design Patterns Portfolio

patterncraft-cover

A curated collection of software design pattern implementations developed as part of a university course on Design Patterns.
This repository showcases clean, modular, and extensible solutions to real-world inspired problems, each focusing on specific GoF (Gang of Four) design patterns.

The project is structured as seven independent assignments, each implemented in its own folder and demonstrating one or more design patterns in action. Together, they form a cohesive portfolio suitable for academic evaluation and professional CVs.


📦 Repository Structure

Each assignment is contained in its own folder (to be renamed based on the short titles below):

PatternCraft/
│
├── 1-TradePulse/
├── 2-ContactCore/
├── 3-LibraryFlyweight/
├── 4-ChatStateHub/
├── 5-DocuGuard/
├── 6-ApprovalChain/
└── 7-PayFlex/

🧩 Assignments Overview

1. TradePulse

Stock Market Simulation

Design Patterns Used: Strategy, Observer

Assignment Description:

  • Design a simple stock market simulation system that incorporates the following design patterns:
    • Strategy Pattern: Implement different trading strategies.
    • Observer Pattern: Notify traders when stock prices change.
  • Requirements:
    • Create a Stock class with name and price attributes.
    • Implement a StockMarket class that holds a collection of stocks.
    • Design trading strategies using the Strategy pattern (simply print whether the trader buys the given stock. No need to maintain a list of how much is owned).
    • LowPriceStrategy: buy when price < 500.
    • HighPriceStrategy: buy when price > 1000.
    • Implement the Observer pattern to notify traders of price changes.

2. ContactCore

Contact Management System

Design Patterns Used: DAO, Factory Method, Abstract Factory

Assignment Description:

  • Create a contact management system.
  • Storing Contacts and Addresses.
  • System should not be dependent on how data is stored.
  • Create an implementation for storing contacts in memory, or serializing them to file.
  • But leave the system open for further extensions to store in other formats.
  • Contacts should have:
    • id, First name, Last name, email.
  • Addresses should have:
    • id, Street, City, Post code, contact ID.
  • Utilize DAO, Factory Method and Abstract Factory.
  • Write demo code utilizing the contact management system, accessing Contacts and Addresses separately, as well as together (getting the address for a contact).

3. LibraryFlyweight

Large-Scale Library Management

Design Patterns Used: Flyweight, Visitor

Assignment Description:

  • Develop a system for a large library that manages various types of media items (books, magazines, and DVDs).
  • The library could have millions of items, and to conserve memory, you need to use the Flyweight pattern for sharing common attributes.
  • Additionally, the library wants to perform different operations on these items without modifying the item classes, using the Visitor pattern.
  • Your task is to implement this system using both the Flyweight and Visitor patterns.
  • The system should:
    1. Use Flyweight to share common attributes (e.g., publisher, genre) among media items.
    2. Implement at least three types of media items: Book, Magazine, and DVD.
    3. Use the Visitor pattern to implement three operations:
      • Calculate lending fee for each item (varies by item type and condition).
      • Show catalog entry: display the item (format differs for each item type).
      • Search for items of a particular Genre.
    4. Demonstrate the usage of both patterns in a main method.

4. ChatStateHub

State-Aware Chat Application

Design Patterns Used: Mediator, State

Assignment Description:

  • Extend the chat room example where the chat application allows users to communicate with each other.
  • Users can be in different states, such as "Online", "Away", or "Busy", and they can switch between these states.
  • Message behaviour:
    • When online: all incoming messages (general chat or private) are immediately displayed by the client.
    • When away: all messages received while away are displayed immediately, and also counted. As the user returns to Online, they are told that they missed X number of messages.
    • When busy: messages received are not displayed, only once the user returns to online or goes to away.
  • The application should use the Mediator pattern to facilitate communication, and the State pattern to manage user states.
  • Write demo code to demonstrate all the features.

5. DocuGuard

Secure Document Management

Design Patterns Used: Command, Proxy

Assignment Description:

  • Design a document management system for a company.
  • The system should allow users to perform operations on documents (such as view, edit, and delete) while also implementing access control and logging.
  • Use the Command pattern to encapsulate document operations and the Proxy pattern to add a security layer and logging functionality.
  • Requirements:
    1. Implement commands for the following document operations:
      • View document.
      • Edit document.
      • Delete document.
    2. Create a command executor that can execute these commands.
    3. Implement a proxy for the document that:
      • Checks user permissions before allowing operations.
      • Logs all operations performed on documents.
    4. Ensure that the system is flexible enough to easily add new document operations in the future.

6. ApprovalChain

Document Approval Workflow

Design Patterns Used: Chain of Responsibility, Null Object

Assignment Description:

  • Create a document approval system for a company.
  • The company has different levels of employees (Junior, Senior, Manager, Director) who can approve documents based on their importance level.
  • Design the system using the Chain of Responsibility pattern and incorporate the Null Object pattern.
  • Requirements:
    1. Create four levels of approvers: Junior, Senior, Manager, and Director.
    2. Each document has an importance level from 1 to 5 (1 being least important, 5 being most important).
    3. Juniors can approve level 1 documents, Seniors can approve up to level 2, Managers up to level 3, and Directors can approve up to level 4.
    4. If a document can't be approved by any level, it should be handled gracefully without throwing an exception.
    5. Implement a method to process documents and show the approval chain in action.

7. PayFlex

Webshop Payment Integration

Design Patterns Used: Factory, Singleton

Assignment Description:

  • Webshop needs to integrate multiple third-party payment gateways (with different APIs) to process customer orders.
  • Main OrderService needs to process payments without knowing the specific details of which payment gateway is being used.
  • Make sure OrderService doesn't create its own dependencies (such as payment processors).
  • Payment processors should be instantiated by a factory, which should be a singleton.

🎯 Purpose

This repository demonstrates:

  • Practical application of core design patterns.
  • Clean separation of concerns.
  • Extensible and maintainable system design.
  • Readable and well-structured academic code suitable for professional portfolios.

📌 Author: Shihab Muhtasim

📚 Course: Design Patterns

🎓 Program: IPCVAI at PPCU, Budapest, Hungary

About

Pattern Craft – Design Patterns is a cohesive software design portfolio showcasing practical implementations of core object-oriented design patterns. Through seven real-world inspired modules, the project demonstrates clean architecture, extensibility, and scalable system design using GoF patterns.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages