Class Design
Class Design
1. Bridging the gap – sometimes there are disconnection or gap between the desired features and the
available resources and the best possible way is to bridge that disconnection. In that case intermediate
elements can be invented to bridge that gap.
2. Realizing Use Cases – in the design phase an operations and objects that has the behavior to realize
use cases with operations must be invented.
3. Designing Algorithms - Formulate an algorithm for each operation. The analysis specification tells
what the operation does for its clients. The algorithm show how it is done.
o Computational complexity
o Flexibility
o Complex efficient
ii. Select data structures appropriate to the algorithms
b. The expansion of algorithms may lead you to create new classes of objects to
hold intermediate results.
ATM Example:
i. Receiver of action
ii. To associate the operation with the target of operation, rather than
the initiator.
c. Focal class
By functionality
By mechanism
5. Refactoring - Changes to the internal structure of software to improve its design without altering its
external functionality.
6. Design Optimization - To design a system is to first get the logic correct and then optimize it. Often a
small part of the code is responsible for most of the time or space costs.
Tasks to optimization:
7. Reification of Behavior - Behavior written in code is rigid; you can execute but cannot manipulate it at
run time. If you need to store, pass, or modify the behavior at run time, you should reify it
9. Organizing a Class Design - We can improve the organization of a class design with the following steps:
– Information hiding
– Coherence of Entities
– Fine-tuning packages
DESIGN PATTERNS
Patterns:
Patterns help you build on the collective experience of skilled software engineers.
Each pattern is a three-part rule, which expresses a relation between a certain context, a problem,
and a solution
A pattern addresses a recurring design problem that arises in specific design situations, and presents a
solution to it.
Patterns identify & and specify abstractions that are above the level of single classes and instances, or
of components.
Architectural patterns - Architectural patterns are used to describe viable software architectures that
are built according to some overall structuring principle.
Design patterns - Design patterns are used to describe subsystems of a software architecture as well
as the relationships between them (which usually consists of several smaller architectural units)
Systems must often handle collections of objects of similar kinds, of service, or even complex
components.
E.g.1 Incoming events from users or other systems, which must be interpreted and scheduled
approximately.
e.g.2 When interactive systems must present application-specific data in a variety of different way, such
views must be handled approximately, both individually and collectively.
In well-structured s/w systems, separate manager components are used to handle such
homogeneous collections of objects.
Command Processor
The command processor design pattern separates the request for a service from its execution.
A command processor component manages requests as separate objects, schedules their execution, and
provides additional services such as the storing of request objects for later undo.
Context:
Applications that need flexible and extensible user interfaces or Applications that provides
services related to the execution of user functions, such as scheduling or undo.
Problem:
Need a solution that is well-structured for mapping its interface to its internal functionality
Need to implement pop-up menus, keyboard shortcuts, or external control of application via a
scripting language
Additional services such as undo should be implemented consistently for all requests.
Solution:
Whenever user calls a specific function of the application, the request is turned into a
command object.
The central component of our pattern description, the command processor component takes
care of all command objects.
It schedules the execution of commands, may store them for later undo and may provide
other additional services such as logging the sequences of commands for testing purposes.
Structure:
Components