sw adt object models
DESCRIPTION
JAVATRANSCRIPT
1
CSCI 528 Data Structures- Introduction to SW Design Processes, ADT, and Object Models -
Dr. Kwang Lee
School of Information
Technology
Quiz #1:
Assignment #1:
Announcement!
Copyright © Prof. K. Lee All rights reserved.
2
Introduction to SW Development Processes
Lecture 1
Lecture Overview
Introduce software development approaches
SW analysis and design methods
– Study top-down and objected-oriented approaches
Introduce design aspects
– Select or build data types
– Develop algorithms for operations on data
– Investigate error types
– Discuss testing methods
Note time and effort devoted to maintenance
4
3
1. SW Development
Usually, three basic approaches to be needed for
development SW
– Identify and Analysis
Confirm needs, solve a problems, and analysis stuff with
programming
– Design
Produce solutions without detail implementation
– Implement
Involve coding algorithm and data structures with programming
languages
5
1. SW Development
Waterfall Model
Adding test and maintenance steps
5 phases of SW life cycle
6
4
1. SW Development
Realistic Waterfall Model7
1. SW Development
(1) Identify and Analysis Steps
(2) SW Design Steps
(3) SW Implementation Procedures
(4) Testing, Executing, and Debugging
(5) Maintenance
8
5
Identify and analyze systems requirements;
– The most important task in creating a software product
is extracting the requirements or requirements
analysis
– Customers typically have an abstract idea of what
they want as an end result, but not what software
should do
Incomplete, ambiguous, or even contradictory requirements
are recognized
– Frequently demonstrating live code may help reduce
the risk that the requirements are incorrect
Using Visual Basic or Script languages
1.1 Identify Steps
9
Make a SW specification (spec)
– Specification is the task of precisely describing the
software to be written, possibly in a rigorous way
Spec will include following things;
– Purpose
– Available resources
– Pre-condition
– Post-condition
– etc
1.1 Identify Steps
10
6
CS courses
– Small systems
• Few hundred lines of
code
• Simple, straightforward
“Real” world
– Large systems
• Thousands of lines of
code
• Complex
• Many components
• Problem initially poorly
defined
1.1 Identify Steps
Real world contracts or specifications
- Must be precise
- May be required to prove end product meets these precise
specifications
11
SW design procedures
– After the purpose and specifications of software are
determined, software developers will design or employ
designers to develop a plan for a solution
– Need a process of problem-solving and planning for
a software solution
Including low-level components and algorithms
implementation issues as well as the architectural view
Determining data types, operations, and algorithms
Selecting design methods
– Structured design (top-down approach)
– Object-oriented design
1.2 SW Design Steps
12
7
Using top-down procedures;
– Identifying major actions
– Analyzing their control flows
– Expressing solution in terms of control structures
and functions
(1) Structured Design Method
13
Original problem partitioned into simple sub-
problems by actions and functions
Each of these sub-problems likewise subdivided
14
(1) Structured Design Method
8
Data1
Data2 Nouns
Data3
Operation1 (funtion1) {
----------
----------
} Verbs
Operation2 (funtion2) {
----------
----------
}
Example: Structured Programming
15
Using object-oriented analysis
– Identifying major objects
– Analyzing their operations
– Expressing solution in terms of these objects and
operations
(2) Object Oriented Design Method
16
9
(2) Object Oriented Design Method
Identify the objects in the problem's specification
and their types
Identify the operations or tasks to manipulate the
objects
17
Record
Student
Class 1 {
Data
Methods
}
Class 2 {
Data
Methods
}
Class n {
Data
Methods
}
Example: Object-Oriented Programming
18
10
Programs = “Data Structures” + “Algorithms”
Determining data types, structures, and algorithms
– What type of data is needed!
– What type of structures are needed!
– What type of algorithms can be performed!
Construct “data structure”
– Simple data type
int, float, long, double
– Build structured
arrays
structures
class objects
Think of them as
Containers
(3) Determine Data and Operation Types
19
Select a best algorithm, or construct/design an
algorithm considering following points;
– Simple
– Definite and unambiguous
– Finite
– Correct and efficient
– Well structured
Before starting final coding for the algorithm, many
cases use pseudocode
(3) Determine Data and Operation Types
20
11
A sequence of statement that are close programming
languages, but more English like, and without the syntax
requirements of the formal computer language
Pascal can be usually used for Pseudocode well
e.g. Regular Code:
if ( is_valid($cc_number) )
{ execute_transaction ($cc_number, $order); }
else
{ show_failure (); }
Pseudocode:
if credit card number is valid
execute transaction based on number and order
else
show a generic failure message
Example: Pseudocode
21
Implementation is the realization of an
application, or execution of a plan, idea, design,
specification, algorithm, or others
Encode the design (coding procedure). Select
languages, C, C++, Java, C#, etc to implement
– Insure quality
Program and sub-programs will be well-structured, and
documented
All source code must be correct, understandable, and
formatted for readability
– Verify integration
Combining program units into a complete software system
1.3 SW Implementation Procedures
22
12
Testing in real environments if possible
Finding and reducing the number of bugs,
defects, or errors in a computer program or a
piece of electronic hardware thus making it
behave as expected
(1) Validation test
(2) Verification test
1.4 Testing, Executing, and Debugging
23
Validation test:
"Are we building the right product?" Check that documents, program modules and others are
matched with the customer's requirements
Verification test:
"Are we building the product right?" Check that products are correct,
Complete,
Consistent with each other and with those of the preceding
phases
1.4 Testing, Executing, and Debugging
24
13
Completing three type of tests required
– Unit tests
Each individual program unit works?
Program components tested in isolation
– Integration tests
Units combined correctly?
Component interface and information flow tested
– System tests
Overall system works correctly?
System programs, sub-programs, and libraries
(1) Kinds of Tests
25
Syntax errors
– Errors in the grammar of the programming language
Link errors
– Errors in the link programs to make an executable
Run-time errors
– Errors happen during the duration of its execution
from beginning to termination
Logic errors
– Errors produces unintended or undesired output or
other behavior
(2) Types of Errors
Difficulty
26
14
Enhancing software to cope with newly discovered
problems or new requirements
– It can take far more time than the initial development of the
software
Necessary modifications because …
– To add new SW or HW features
– Poor performance, poor structure, poor documentation, poor
style, and so on
Bug finding and fixing is tougher
Impedes implementation of enhancements
Large % of
– Computer center budgets and programmer's time
– Software development cost
1.5 Maintenance
27
Appendix: “V” Life Cycle Model
The "V" Life Cycle Model Test by Dorothy
Graham
28
15
Fusion Method by Hewlett-Packard
Requirement Doc
Object Models Interface Models
Object Interaction Graphs
Visibility Graphs
Class Descriptions
Inheritance Graphs
Programs
Analysis Part
Design Part
Implementation Part
Appendix: Fusion Method
29
Summary
Discussed Software Development Processes
– Identify and analysis steps
Identify and analyze systems requirements
– SW design steps
Choose top-down and objected-oriented approaches
Select or build data types
Develop algorithms for operations on data
– Implement SW code procedures
Select languages, C, C++, Java, C#, etc to implement SW
– Discuss testing methods
Investigate error types
– Set maintenance
30
16
Introduction to ADT and Object Models
Lecture 1
Introduce and define ADTs
– Process abstraction
– Data abstraction
– What is ADT?
Why OOP need?
– Object-oriented concept
– Object-oriented programming (OOP) features
Elements of Object Models
– The meaning of abstraction
– The meaning of encapsulation
– The meaning of modularity
– The meaning of hierarchy
Lecture Overview
32
17
1. What is Abstraction?
Abstraction arise from a recognition of
similarities between certain objects, situations, or
processes in the real world
Abstraction is one of the fundamental ways
that we as human cope with complexity
33
Example: Abstraction
Visual Icons
34
18
1. What is Abstraction?
In the programming, abstraction is a
“representation” of an entity that includes only
the most significant attributes
Using abstraction concept in a programming is
important to reduce program complexity and
difficulty
35
Example: Abstraction
How to make „6‟ using data 1 and + operation?
– 1 +1 + 1 + 1 + 1 + 1 = 6
How to make ‟21‟?
– 1 +1 + 1 + ,……., + 1 = 21
How to make „10 million‟?
Using 1 + 1 = 2, 1 + 1 + 1 =3, then abstracted
data „2‟ and „3‟
– 2 + 3 + ,…, + 2 = 21
Create another abstracted operation (×),
multiplication
– (3 × 2 × 3) + 3 = 2136
19
1. What is Abstraction?
Knowing the concept of abstraction is a
fundamental way to learn programming and
computer science
Generally all programming languages support
“process abstraction” using subprograms
Nearly many programming languages designed
since 1980 support “data abstraction”
37
(1) Process Abstraction
All programming languages support process
abstraction using subprograms
– They provide a way for a program to specify that some
process is to be done, without providing detail of how it
is to be done
main()
{
int avg, find;
sortdata(~~);
avg=average(~~);
find = search(~~);
~ ~
return 0;
}
void sortdata(~~)
{ }
int average(~~)
{ }
int search(~~)
{ }
38
20
Since 1980, nearly all programming languages
designed support data abstraction, called
abstract data type (ADT)
– Smalltalk, Object Pascal, C++, Java, C#, and others
Abstract data type (ADT) is user-defined
abstraction type. It enclosure that includes;
– Data representation of one specific data type
– Subprograms that provide the operations for that type
39
(2) Data Abstraction
Example: Data Abstraction
Suppose an abstract data type is to be constructed for a
stack that has the following abstract operations:
– Create(stack) :creates a stack object
– Destroy(stack) :deallocates the storages for the stack
– Empty(stack) :predicate function for checking the stack
– Push(stack, element) :pushes the specified element
– Pop(stack) :removes the top element from the stack
– Top(stack) :returns a copy of the top element
A client of the stack type could have a code sequence such
as the following:
create(stk1);
push(stk1, color1);
if (!empty(stk1)) temp = top(stk1);
…. 40
21
Abstract data type (ADT) is a user-defined data
type that satisfies the following two conditions:
1. The declaration of the type and the operations on objects
of the type are contained in a single syntactic unit
e.g. Unit = {type + operations (protocol)}
2. The representation of objects of the type is hidden from the
program units that use the type, so the only direct
operations possible on those objects are those provided in
the type's definition
e.g. Manipulate objects
unit 1 unit 2
41
2. What is ADT?
2.1 ADT Implementations
ADT is a basic unit in programming languages
- Unit = { Storage structures for the data items +
Algorithms for the operations
- Called an Abstract Data Type (ADT) ≈ Objects
For a programming task, we must identify
(1) The collection of data items
(2) Basic operations to be performed on them
Taken together (data items and operations)42
Unit Data
Operations
22
In the point of Java or C++, ADT is an object to
make one unit procedure;
unit procedure = { data + functions} = class
e.g.
class abc
{ data;
functions;
}
=> abc is an object
=> abc a, b; then a, b are objects (instances)
2.2 ADT Implementations in C++, Java
43
44
2.3 Advantages of Data Abstraction
Modularity -- everything associated with a data
structure is together so that program have a
strong organization and modifiability
Reliability -- by hiding the data representations
(encapsulation), user code cannot directly access
objects of the type or depend on the
representation, allowing the representation to be
changed without affecting user code
23
3. Why OOP need?
Software crisis in 1980
– Conflicting requirements have always hindered the
software development process
– The roots of the software crisis are complexity,
expectations, and change
- It refers to the difficulty of writing correct, understandable, and
verifiable computer programs
Trying to find easier maintenance and reusable
SW method
Widespread abstraction method in software
engineering fields
45
3. Why OOP need?
ADT concept can make data and basic
operations to be merged into one single entity,
called “object”
– ADT is the fundamental way to support object model
for finding an object, and developing ADT
Object modelling programming skill provide lots
of advantages for SW engineering processes,
such as easier maintenance and reusable SW
components with an obvious mapping from real
world entities to system
46
24
3. Why OOP need?
Therefore, programmers need a language (OOP)
which can handle the above requests technically
with supporting manageable coding mechanisms
47
3.1 Object-Oriented Concept Development
Object-oriented analysis (OOA):
– concerned with developing an object model of the
application domain by discovering the classes and
objects
Object-oriented design (OOD):
– concerned with developing an object-oriented system
model to implement requirements with inventing the
abstractions and mechanisms
Object-oriented programming (OOP):
– concerned with realising/implementing an OOD using
an OO programming language such as C++ or Java
48
25
Example: Object-Oriented Systems
49
An object-oriented system is made up of interacting
objects that maintains their own local state and
provide operations on that state
3.2 Elements of the Object Models
For all things object-oriented, the conceptual
framework is the object model
There are four major elements as follows;
(1) Abstraction
(2) Encapsulation
(3) Modularity
(4) Hierarchy
50
26
Object Orientation
En
cap
sula
tio
n
Ab
stra
ctio
n
Hie
rarc
hy
Mo
du
lari
ty
51
3.2 Elements of the Object Models
Abstraction is the process or result of
generalization by reducing the information
content of a concept
– Abstraction is one of the fundamental ways that we
as human cope with complexity
A good abstraction is one that emphasis
significant part to the reader and suppresses
detail immaterial and diversionary
– Abstraction focuses on the outside view of an object
and serves to separate an objects' essential behavior
from its implementation
52
(1) The Meaning of Abstraction
27
Sales Person
Not saying which
salesperson – just
a salesperson in
general!!!
CustomerElectronic Product
Example: Abstraction
53
(2) The Meaning of Encapsulation
Abstraction focuses on the observable behavior
of an object, whereas “Encapsulation” focuses
on the implementations that gives rise to this
behavior
The definition of “Encapsulation” is the process
of compartmentalizing the elements of an
abstraction that constitute its structure and
behavior
– Abstraction should be treated as a secret and hidden
from most client in implementation
– Encapsulation serves to separate the contractual
interfaces of an abstraction and its implementation54
28
(2) The Meaning of Encapsulation
Encapsulation is most often achieved through
“Information Hiding”
– All secrets of an object is hidden, as well as the
implementation of its method
– Hiding is the one level of abstraction may be represent
the outside view at another level
– “Hiding is for the prevention of accidents, not the
prevention of fraud”
55
Example: Encapsulation and Hiding
Hiding implementation from clients
– Clients depend on interface
How does an object encapsulate?
What does it encapsulate?
56
29
(3) The Meaning of Modularity
Modularity is that the action of partitioning a
program into “individual components” can
reduce its complexity to some degree
Modularity is the property of a system that has
been decomposed into a set of cohesive and
loosely coupled modules
– The goal of the decomposition into modules is the
reduction of software cost by allowing modules to be
designed and revised independently
– It creates a number of well-defined, documented
boundaries within the program
57
Order Processing
System
Billing
Order
Entry
Order
Fulfillment
Example: Modularity
The breaking up of something complex into
manageable pieces
58
30
(3) The Meaning of Modularity
Modularization consists of dividing a program into
modules which can be compiled separately, but
which have connections with other modules
In object-oriented design, modularity provides a
crisp boundary around a single abstraction
– Both encapsulation and modularity provide barriers
around the abstraction
The principles of abstraction, encapsulation, and
modularity are synergistic
59
(4) The Meaning of Hierarchy
Abstraction, encapsulation, and modularity are
necessary as the following;
– Abstraction help to find/create objects by recognizing
similarities between certain functions, situations, or
processes in the real world
– Encapsulation help manage the complexity by hiding the
inside view of our abstraction
– Modularity help giving us a way to cluster logically related
abstraction
To “simplify” the whole problem, identifying the
hierarchies in design is needed so that a set of
abstractions often forms a “hierarchy structure”
– Hierarchy is a ranking or ordering of abstractions
60
31
(4) The Meaning of Hierarchy
Two most important hierarchies in a complex system
are its class structure (the “is-a” hierarchy) and its
object structure (the “part-of” hierarchy)
– “is-a” relationship
Single inheritance
Multiple inheritance
– “part-of” relationship
Aggregation
61
Decreasing
abstraction
Increasing
abstraction
Asset
RealEstate
Savings
BankAccount
Checking Stock
Security
Bond
Elements at the same level of the hierarchy should be at the same level of abstraction
Example: Hierarchy
62
32
Introduced and define ADTs
– Process abstraction
– Data abstraction
Studied object-oriented models and programming
– Object-oriented concept
– Object-oriented programming (OOP) features
Looked at four elements of object models
– Meaning of abstraction
– Meaning of encapsulation
– Meaning of modularity
– Meaning of hierarchy
Summary
63
Thank You!
Quiz #1:
Assignment #1:
Note and Thank You
Copyright © Prof. K. Lee All rights reserved.