IEG3080 Software Engineering - PowerPoint PPT Presentation

1 / 42
About This Presentation
Title:

IEG3080 Software Engineering

Description:

The essential idea of OO. Base class provides the interface (function declaration) ... Different parts are manufactured by different companies from different places in ... – PowerPoint PPT presentation

Number of Views:34
Avg rating:3.0/5.0
Slides: 43
Provided by: mch6
Category:

less

Transcript and Presenter's Notes

Title: IEG3080 Software Engineering


1
IEG3080 Software Engineering
  • Instructor Prof. Michael Chang
  • About this course
  • Object-oriented programming
  • C
  • Design Patterns
  • Software Methodologies
  • Reference text
  • Design patterns by Gamma et al (Addison Wesley)
  • The Bible in OO, must read it if you are
    interested in OO. Examples written in C, but
    not hard to follow
  • www.wikipedia.org

2
  • 4 Assignment 10
  • 1 Project 30
  • Final Exam (open notes, one A4 paper) 60
  • Homepage http//course.ie.cuhk.edu.hk/ieg3080
  • How to download Visual Studio .NET
  • Get the form from
  • www.ie.cuhk.edu.hk/fileadmin/download/student/docu
    ment/msdnaa.pdf
  • Ignore the CD part, dont need my signature, sign
    it and return it to tutors

3
  • No plagiarism
  • Policy of zero tolerance
  • Penalties include failing the course and
    receiving demerits.
  • http//www.cuhk.edu.hk/policy/academichonesty/
  • Please sign the No plagiarism declaration form
    and attach it together with your
    assignment/project
  • The form can be downloaded from section 9 in
    above site

4
  • Interface
  • Implementation

5
What is software engineering?
  • How to build
  • large-scale software
  • by a large team of people
  • quickly
  • and
  • inexpensively?

6
Problems
  • Software is expensive
  • Delivery is always late
  • Software is unreliable
  • Software is difficult to maintain
  • the code is written by other people
  • Software is difficult to adapt to future change
  • Difficult to manage a large team

7
Problems
  • Technical problems
  • To build complex software reliably, quickly,
    cheaply, easy to maintain, and can be changed
    flexibly in future
  • OO, design patterns, etc
  • Management problems
  • How to manage software project
  • Software methodology

8
Management solution
  • Effective communication
  • How to manage a team
  • People has different skills
  • Turnover
  • Communicate in a large team
  • Quality of the software
  • How to manage the customers
  • How to collect the requirements
  • Are we building the system that the customers
    want?

9
Management solution
  • Software methodologies
  • Best practices in software development
  • Traditional methods
  • Rational Unified Process
  • Extreme Programming (XP)
  • CASE tools
  • UML - schematic diagram for software
  • NUnit for regression testing of software

10
Technical solution
  • How to build complex software reliably, quickly,
    cheaply, easy to maintain, and can be changed
    flexibly in future
  • Solution
  • Reusable software
  • Key to reusable software
  • Many solutions, but the most important concept is
    the interface
  • In particular, the separation of interface with
    the implementation

11
Levels of reuse
  • Source code reuse
  • But vendors dont give the source code away
  • Binary code reuse
  • But how to modify existing binary code?
  • Interface reuse
  • Key to flexible software
  • Design reuse
  • Design patterns, solutions to common programming
    problems

12
Software is complex
  • How to deal with complex system?
  • Divide and conquer
  • Divide a complex system into sub-systems, and a
    sub-system into objects
  • Each component can be developed independently
    from each other
  • How to divide a system into parts
  • Key issue - the interface between parts

13
????
14
To divide a system into parts
  • A decomposed cow

Body
Head
Read Leg
Front Leg
15
Is software easy to change?
  • Good software will be used for many years
  • Must be able to extend/modify the software in
    order to cater for future needs
  • Is software easy to change?
  • Look easy, but in fact difficult !!
  • Why?
  • Too many dependencies between different modules
  • ???????

16
Solution?
  • Reduce dependency between parts
  • Can change a component freely without affecting
    the rest of the system
  • Interface is the key to flexible and extensible
    software
  • Related concepts
  • Loose coupling
  • Modularity
  • Encapsulation
  • Information hiding

17
Interface so that parts can be changed
independently
  • USB interface

PC
Camera
USB Interface
Disk
Phone
18
To connect to a new camera
New Camera
PC
USB Interface
Disk
Phone
19
Interface and Implementation
  • Interface is a specification, describing how
    components should be joint
  • Implementation is the real stuff (the code)
  • Interface is MORE IMPORTANT than implementation
  • Why?
  • Interface, once fixed, is hard to change
  • e.g. USB
  • Implementation can be easily changed
  • e.g. mobile phone, camera, printer

20
What is an object?
  • Object is a software component that you can reuse
    easily
  • Each object has its own localized functions and
    data
  • Object function data
  • Why do we want localized functions and data?
  • So that we can change a component easily

