0% found this document useful (0 votes)
5 views

CS457--Assignment1-Task2.pdf

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

CS457--Assignment1-Task2.pdf

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Table of Contents

Motivation 02
Task-1 03-04
JHotDraw Architecture Style 04
Task-2 05-09
Design Patterns
1. Mediator Pattern 05
2. Composite Pattern 06
3. Observer Pattern 07
4. Template Method Pattern 08
5. Strategy Pattern 09

1
Motivation
Software development is largely based on standards, conventions, underlying
systems and architectures, most notably object-oriented frameworks. The
frameworks are reusable designs of all or part of a software system described by a
set of abstract classes and the way instances of those classes collaborate.
The JHotDraw framework follows the MVC guidelines. The functionality that a
JHotDraw-based diagram editor provides results from the interaction of: (a)
Swing-based classes (related to the View management concern), (b) a very thin
controller, and (c) the Model classes which are application dependent and are
written entirely by the framework programmer.

2
Task 1
Software architecture refers to the high-level abstraction of a system including the
configuration of the involved elements and the interactions and relationships that
exist between them. It is the most interpretable, significant, and irreplaceable part
of the entire system design process. Software is built upon a certain architectural
style. In most cases, the post-development phase consisting of maintenance,
support, and evolution leads to changes in the system. The architectural
documentation of the software may not be maintained with the same consistency
and might not be up-to-date. Moreover, frequent changes in the involved classes
and packages with the motivation of improvement in results would lead to
deviation in the original underlying architecture. Source codes can be easily built
by referring to the software architectures. However, the reverse process i.e.
derivation of the software architecture from the source code is a challenging task.
The most common type of software architecture format used in the development
process is the layered architecture style. The layered architecture breaks down the
system into different layers of abstraction and assigns every element to each of
these layers based on their role and responsibility. Layered software architecture
has lesser design constraints, is simplistic, and easy to construct. The layers are
present in hierarchical order with specific rules governing the interactions
between them. Lower layers are supposed to provide the required information to
the top layers, while the top layers can only interact with the very next lower
layers. Our work focuses on the recovery and validation of JHotDraw a Java-based
software system that is closed layer in style.

3
4
Design Patterns:
1. Mediator
It is a behavioral design pattern that lets you reduce chaotic dependencies
between objects. The pattern restricts direct communications between the
objects and forces them to collaborate only via a mediator object.

In our case, the mediator is the DrawingEditor class. It helps us eliminate


mutual dependencies between the tool and the DrawingView. The
DrawingView doesn’t need to communicate with the tool, if it needs to
draw using the tool it will use the ‘getTool’ method in the DrawingEditor
(Mediator).

Exact Locations:
○ org.jhotdraw.draw.DrawingEditor.java
○ org.jhotdraw.draw.DrawingView.java
○ org.jhotdraw.draw.Tool.java

5
2. Composite
It is a structural design pattern that lets you compose objects into tree
structures and then work with these structures as if they were individual
objects.

In our case, the CompositeFigure acts as a container that delegates the


work to the Figure components in its ArrayList, to be able to draw different
figures using the ‘drawFigure’ method.

Exact Locations:
○ org.jhotdraw.draw.CompositeFigure.java
○ org.jhotdraw.draw.Figure.java

6
3. Observer
It is a behavioral design pattern that lets you define a subscription
mechanism to notify multiple objects about any events that happen to the
object they’re observing.

In our case, the publisher is the DrawingView and the subscriber is the
FigureSelectionListener. Whenever the DrawingView calls the
‘fireSelectionChanged’ method, the subscribers are notified via the
‘selectionChanged’ method.

Exact Locations:
○ org.jhotdraw.draw.FigureSelectionListener.java
○ org.jhotdraw.draw.DrawingView.java

7
4. Template Method
It is a behavioral design pattern that defines the skeleton of an algorithm in
the superclass but lets subclasses override specific steps of the algorithm
without changing its structure.

In our case, the AttributedFigure acts as the template that keeps track of a
set of attributes of a figure. It provides a template method called
‘drawFigure’ that calls methods such as ‘drawFill’ and ‘drawStroke’ which
are overridden in the EllipseFigure, RectangleFigure, and TriangleFigure
classes.

Exact Locations:
○ org.jhotdraw.draw.AttributedFigure.java
○ org.jhotdraw.draw.EllipseFigure.java
○ org.jhotdraw.draw.RectangleFigure.java
○ org.jhotdraw.draw.TriangleFigure.java

8
5. Strategy
It is a behavioral design pattern that lets you define a family of algorithms,
put each of them into a separate class, and make their objects
interchangeable.

In our case, the LineConnectionFigure class maintains a reference to one of


the Liner objects which we can consider the interface for the different
strategies we have. The LineConnfectionFigure executes the ‘lineout’
method on one of the linked liner objects without needing to know which
type of liner it is.

Exact Locations:
○ org.jhotdraw.draw.ConnectionFigure.java
○ org.jhotdraw.draw.LineConnectionFigure.java
○ org.jhotdraw.draw.Liner.java
○ org.jhotdraw.draw.ElbowLiner.java
○ org.jhotdraw.draw.SlantedLiner.java

You might also like