Git Product home page Git Product logo

sdp-decoratorpattern's Introduction

SDP-DecoratorPattern Orujova Elmira SE-2008

This codes shows how the Decorator pattern works on example of photo editing app. User might want to do just basic automatic editing (ex. lightning, contrast, brightness etc.) but also might want some advanced editing features to be used. This code shows what changes were made and counts them.

There is basic auto edit, but what if user wants several extra editings, it is convenient to use Decorator pattern, which dynamically adds new funtionality (editing). So behaviors are added to an individual object, without changing the class.

PhotoEditor editor2 = new BasicAutoEdit();
        editor2 = new Graininess(editor2);
        editor2 = new SkinSmooth(editor2);
        editor2 = new SlimFace(editor2);
        System.out.println("Your photo is ready!");
        System.out.println(editor2.editPhoto());
        System.out.println("Number of non basic changes is : " + editor2.NumOfChanges()+ "\nthanks for using our service");

In this piece of code, we are adding new editings at run time, starting from basic changes. It also counts how many changes user has done and outputs it. The output will look like:

Your photo is ready!
Basic corrections were made. Graininess is added. Smooth effect was added. All faces on photo were slimmed. 
Number of non basic changes is : 3
thanks for using our service

sdp-decoratorpattern's People

Contributors

saku-bara avatar

Watchers

 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.