New Camera (data)
PC (data)
21
Separation of interface and implementation
  • Interface and implementation are two different
    things

New Camera (data)
PC (data)
Implementation
Interface (USB)
22
What is a USB interface?
  • Just a specification on paper
  • Abstract concept, not concrete product
  • Interface, not implementation

23
What is the use of header file in C?
Interface
implementation
.h file int foo(int x)
.c file int foo(int x) . . .
24
The reason of using header file
  • Separation of interface and implementation

.h file
Rest of the system Can only see the header file,
so that the implementation can be changed freely
.c file
25
The advantage of the separation
  • .c file (the code) can be changed without
    affecting the rest of the system
  • .h file (the header) cannot be changed!!

.h file
Rest of the system Can only see the header file,
so that the code can be changed freely
New .c file
26
The essential idea of OO
  • Base class provides the interface (function
    declaration)
  • The subclass provides the function implementation
  • The subclass inherits the interface of the base
    class

Interface class
Rest of the system Can only see the base class
(interface), so that the subclass (implementation)
can be changed freely
Implementation
27
Inheritance
  • Inheritance is a key concept in OOP. What does it
    mean?
  • If class B inherits class A, then class B has
    everything in A
  • Class interface implementation
  • An easy way to reuse other peoples interface and
    implementation
  • UML notation

A
B
28
Interface inheritance versus implementation
inheritance
  • Class A (the base class) may have interface and
    implementation
  • Class B (the sub-class) inherits both the
    interface and implementation in A
  • Interface inheritance
  • Implementation inheritance
  • Interface inheritance is much more important than
    implementation inheritance
  • The main purpose of the base class is to provide
    an interface, so that the sub-class
    (implementation) can be changed freely in future

29
Reusable software
  • Inheritance reuse
  • By inheritance
  • Implementation reuse
  • By delegation
  • Reuse other peoples code by using other peoples
    object to do the work for you
  • Inheritance and delegation are the two key
    concepts in OO

30
Common misconception about OO
  • Wrong concept
  • The main purpose of inheritance is to inherit the
    codes in the base class
  • This concept is wrong
  • It confuses the concept of interface inheritance
    with implementation inheritance
  • Implementation can be reused by delegation rather
    than by inheritance
  • Just creates an object and use it (like getting a
    code library and use it)

31
Inheritance
  • Example
  • Interface
  • USB specification (just a piece of paper, totally
    abstract)
  • Implementation
  • MP3 player
  • Digital camera
  • Mobile phone

32
Inheritance and implementation
Rest of the System
USB
Interface
Mobile Phone
Implementation
MP3
Digital Camera
33
Interface and implementation
  • Interface promotes the following related design
    concepts
  • Modularity
  • Divide a system into modules
  • Encapsulation
  • Hide the complexity of module, expose only the
    interface
  • Abstraction
  • Intellectual simplification, e.g. USB is an
    abstraction of devices (existing or yet to be
    invented)
  • Reduce the amount of learning
  • Loose coupling
  • change in one module wont affect others

34
The key to LARGE SCALE DEVELOPMENT
  • Different parts are manufactured by different
    companies from different places in the world
  • Modularity, encapsulation, abstraction, and loose
    coupling are boiled down to one important
    principle in good engineering design
  • The Interface

35
Example of good interface
  • World-wide web
  • Network level interface HTTP protocol
  • Human level interface HTML/XML
  • Internet
  • Interfaces - IP
  • Airplane, plumbing, car, . . .
  • 2nd language (English) is more important than
    mother tongue for business communication

36
The high input impedance / low output impedance
principle in circuit design
  • B has high input impedance and low output
    impedance, can change B without affecting the
    rest of the system
  • Essential ideas are the same
  • Divide and conquer
  • With good interface, one can change a part
    without affecting the rest of the system

Box A
Box B
Box C
37
The most important principle in (software)
engineering
  • Separation
  • of
  • Interface
  • and
  • Implementation

38
Interface and implementation
Interface versus implementation
Disk drive CDROM Printer Digital
camera Future products . . .
USB bus
Polymorphism many different forms
39
  • USB is an abstraction of the hardware
  • Design the PC system around the USB interface,
    not to a particular device
  • The first principle in OOP (in Gammas Design
    Pattern)
  • programming to an interface, not an
    implementation

40
From C, C to Java/C
  • Basic principles are the same
  • The separation of interface from implementation
  • The differences
  • On granularity
  • C at sub-system level (coarser scale)
  • C, C - at object level (finer scale)
  • C is complicated
  • C (and Java) is simpler (no pointer)

41
Abstract versus concrete
  • Interface is abstract, implementation is concrete
  • Top designers design the interface, they dont
    code !!
  • Implementation is done by programmers working
    independently all over the world
  • OO is about an abstract style of programming,
    focus on the interface

42
Which one is a more successful design from OO
point of view?
Morning ?
Twins
Write a Comment
User Comments (0)
About PowerShow.com