Git Product home page Git Product logo

designpattern.bridge's Introduction

DesignPattern.Bridge

Repository name describes what we are going to do. Here I took the problems of publisher. What he/she do? He publish paper on various topic that could be book, could be question paper or anything else. Here I have used 5 branches you need to go though branch to get understand what is happening.

First of all checkout https://simpleprogrammer.com/design-patterns-simplified-the-bridge-pattern/ to get basic understanding over bridge design pattern and the follow those steps to dig inside the repository.

Step 1: Lets start with initial problem branch. Here I have fixed the basic problems of that publisher. Here we done the job without using any abstraction. And checkout the todo. #P1, Need to execute all the printing task in a loop. To fix this problem we need to go with abstraction.

Step 2: Jump to IntroduceInterface-PrintInForLoop here we go with abstraction to solve #P1 and do the printing operation inside a loop. So we reduce code duplication. And now another problem rises. Publisher need to use text formatting for some his customer.

Step 3: Remember, we need to add different type of formatting for different customer and we doen the job inside AddStringFormattingMachanismUglySolution. Branch name described it's a ugly solution. Why? please go inside the models I hope you could realize. Here we have added various classes for various text formatting and what happened when that publisher print 100 types of item and customer looking for 5 types of text formating option? Can you imagine? We need to define minimum 500 classes. And our next goal is #P3, fix ugly class explosion.

Step 4: Jump to UseBridgeDesignPattern. I have introduce IFormatter interface and implemented on several classes to generate its own formatting. Those classes will do the remaining job of formatting and publisher need to add specific formatter for their specific print. And if he did not pass any, it will use default one.

Thanks for checking it out, and like to get star if it make scense to you. Happy coding :)

designpattern.bridge's People

Contributors

abuzaforfagun avatar

Stargazers

Md Farid Hossain avatar

Watchers

James Cloos avatar

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.