ECE 231 Intermediate Programming and Engineering Problem Solving - PowerPoint PPT Presentation

1 / 11
About This Presentation
Title:

ECE 231 Intermediate Programming and Engineering Problem Solving

Description:

ECE 231 Intermediate Programming and Engineering Problem Solving – PowerPoint PPT presentation

Number of Views:78
Avg rating:3.0/5.0
Slides: 12
Provided by: Hong3
Category:

less

Transcript and Presenter's Notes

Title: ECE 231 Intermediate Programming and Engineering Problem Solving


1
ECE 231Intermediate Programming andEngineering
Problem Solving
  • Fall 2008
  • Honggang Yu

2
Major Differences C vs. C
  • Procedure-Oriented Programming (POP)
  • Procedures/functions/subroutines
  • Top-down design (divide and conquer)
  • Object-Oriented Programming(OOP)
  • Abstract Data Type (ADT), Class (more closer to
    real world), data-hiding, polymorphism and
    inheritance
  • Bottom-up design

3
Contrasting Program Design
  • Procedure-Oriented Object-Oriented

Data Operations
Control
Class
4
Before Object Orientation
Real world concepts
Skljkvjkvjfkavjafkk saovjsdvjfvkfjvkfjk Skljkvjkv
jfkavjafkk saovjsdvjfvkfjvkfjk Skljkvjkvjfkavjafkk
saovjsdvjfvkfjvkfjk Skljkvjkvjfkavjafkk saovjsdvj
fvkfjvkfjk
Object-orientation helps to remedy this mismatch
Poor correspondence
getCustomerName() initialize() doTransacion() getD
ocument()
billCustomer() recordTransaction() initiateTransa
ction()
Software Design Entities
Adapted from Software Design From Programming to
Architecture by Eric J. Braude (Wiley 2003), with
permission.
5
Object Orientation
Real world concepts
Skljkvjkvjfkavjafkk saovjsdvjfvkfjvkfjk Skljkvjkv
jfkavjafkk saovjsdvjfvkfjvkfjk Skljkvjkvjfkavjafkk
saovjsdvjfvkfjvkfjk Skljkvjkvjfkavjafkk saovjsdvj
fvkfjvkfjk
Direct correspondence
Account getDetails()
Transaction execute()
Customer getFirstName()
Software design entities
Adapted from Software Design From Programming to
Architecture by Eric J. Braude (Wiley 2003), with
permission.
Graphics reproduced with permission from Corel.
6
Major Differences C vs. C
  • Easy to maintain, excellent reusability and
    reliability for large projects of millions of
    lines of code
  • Abstract Data Types (ADTs), Classes, Data hiding
    could impede code efficiency
  • Unmaintainable for large projects
  • Good choice for code that has to be fast while
    still being reasonably readable and portable, eg.
    device drivers

7
Syntax Differences C vs. C
  • include ltiostreamgt
  • Data type typecast is different e.g
  • int i 2
  • float f float (i)Format type(variable)
  • Dynamic memory allocation in C by new and
    delete.
  • includeltstidio.hgt
  • int i 2
  • float f (float) iFormat (type)variable
  • in C by calloc() and malloc()

8
Syntax Differences C vs. C
  • main() must have a return type in C
  • Function prototyping (declaration) is compulsive
    in C.
  • Boundary checking for array in C .
  • main() may not have a return type in C
  • Function prototyping (declaration) is optional in
    C.
  • No boundary checking for array

9
Syntax Differences C vs. C
  • the input/output operation is done in C through
    cout and cin objects
  • In C we use namespace name std (Appendix C30)
  • in c it is done through printf() and scanf()
    functions
  • in C it is not needed

10
C Features C with Classes
  • Inheritance (a child class can inherit
  • features of parent class)
  • Polymorphism (Ability to take many
  • forms)
  • Encapsulation (Binding of methods and
  • data together)
  • Abstraction (Hiding the Implementation
  • from the user)

11
Review Appendix C
  • Basic C
Write a Comment
User Comments (0)
About PowerShow.com