Saturday, October 24, 2020

3.7 Identify Software Architecture and Design Patterns on a Diagram

 

Identify Software Architecture and Design Patterns on a Diagram

A new application for publishing short stories is in the making. You received an idea for the components that are necessary and the connection between them in the form of a class diagram. To understand how the application works, you need to first understand the diagram to reason about its functionalities and restrictions.

You may navigate away from this page once you begin initializing the lab.

You will be notified once the devices are ready.

Identify Software Architecture and Design Patterns on a Diagram

As you can see in the Topology figure, modular applications enable easier maintenance. To achieve a level of modularity which helps you to reason about the meaning and functionality of the codebase, you should use already proven software architectures and design patterns. Before writing the code, you should design it with the help of class diagrams, where you can sketch the implementation of the design patterns, and by doing that, document the solution. The class diagrams should give you an overview of how the application is composed together without having to inspect the code.

Step 1

Identify the missing design pattern usage in this diagram. The missing class model is outlined in red. Drag the most appropriate class model listed below the diagram (outlined in yellow) to the empty model in the diagram.

Task:

Answer

Solution:

Out of the proposed class models, the first one is the most appropriate because it is an abstraction observer class that proposes a public update() method.

Step 2

When using the observer pattern, the related publisher and observers must implement some methods that are currently missing in the diagram. The following diagram outlines the models that are missing the observer methods and an argument. Inside each of the models that have a placeholder for method or argument, type the name of the method or variable, together with the visibility value. The possible values are + update()- notify(), and - observers: [].

Task:

Answer

Solution:

The update() method must be implemented on both view components. StoryModel will rely on the observer contract that this method exists on the object that subscribes to them. In return, the model has to implement the private notify() method, which is used on a state change, to notify all observers that are stored in the private observers list.

No comments:

Post a Comment