Frameworks - aljasser.net

advertisement
SWE 316: Software Design and Architecture
Lecture 11 : Frameworks
Objectives

To understand


… the meaning of “frameworks”
To be able to


… build frameworks
… complete a detailed design
Adapted from Software Design: From
Programming to Architecture by Eric J.
Braude (Wiley 2003), with permission.
SWE 316: Software Design and Architecture – Dr. Khalid Aljasser
14.4
Review
Frameworks
Framework Usages
Requirements
Analysis
Framework Development
2/24
Process Phases Discussed in This Chapter
Design
Framework Architecture Detailed Design
Key: x = main emphasis x = secondary emphasis
SWE 316: Software Design and Architecture – Dr. Khalid Aljasser
Implementation
Review
Frameworks
Framework Usages
Framework Development
What is a software architecture?

An architecture for a software application is its high
level design, enabling software engineers to gain
understanding

An early stage of the system design process

It involves identifying major system components and
their communications

Represents the link between specification and
design processes
SWE 316: Software Design and Architecture – Dr. Khalid Aljasser
3/24
Review
Frameworks
Framework Usages
Framework Development
Framework




Framework --- a collection of classes
applicable to multiple applications
Business logic: the parts that are particular to an
application and are often not reused.
Reusability can be at the architecture level, design
level, and code level
Try to answer the following questions:



Where do we keep classes slated for reuse?
How do we organize them?
Should we build in relationships among these classes.
SWE 316: Software Design and Architecture – Dr. Khalid Aljasser
4/24
14.4
Review
Frameworks
Framework Usages
Framework Development
The meaning and usage of frameworks

A framework is a collection of software artifacts that
is usable by several different applications

Classes within a framework may be related and
applications may use them by means of inheritance,
aggregation or dependency.

E.g.


Java API’s (3D, 2D, Swing)
The Enterprise Java Bean (EJB)
SWE 316: Software Design and Architecture – Dr. Khalid Aljasser
5/24
Review
Frameworks
Framework Usages
Framework Development
Framework definitions

A framework is a set of cooperating classes that
comprise a reusable backbone for a specific
application domain.


A framework provides an integrated set of domain- specific
functionality
A framework is a semi-complete application

A framework is customized to a particular application by
deriving application specific classes from abstract classes
defined by the framework.
SWE 316: Software Design and Architecture – Dr. Khalid Aljasser
6/24
Review
Frameworks
Framework Usages
Framework Development
Why frameworks

Frameworks are the key to OO reuse

Frameworks reuse analysis and design, not just code.

Frameworks reuse overall architecture, not just
components.
SWE 316: Software Design and Architecture – Dr. Khalid Aljasser
7/24
Review
Frameworks
Framework Usages
Framework Development
Framework challenges


Developing high quality reusable extensible frameworks for
application domains involves complicated tasks.
It takes a substantial amount of time and effort to learn how
to utilize OO application frameworks.

Requirements of frameworks often change with changing
application requirements.

Frameworks need maintenance including both adaptation and
modification.
No current common standards exist for the design,
implementation, documentation, and adaptation of frameworks.

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser
8/24
Review
Frameworks
Framework Usages
Framework Development
Frameworks vs. components

Frameworks have lots of room for customization and they
have interfaces that are more complex than those of many
other components.

Frameworks and other software components are different
but cooperating technologies.


Frameworks are built from building blocks, which are their
component classes.
At the same time, frameworks themselves are application
building blocks and are used to build larger systems.
SWE 316: Software Design and Architecture – Dr. Khalid Aljasser
9/24
Review
Frameworks
Framework Usages
10/24
Framework Development
Class Model vs. Architecture and Detailed Design
Framework classes
DP
Architecture
DP
Design classes
DP
Detailed design
Class Model for
this application
DP = design pattern
SWE 316: Software Design and Architecture – Dr. Khalid Aljasser
DP
DP
Domain classes
DP
Review
Frameworks
Framework Usages
Framework Usages
1- Toolkit

11/24
Framework Development
14.4.2
“Bag of tools” with no architectural assumption, e.g. java.math



A collection of useful classes
Each usable in isolation
(Sometime not called a framework)
2- Abstract architecture

Common denominator of architecture, with architectural
assumption, e.g. java.awt and container class

An architecture in the abstract
3- Control

A system containing control, e.g. java.applet

Follow the protocols to obtain your application
SWE 316: Software Design and Architecture – Dr. Khalid Aljasser
Review
Frameworks
Framework Usages
Selected Framework Goals
Persistence Service


12/24
Framework Development
14.4.3
Store instances between executions
Identity Service


