SW ADT Object Models

Published on February 2017 | Categories: Documents | Downloads: 29 | Comments: 0 | Views: 194
of 32
Download PDF   Embed   Report

Comments

Content

CSCI 528 Data Structures
- Introduction to SW Design Processes, ADT, and Object Models -

Dr. Kwang Lee
School of Information
Technology

Announcement!
Quiz #1:
Assignment #1:

Copyright © Prof. K. Lee All rights reserved.

1

Introduction to SW Development
Processes
Lecture 1

Lecture Overview



Introduce software development approaches
SW analysis and design methods




Introduce design aspects







Study top-down and objected-oriented approaches
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

2

1. SW Development


Usually, three basic approaches to be needed for
development SW


Identify and Analysis




Design




Confirm needs, solve a problems, and analysis stuff with
programming
Produce solutions without detail implementation

Implement


Involve coding algorithm and data structures with programming
languages

5

1. SW Development




Adding test and maintenance steps
5 phases of SW life cycle

Waterfall Model
6

3

1. SW Development

Realistic Waterfall Model
7

1. SW Development
(1) Identify and Analysis Steps
(2) SW Design Steps
(3) SW Implementation Procedures
(4) Testing, Executing, and Debugging
(5) Maintenance

8

4

1.1 Identify Steps


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
9

1.1 Identify Steps


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

10

5

1.1 Identify Steps


Real world contracts or specifications
-



Must be precise
May be required to prove end product meets these precise
specifications

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
11

1.2 SW Design Steps


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
12

6

(1) Structured Design Method


Using top-down procedures;




Identifying major actions
Analyzing their control flows
Expressing solution in terms of control structures
and functions

13

(1) Structured Design Method



Original problem partitioned into simple subproblems by actions and functions
Each of these sub-problems likewise subdivided

14

7

Example: Structured Programming
Data1
Data2

Nouns

Data3

Operation1 (funtion1) {
------------------}

Verbs

Operation2 (funtion2) {
------------------}
15

(2) Object Oriented Design Method


Using object-oriented analysis




Identifying major objects
Analyzing their operations
Expressing solution in terms of these objects and
operations

16

8

(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
Record

Student
17

Example: Object-Oriented Programming
Class 1 {

Class 2 {

Data

Data

Methods

Methods
}

}

Class n {
Data
Methods
}

18

9

(3) Determine Data and Operation Types



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




Think of them as
Containers

arrays
structures
class objects
19

(3) Determine Data and Operation Types


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

20

10

Example: Pseudocode




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

21

1.3 SW Implementation Procedures




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
22

11

1.4 Testing, Executing, and Debugging



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

23

1.4 Testing, Executing, and Debugging


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

24

12

(1) Kinds of Tests


Completing three type of tests required


Unit tests





Integration tests





Each individual program unit works?
Program components tested in isolation
Units combined correctly?
Component interface and information flow tested

System tests



Overall system works correctly?
System programs, sub-programs, and libraries

25

(2) Types of Errors


Syntax errors




Errors in the link programs to make an executable

Run-time errors




Errors in the grammar of the programming language

Link errors




Difficulty

Errors happen during the duration of its execution
from beginning to termination

Logic errors


Errors produces unintended or undesired output or
other behavior
26

13

1.5 Maintenance


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
27

Appendix: “V” Life Cycle Model


The "V" Life Cycle Model Test by Dorothy
Graham

28

14

Appendix: Fusion Method


Fusion Method by Hewlett-Packard
Requirement Doc

Object Models

Analysis Part

Interface Models

Object Interaction Graphs

Visibility Graphs

Design Part
Class Descriptions

Inheritance Graphs

Programs

Implementation Part
29

Summary


Discussed Software Development Processes


Identify and analysis steps




SW design steps






Select languages, C, C++, Java, C#, etc to implement SW

Discuss testing methods




Choose top-down and objected-oriented approaches
Select or build data types
Develop algorithms for operations on data

Implement SW code procedures




Identify and analyze systems requirements

Investigate error types

Set maintenance
30

15

Introduction to ADT and Object
Models
Lecture 1

Lecture Overview


Introduce and define ADTs






Why OOP need?





Process abstraction
Data abstraction
What is ADT?
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

32

16

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

17

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?




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‟




1 +1 + 1 + 1 + 1 + 1 = 6

2 + 3 + ,…, + 2 = 21

Create another abstracted operation (×),
multiplication


(3 × 2 × 3) + 3 = 21
36

18

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

19

(2) Data Abstraction


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

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

20

2. What is ADT?


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.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
Unit

Data
Operations



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

21

2.2 ADT Implementations in C++, Java


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)
43

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

44

22

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

23

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):




Object-oriented design (OOD):




concerned with developing an object model of the
application domain by discovering the classes and
objects
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

24

Example: Object-Oriented Systems


An object-oriented system is made up of interacting
objects that maintains their own local state and
provide operations on that state

49

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

25

3.2 Elements of the Object Models

Hierarchy

Modularity

Encapsulation

Abstraction

Object Orientation

51

(1) The Meaning of Abstraction


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

26

Example: Abstraction

Sales Person
Not saying which
salesperson – just
a salesperson in
general!!!
Customer

Electronic Product

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 implementation
54

27

(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

28

(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

Example: Modularity


The breaking up of something complex into
manageable pieces
Order
Entry

Order Processing
System

Order
Fulfillment

Billing

58

29

(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

30

(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

Example: Hierarchy
Asset

Increasing
abstraction

BankAccount

Savings Checking
Decreasing
abstraction

Security

Stock

RealEstate

Bond

Elements at the same level of the hierarchy
should be at the same level of abstraction
62

31

Summary


Introduced and define ADTs





Studied object-oriented models and programming





Process abstraction
Data abstraction
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
63

Note and Thank You
Quiz #1:
Assignment #1:

Thank You!
Copyright © Prof. K. Lee All rights reserved.

32

Sponsor Documents

Or use your account on DocShare.tips

Hide

Forgot your password?

Or register your new account on DocShare.tips

Hide

Lost your password? Please enter your email address. You will receive a link to create a new password.

Back to log-in

Close