SEG 4570 System Design and Implementation Tutorial 1 - PowerPoint PPT Presentation

1 / 22
About This Presentation
Title:

SEG 4570 System Design and Implementation Tutorial 1

Description:

It can be viewed as functional decomposition. II. Object-oriented Analysis (OOA) ... world entities into object-oriented components (object-oriented decomposition) ... – PowerPoint PPT presentation

Number of Views:64
Avg rating:3.0/5.0
Slides: 23
Provided by: chanki
Category:

less

Transcript and Presenter's Notes

Title: SEG 4570 System Design and Implementation Tutorial 1


1
SEG 4570System Design andImplementationTutoria
l 1
2
Tutorial Content
  • Procedural vs Object-Oriented
  • Basic Concepts
  • Design for a Library System
  • I. Procedural Approach
  • II. Object-Oriented Approach
  • Procedural vs Object-Oriented

3
Basic Concepts
  • I. Procedural System Analysis Approach
  • Examine a problem using input-processing-output
    (information flow) model and implement the model
    in the same way.
  • It can be viewed as functional decomposition.
  • II. Object-oriented Analysis (OOA)
  • Examines requirements from the perspective of
    object-oriented concept such as classes, objects,
    attributes, operations and inheritance.
  • It emphasizes the identification and
    classification of real-world entities into
    object-oriented components (object-oriented
    decomposition).

4
Basic Concepts
  • III. Coupling
  • The degree of interaction between modules.
  • 5 levels (high to low)
  • Content coupling is when one module modifies or
    relies on the internal workings of another module
    (e.g. accessing local data of another module).
  • Common coupling is when two modules share the
    same global data (e.g. a global variable)
  • Control coupling is one module controlling the
    logic of another, by passing it information on
    what to do
  • Stamp coupling is when modules share a composite
    data structure and use only a part of it (e.g.
    passing a whole record to a function which only
    needs one field of it).
  • Data coupling is when modules share data through,
    for example, parameters.
  • Modules should be loosely coupled.

5
Designing a Library System
  • Sample Problem
  • Implements a simple library system which handles
    a information database of books.
  • A database file consists of records of
    information about each book, including the books
    id, title, author, year and status is provided.
  • The system is able to load the database file,
    allows user to perform keyword search of books
    through title and author, check out books and
    save the current information into the database.

6
Design for a Library System Using Procedural
Approach
  • 1. Problem identification
  • Implement a library system
  • Requirements
  • I. Load database from database file.
  • II. Search keyword through the title and
    author.
  • III. Check out books.
  • IV. Save current information to the database
    file.
  • 2. Draw DFD to illustrate the data flow in the
    system (input-processing-output model)

7
Design for a Library System Using Procedural
Approach
  • A sample DFD

8
Design for a Library System Using Procedural
Approach
  • 3. Implement the model with Functions for each
    process
  • I. Define a book structure II. Define a
    database structure

  • III. Define variables in main ( )

typedef struct char id char title
char author char year char status
Book
typedef struct int no_of_books char
db_name Book books50 Database
Database lib_db char cmd ...
9
Design for a Library System Using Procedural
Approach
  • IV. Define the following functions in separate
    modules

void loadDb(char db_file, Database ) void
saveDb(Database ) void search(char str_search,
Database ) void chkout(char str_id, Database
) int getCmd( ) void exeCmd(int
cmd_type) char getTitle(Book ) char
getAuthor(Book ) int getStatus(Book ) void
setStatus(Book )
10
Design for a Library System Using Procedural
Approach
  • A Library System Using Procedural Approach

11
Design for a Library System Using Object-Oriented
Approach
  • 1. Problem identification
  • similar to Procedural Approach
  • 2. Identifying and creating Objects
  • I. List all nouns involved in the problem
  • II. Group the nouns to form classes
  • III. Design the communication between each
    class
  • IV. Add methods to the classes
  • V. Review the design to minimize no. of
    classes

12
Design for a Library System Using OO Approach
  • 3. Implement the model with Classes and Objects
  • I. Book.h

