Giter Site home page Giter Site logo

thegeekyasian / strategy-pattern-in-spring-boot Goto Github PK

View Code? Open in Web Editor NEW
9.0 3.0 1.0 15 KB

A very simple implementation of Strategy Design Pattern and Factory Design Pattern to a Spring Boot project.

License: MIT License

Java 100.00%
java springboot design-patterns factory-design-pattern factory-pattern java-design-patterns spring-boot strategy-design-pattern strategy-pattern

strategy-pattern-in-spring-boot's Introduction

Strategy Design Pattern in Spring Boot

Discord Twitter

Discover the simplest and most effective way to implement strategy patterns in Spring Boot with the provided implementation.

This project provides clear and concise examples of these powerful design patterns in action, along with detailed explanations that make it easy to understand and apply them to your own Spring Boot projects.

The project primarily uses Spring Boot dependency injection with autowiring to resolve the created strategies, which enabled you to comply with O of SOLID design principles, i.e. Open-Closed Principle.

Which means, to add a new strategy, all you have to do is just have to provide a new implementation of your strategy interface and that's it. Spring will automatically resolve the dependencies and will map it to the provided type.

How to run

The application uses Spring Boot and starts on post 9000 by default. You can simply build and run the project similar to how to run any other spring boot applications.

The application will execute the test() method in the NotificationExecutor, which calls NotificationFactory for each of three supported notification types. It will produce the below output:

Sending email
Sending push notification
Sending SMS

How was it done?

To understand further, you can go through a step-by-step guide that I have created on how it was implemented.

The guide is available HERE.

Help

For any questions, assistance or to report any issues, please feel free to join the discord community.

strategy-pattern-in-spring-boot's People

Contributors

thegeekyasian avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

poojarajput-aq

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.