week-3

Hello,

I am doing some class activities and looking over some questions ahead to save time for a thing or two. I came across the word "Behavioral Patterns" in class Act. 4 (Model 8); I got curious and looked it up. I found two articles that helped me understand the purposes, Problems with solutions, Real-World Analogy, Structure, Pseudo-code, Applicability, How to Implement, Pros and Cons, Relations with Other Patterns.


The Behavioral Patterns are concerned with providing solutions. It is about object interaction - how they communicate, how some are dependent on others, how to separate them to be both dependent and independent, and give both flexibility and testing capabilities—also, the assignment of responsibilities between objects.


The Behavioral Patterns cover many small parts to form the full extend of patterns. Like Interpreter, Template Method/Pattern, Chain of Responsibility, Command, Iterator, Mediator, Memento, Observer, State, Strategy, and Visitor.

Interpreter


The Interpreter pattern: Evaluate any language grammar or expressions. An excellent example; this pattern would be Google Translate, which deciphers the input, and shows us the output in another language. Another example would be the Java compiler. The compiler interprets Java code and translates it into byte-code that the JVM uses to perform operations on the device it runs on. Also, it represents a great way to write simple programs that understand human-like syntax. 


Chain of Responsibility - pass requests along a chain of handlers. Upon receiving a request, each handler processes the requestor gives it to the next handler in the chain. 

Command - Turns a request into a stand-alone object that contains all information about the proposal. This transformation lets pass requests as a method arguments, delay or queue a request's execution, and support undo-able operations. 

Iterator - traverse elements of a collection without exposing its underlying representation (list, stack, tree, etc.)

Mediator - it reduces chaotic dependencies between objects. The pattern restricts direct communications between the entities and forces them to collaborate only via a mediator object.

Memento - it saves and restores the previous state of an object without revealing the details of its implementation.

Observer - define a subscription mechanism to notify multiple objects about any events to the observed entity.

State - lets an object alter its behavior when its internal state changes. It appears as if the thing changed its class.

Strategy - define a family of algorithms, put them into a separate class, and make their objects interchangeable.

Template Method - the outline of an algorithm in the super-class but lets sub-classes revoke exact steps of the algorithm without modifying its structure.

Visitor - It separates algorithms from the objects on which they operate.

 

Comments



  1. This information supports me to learn and understand the topic for the CS course. The material can students expect to apply what was learned in their future practice by small subject containing many types of information.

    URL links-
    https://stackabuse.com/behavioral-design-patterns-in-java/
    (The first link has meanings with picture codes examples.)

    https://refactoring.guru/design-patterns/behavioral-patterns
    (The second link has purposes, Problems with solutions, Real-World Analogy, Structure, Pseudo-code, Applicability, How to Implement, Pros and Cons, Relations with Other Patterns. But it has every word except Interpreter.)

    ReplyDelete

Post a Comment

Popular posts from this blog

weekly blog (week one)

week-6

Sprint-1