class Book private String id String title
String author String year String status
public void setRecord(String record) void
setStatus( ) String getRecord( ) String
getTitle( ) String getAuthor( ) int
getStatus( )
13
Design for a Library System Using OO Approach
  • II. Database.h
  • III. LibSys.h

class Database private int no_of_record
String db_name Book record50
public void loadDb(String db_file) void
saveDb( ) void search(String str_search) void
chkout(String str_id)
class LibSys private Database lib_sys
String cmd
public int getCmd( ) void exeCmd(int
cmd_no)
14
Design for a Library System Using OO Approach
  • A Library System Using OO Approach

15
Procedural Approach vs OO
  • 1. Modeling Power
  • I. Modeling Power in Procedural Programming
  • Restricted to functional models. Systems can only
    be modeled by information flow.
  • Difficult to model systems with high complexity.
  • II. Modeling Power in OOP
  • Systems can be modeled by the interaction between
    objects which can better resemble the real world
    than traditional software can.
  • This makes OOP easier to understand and the
    problem model more similar to the physical
    implementation model.

16
Procedural Approach vs OO
  • 2. Data Abstraction
  • I. Abstraction in Procedural Programming
  • Process Abstraction only
  • Subprograms allow a calling program to specify
    that a process is to be done without spelling out
    how.
  • e.g. ordinary functions, subprograms,
  • Problems
  • User-defined data do not have their own
    operations, any operation can access any data by
    parameter passing.
  • Lead to high coupling between modules.

17
Procedural Approach vs OO
  • 2. Data Abstraction
  • II. Data Abstraction in OOP
  • Extend data abstraction to a higher level data
    type, which is called class.
  • Data manipulation can only be done by operations
    specified in the definition of the data within a
    class.
  • Classes can be viewed as as user-defined abstract
    data type where related data and their operations
    are hidden.
  • It is also known as encapsulation.
  • Advantages
  • Modules becomes self-contained which greatly
    reduces the coupling between them.

18
Procedural Approach vs OO
  • 3. Modular Structure
  • I. Modular Structure in Procedural Programming
  • Modules are defined by functions which are more
    complicated.
  • Modules are tightly coupled, changes to one part
    can easily lead to unforeseen behavioral changes
    in other parts.
  • Relationships between modules cannot be easily
    discovered.
  • Modules may need to be tested as a whole.

19
Procedural Approach vs OO
  • 3. Modular Structure
  • II. Modular Structure in OOP
  • Components of a OO system consist of
    self-contained objects, unexpected side effects
    in other modules occur less frequently after
    modifications are made.
  • Relationship between modules can be easily seen
    from the header files.
  • Individual modules can also be tested separately
    which makes system more reliable.

20
Procedural Approach vs OO
  • 4. Maintenance
  • I. Maintenance in Procedural Programming
  • Weak maintainability.
  • Due to the high complexity and coupling between
    modules, it is difficult to understand the
    system.
  • System cannot be easily modified to meet changes
    in requirement. i.e. not flexible.
  • II. Maintenance in OOP
  • As modules in OO system are easier to be modified
    and understood, maintenance can be done in a
    fraction of the time needed for traditional
    system.

21
Procedural Approach vs OO
  • 5. Reusability
  • I. Reusability in Procedural Programming
  • Modules with high coupling are difficult to
    reuse.
  • II. Reusability in OOP
  • Since objects are independent entities with their
    own data and operations, it is possible to reuse
    some objects in other applications.
  • OOP supports inheritance and polymorphism which
    can greatly increase the module reusability.

22
Conclusions
  • 1. OOA has a better modeling power than
    structured approach through object-oriented
    decomposition.
  • 2. OOP has a low mutual coherent between modules
    which make OO system more readable, maintainable,
    reliable, flexible and reusable.
  • 3. Some OO features such as inheritance and
    polymorphism, which cannot be found in classical
    language, can greatly increase the quality of the
    OO system.
Write a Comment
User Comments (0)
About PowerShow.com