WITH C++ Prof. Amr Goneid AUC Part 1. Introduction Prof. amr - - PowerPoint PPT Presentation

with c
SMART_READER_LITE
LIVE PREVIEW

WITH C++ Prof. Amr Goneid AUC Part 1. Introduction Prof. amr - - PowerPoint PPT Presentation

CSCE 110 PROGRAMMING FUNDAMENTALS WITH C++ Prof. Amr Goneid AUC Part 1. Introduction Prof. amr Goneid, AUC 1 1. Introduction Software for Problem Solving Software Production Process Top-Down Design Modules Structured


slide-1
SLIDE 1
  • Prof. amr Goneid, AUC

1

CSCE 110 PROGRAMMING FUNDAMENTALS

WITH C++

  • Prof. Amr Goneid

AUC Part 1. Introduction

slide-2
SLIDE 2
  • Prof. amr Goneid, AUC

2

  • 1. Introduction

 Software for Problem Solving  Software Production Process  Top-Down Design  Modules  Structured Software & Program Design  Some Guidelines for Design  Example  C++ Program & Module Structures  Object Oriented Programming

slide-3
SLIDE 3
  • Prof. amr Goneid, AUC

3

Software for Problem Solving

 Use of S/W

Problem Domain S/W Decide, Learn, View & Interact, Play, ……. TO

slide-4
SLIDE 4
  • Prof. amr Goneid, AUC

4

Software Production Process

 Stages of S/W Production

Specify Requirements

Solution Strategy S/W Production S/W Testing Problem Definition Maintenance Upgrade

slide-5
SLIDE 5
  • Prof. amr Goneid, AUC

5

Software Production

S/W Design

Implementation (Programs)

Debugging

Performance Analysis / Benchmarks

slide-6
SLIDE 6
  • Prof. amr Goneid, AUC

6

Top-Down Design

 Divide and Conquer Strategy.  Given problem X (Level 0). Divide it

into sub-problems X1, X2, …, Xn (Level 1) such that solving X1, then X2, then … solves X completely.

 Repeat for each sub-problem until we

reach basic or trivial implementation level.

slide-7
SLIDE 7
  • Prof. amr Goneid, AUC

7

Top-Down Design

Level

X X1 X2 X3 Xn X21 X22 1 2 . .

slide-8
SLIDE 8
  • Prof. amr Goneid, AUC

8

Modules

In C++ Implemented as Main Problem X Main Program X Implemented as Sub-Problem Xi Module Xi

slide-9
SLIDE 9
  • Prof. amr Goneid, AUC

9

Structured Software Design

 Design Steps

Main & Subs Functional Specs Data Specs Algorithm Specs Pseudo- code

slide-10
SLIDE 10
  • Prof. amr Goneid, AUC

10

Structured Program Design

Main Program and Modules X1 Data Actions (Algorithms) X2 Data Actions (Algorithms) Main Data Main Manager

X1 Module X2 Module

Main Program

slide-11
SLIDE 11
  • Prof. amr Goneid, AUC

11

Some Guidelines for Design

 Transparency of Purpose  Correctness  Completeness  Ease of Use  Efficiency  Writability  Maintainability

slide-12
SLIDE 12
  • Prof. amr Goneid, AUC

12

Example of a Design Document

 Problem Definition:

n projects are to be prioritized according to cost (least cost first). Problem size is n

 Requirement Specification:

  • Input(s): n, and list of costs in random
  • rder.
  • Output(s): List of costs in ascending
  • rder.
slide-13
SLIDE 13
  • Prof. amr Goneid, AUC

13

Example(continued)

Solution Strategy:

  • 1. Input random List of costs
  • 2. Sort List in ascending order of cost.
  • 3. Print sorted List.

S/W Design:

Structured (Top-Down) Design: Yields a main module and a sorting module

slide-14
SLIDE 14
  • Prof. amr Goneid, AUC

14

Example(continued)

 S/W Design (continued):

 Functional Specification:

 Main Module:

– Input list and its size n – Call Sorting module to sort list – Output sorted list

 Sorting Module:

– Receives list and its size n – Returns sorted list

slide-15
SLIDE 15
  • Prof. amr Goneid, AUC

15

Example(continued)

 S/W Design (continued):

 Data Specification:

The cost is an integer number. MAX = 100 to represent maximum list size An Array (a) of size MAX to store list.

 Algorithm Specification:

Sorting module uses the algorithm of Selection Sort.

slide-16
SLIDE 16
  • Prof. amr Goneid, AUC

16

Example(continued)

S/W Design (continued):

Main Module:

1.

Input n.

2.

Check that n does not exceed MAX.

3.

Input random list into array (a). Items will

  • ccupy locations a0 ….. an-1

4.

Call sorting module.

5.

Output sorted list (a).

slide-17
SLIDE 17
  • Prof. amr Goneid, AUC

17

Example(continued)

S/W Design (continued):

Sorting module (Selection Sort): Repeat for list items k from 0 to n-2

1.

Consider the sub-array from k to n-1

2.

Find location of the smallest element in that sub-array

3.

Exchange that element with that at (k)

slide-18
SLIDE 18
  • Prof. amr Goneid, AUC

18

Example(continued)

 Implementation Stage:

As a C++ Program

slide-19
SLIDE 19
  • Prof. amr Goneid, AUC

19

C++ Program Structure

Compiler Directives

Used Modules (Functions) Prototypes Main Function Header { Main Data Declarations Main Function Actions } Used Modules (Functions) are Defined Here

slide-20
SLIDE 20
  • Prof. amr Goneid, AUC

20

C++ Module (Function) Structure

Module (Function) Header { Local Data Declarations Module Actions (Executable Statements) }

slide-21
SLIDE 21
  • Prof. amr Goneid, AUC

21

Object Oriented Programming

 Abstraction:

Data Model of a physical object or process

 Methods:

Operations (Algorithms) performed on data of an

  • bject

 Class:

Entity defining attributes of an object (data and methods)

 Object:

An actual instance of a class