Breaking News: Grepper is joining You.com. Read the official announcement!
Check it out

How Strategy design pattern is different from State design pattern in Java?

Pragya Keshap answered on February 10, 2023 Popularity 3/10 Helpfulness 1/10

Contents


More Related Answers

  • What design pattern allows behavior to be added to an individual object
  • What are the design-patterns used in Spring framework?
  • java decorator pattern
  • java strategy pattern
  • What are design patterns in software engineering and why are they important?
  • what is design pattern
  • pattern in java
  • Pattern Programs in Java.
  • strategy design pattern
  • Java design patterns
  • How are design principles different from design patterns?
  • What are design patterns?
  • What are design patterns?
  • Why Design Patterns?
  • java oop design patterns
  • Java design patterns
  • Java design patterns
  • Java design patterns
  • Java design patterns
  • What are the design patterns involved in JDBC architecture?
  • Template Design Pattern In java
  • When to use the Strategy Design Pattern in Java?
  • What is the difference between Strategy and State design Patterns in Java?
  • When to use the Composite design pattern in Java? Have you used it previously in your project?
  • what is difference between state design pattern and strategy design pattern
  • strategy design pattern
  • What are the advantages of Java Design Patterns?
  • How can you describe a design pattern?
  • What are the types of design patterns in Java?
  • What are some of the design patterns used in Java’s JDK library?

  • How Strategy design pattern is different from State design pattern in Java?

    0

    State design pattern is a behavioral design pattern that is use for

    defining the state machine for an object. Each state of an object is

    defined in a child class of State class. When different actions are

    taken on an Object, it can change its state.

    Strategy pattern is also a behavioral pattern, but it is mainly used

    for defining multiple algorithms. With same action of a client, the

    algorithm to be used can change.

    Some people consider State pattern similar to Strategy pattern,

    since an Object changes its Strategy with different method

    invocations. But the main difference is that in State pattern internal

    state of an Object is one of the determining factors for selecting the

    Strategy for change of state.

    Where as in Strategy pattern, client can pass some external

    parameter in input during method invocation that determines the

    strategy to be used at run time.

    Therefore State pattern is based on the Object’s internal state,

    where as Strategy pattern is based on Client’s invocation.

    State pattern is very useful in increasing the maintainability of the

    code in a large code-base.

    https://medium.com/javarevisited/micro-biology-of-state-and-strategy-design-pattern-2add63460ab7

    Popularity 3/10 Helpfulness 1/10 Language java
    Source: Grepper
    Tags: java state
    Link to this answer
    Share Copy Link
    Contributed on Feb 10 2023
    Pragya Keshap
    0 Answers  Avg Quality 2/10


    X

    Continue with Google

    By continuing, I agree that I have read and agree to Greppers's Terms of Service and Privacy Policy.
    X
    Grepper Account Login Required

    Oops, You will need to install Grepper and log-in to perform this action.