Skip to content

HieuStudyingCS/Dependency-Injection---MessageService

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

C++ Dependency Injection Framework: Messaging Service

Overview

This project is a lightweight C++ application that demonstrates the Dependency Injection (DI) design pattern. It illustrates how to achieve Inversion of Control (IoC) to build a loosely coupled, highly cohesive messaging system that currently supports Email and SMS services.

By leveraging strict Object-Oriented Programming (OOP) principles and modern C++ memory management, this architecture ensures scalable, maintainable, and testable application development.

This is a personal project I built while studying the Dependency Injection design pattern.

Key Features

  • Dependency Injection: Services are injected into consumers via constructor injection, eliminating hard-coded dependencies.
  • Interface-Driven Design: Clear abstraction using IMessageService, IConsumer, and IMessageServiceInjector interfaces.
  • Safe Memory Management: Extensively utilizes modern C++ smart pointers (std::unique_ptr and std::move) to manage object lifecycles on the heap safely, preventing memory leaks.
  • Open/Closed Principle: The system is open for extension but closed for modification. New message types (e.g., Push Notifications) can be integrated without altering existing consumer logic.

Project Structure

messaging_project/
├── CMakeLists.txt
├── include/
│   ├── IMessageService.h
│   ├── IConsumer.h
│   ├── IMessageServiceInjector.h
│   ├── EmailService.h
│   ├── SMSService.h
│   ├── MyDIApplication.h
│   ├── EmailServiceInjector.h
│   └── SMSServiceInjector.h
└── src/
    ├── EmailService.cpp
    ├── SMSService.cpp
    ├── MyDIApplication.cpp
    ├── EmailServiceInjector.cpp
    ├── SMSServiceInjector.cpp
    └── main.cpp

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published