Identify objects sufficiently to retrieve them across
executions
Pooling

- of objects: Reusing objects
at runtime to save time and
space
Goal : Reuse

- of threads
We Use Frameworks …to

- of database connections
reuse classes, relationships

Security
among classes, or preprogrammed control.

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser
Review
Frameworks
Framework Usages
Framework Development
Framework design Issues

Keep it simple

Be consistent

Don’t make things almost the same

Design to prevent user errors (i.e. naming conventions)

Have default behavior

Have documentation especially for interactions
SWE 316: Software Design and Architecture – Dr. Khalid Aljasser
13/24
Review
Frameworks
Framework Usages
14/24
Framework Development
Framework development




14.4.4
Framework Design
Framework Implementation
Framework Testing
Documentation
Architectural
Design
Framework
Design
Framework
Implementation
SWE 316: Software Design and Architecture – Dr. Khalid Aljasser
Framework
Testing
Documentation
Review
Frameworks
Framework Usages
Framework Development
Principles of framework design

First rule:



Designing reusable code requires iteration

Reusable code requires many iterations.

Basic law of software engineering: “if it hasn't been tested, it doesn't
work”, thus software that hasn't been reused is not reusable.
Frameworks encode domain knowledge




Don't design, buy one, instead.
Frameworks solve a particular set of problems.
Not always application-domain specific
Customer of framework is application programmer
Frameworks are abstractions: people generalize from concrete
examples
SWE 316: Software Design and Architecture – Dr. Khalid Aljasser
15/24
Review
Frameworks
Framework Usages
Framework Development
Seeking Generalization: Bottom-up
1. Start with classes in class model
2. Look for generalizations
Problem
Procedure
WinProblem
WinProcedure
SWE 316: Software Design and Architecture – Dr. Khalid Aljasser
16/24
14.4.4.1
Review
Frameworks
Framework Usages
17/24
Framework Development
Ideal way to develop framework


Analyze problem domain

Learn well-known abstractions.

Collect examples of programs to be built from
framework. (Minimum of 4 or 5).
Design abstraction that covers examples.


Analysis
Design
look for commonalities, represent each idea once.
Test framework by using it to solve the examples.

Each example is a separate application.

Performing a test means writing software.
SWE 316: Software Design and Architecture – Dr. Khalid Aljasser
Test
Review
Frameworks
Framework Usages
18/24
Framework Development
Seeking Generalization: Top-down
1. Start with libraries (e.g., MFC)
2. Look for opportunities to use
List
ListIterator
library
ScheduledEvents
SWE 316: Software Design and Architecture – Dr. Khalid Aljasser
Review
Frameworks
Framework Usages
Framework Development
Why ideal is never followed

Analyzing domain requires analyzing individual examples,
which is very hard.



Only practical if examples have already been analyzed.
Analyzing and implementing examples is large fraction of the
cost of the project.
Old applications work, so there is no incentive to convert
them to use framework.
SWE 316: Software Design and Architecture – Dr. Khalid Aljasser
19/24
Review
Frameworks
Framework Usages
Framework Development
Good way to develop framework

Pick two similar applications.

Include developers experienced in the same domain.

One framework group


Consider other applications

Explain and teach framework
Two application groups

Try to reuse as much software as possible

Complain about how hard software is to use
SWE 316: Software Design and Architecture – Dr. Khalid Aljasser
20/24
Review
Frameworks
Framework Usages
Framework Development
Typical way to develop framework

Notice that many applications are similar.

Develop next application in that domain in an OO language.

Divide software into reusable and non-reusable parts.

Develop next application reusing as much software as
possible.
Framework is not very reusable
Fix it
Develop next application reusing as much software as possible
SWE 316: Software Design and Architecture – Dr. Khalid Aljasser
21/24
Review
Frameworks
Framework Usages
Framework Development
Another strategy

Design framework - prototype several small applications

Build real application

Refactor and extend framework
SWE 316: Software Design and Architecture – Dr. Khalid Aljasser
22/24
Review
Frameworks
Framework Usages
Framework Development
Summary of process

Start with examples of desired applications

Iteratively develop abstractions

Test by building applications
SWE 316: Software Design and Architecture – Dr. Khalid Aljasser
23/24
Review
Frameworks
Framework Usages
Framework Development
Summary

A framework is a collection of software artifacts that
is usable by several different applications

Frameworks reuse overall architecture, not just
components.

Framework development

Several strategies e.g., Top-Down, Bottom-Up
SWE 316: Software Design and Architecture – Dr. Khalid Aljasser
24/24
Download