Open in app
Home
Notifications
Lists
Stories

Write
Chaanakya
Chaanakya

21 Followers

Home

Published in Javarevisited

·12 hours ago

Avoid subclassing using Decorator pattern

How to avoid subclassing using the decorator pattern explained using a text formatting example — Decorator pattern allows behaviour to be added to an individual object dynamically, without affecting the behaviour of other objects from the same class. Decorator pattern is often used as an alternative to subclassing. Subclassing adds behaviour at compile time where as in decorating, behaviour can be added at run-time.

Decorator Pattern

6 min read

Avoid subclassing using Decorator pattern
Avoid subclassing using Decorator pattern
Decorator Pattern

6 min read


Nov 19

Strategy Pattern in Java

What is Strategy pattern? It encapsulates a family of algorithms and makes them interchangeable at run time. Examples: Sorting report data (Sort by name, Sort by date…), payment strategies (Debit card, credit card, UPI,…) When to use: To Change behaviour at runtime. eg: different payment strategies based on user input…

Strategy Pattern

4 min read

Strategy Pattern in Java
Strategy Pattern in Java
Strategy Pattern

4 min read

Chaanakya

Chaanakya

21 Followers

Software Engineer

Following
  • Fred Grott

    Fred Grott

  • Kasper Müller

    Kasper Müller

  • The Educative Team

    The Educative Team

  • Tim Denning

    Tim Denning

  • Josef Cruz

    Josef Cruz

Help

Status

Writers

Blog

Careers

Privacy

Terms

About

Text to speech