Top Banner
PC204 Lecture 5 Programming Methodologies Copyright 2000 by Conrad Huang and the Regents of the University of California. All rights reserved.
21

PC204 Lecture 5 Programming Methodologies Copyright 2000 by Conrad Huang and the Regents of the University of California. All rights reserved.

Jan 19, 2016

Download

Documents

Bertram Carroll
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: PC204 Lecture 5 Programming Methodologies Copyright 2000 by Conrad Huang and the Regents of the University of California. All rights reserved.

PC204

Lecture 5

Programming Methodologies

Copyright 2000 by Conrad Huang and the Regents of the University of California.All rights reserved.

Page 2: PC204 Lecture 5 Programming Methodologies Copyright 2000 by Conrad Huang and the Regents of the University of California. All rights reserved.

Programming Paradigms

• Software Engineering

• Exploratory Programming

Page 3: PC204 Lecture 5 Programming Methodologies Copyright 2000 by Conrad Huang and the Regents of the University of California. All rights reserved.

Software Engineering

• Requirements• Specification• Design• Coding• Verification• Debugging

• Documentation• Dissemination• Maintenance• Enhancement

Page 4: PC204 Lecture 5 Programming Methodologies Copyright 2000 by Conrad Huang and the Regents of the University of California. All rights reserved.

Why Doesn’t It Work (for us)?

• Fuzzy requirements

• The most important phase is often is least well defined, especially in a research environment

Page 5: PC204 Lecture 5 Programming Methodologies Copyright 2000 by Conrad Huang and the Regents of the University of California. All rights reserved.

Exploratory Programming

• Faster feedback loop

• Standard components

• Reusable components

• Rapid Application Development (RAD)

Page 6: PC204 Lecture 5 Programming Methodologies Copyright 2000 by Conrad Huang and the Regents of the University of California. All rights reserved.

Methodologies

• Functional decomposition

• Structured programming

• Modular programming

• Object-oriented programming

• Generic programming

• Extreme programming

• Agile programming

Page 7: PC204 Lecture 5 Programming Methodologies Copyright 2000 by Conrad Huang and the Regents of the University of California. All rights reserved.

What’s the Difference?

• Methodologies may be applied for any programming language

• Some languages are easier (or harder) to use with some methodologies

• The outward appearance of a program is frequently determined by the language, but the methodology may be discerned from code organization

Page 8: PC204 Lecture 5 Programming Methodologies Copyright 2000 by Conrad Huang and the Regents of the University of California. All rights reserved.

Evaluation Criteria

• Correctness

• Maintainability

• Flexibility

• Reusability

Page 9: PC204 Lecture 5 Programming Methodologies Copyright 2000 by Conrad Huang and the Regents of the University of California. All rights reserved.

Functional Decomposition

• Divide problem into phases

• Flowchart diagrams• “Input, compute,

output”• Algorithm for each

phase• Fortran

• Correctness - okay• Maintainability - okay• Flexibility - limited• Reusability - limited

Page 10: PC204 Lecture 5 Programming Methodologies Copyright 2000 by Conrad Huang and the Regents of the University of California. All rights reserved.

Functional Decomposition

yes

yes

no

no

loop

Page 11: PC204 Lecture 5 Programming Methodologies Copyright 2000 by Conrad Huang and the Regents of the University of California. All rights reserved.

Structured Programming

• Local organization• No “go to”s• Use functions• Characterized as “just

indentations” by unbelievers

• Fortran, C, Pascal

• Correctness - okay• Maintainability - better

– more readable code

• Flexibility - okay– simpler to reorganize

• Reusability - better– reuse functions

Page 12: PC204 Lecture 5 Programming Methodologies Copyright 2000 by Conrad Huang and the Regents of the University of California. All rights reserved.

Structured Programming

yes

yes

no

no

loop

Function

Function

Page 13: PC204 Lecture 5 Programming Methodologies Copyright 2000 by Conrad Huang and the Regents of the University of California. All rights reserved.

Modular Programming

• Group related data and functions together

• Module functions operate on module data

• Interface vs. Implementation

• Data abstraction and data encapsulation

• C, Algol, Ada

• Correctness - good– module-based testing

• Maintainability - good– localized changes

• Flexibility - better• Reusability - better

– reuse entire modules

Page 14: PC204 Lecture 5 Programming Methodologies Copyright 2000 by Conrad Huang and the Regents of the University of California. All rights reserved.

Modular Programming

ModuleModule

Module

Page 15: PC204 Lecture 5 Programming Methodologies Copyright 2000 by Conrad Huang and the Regents of the University of California. All rights reserved.

Object-oriented Programming

• Formalize convention of always passing module data structures to module functions

• Class: definition of data and the functions that operate on them

• Object: data created from class definition

• Smalltalk, C++, Java

• Correctness - good• Maintainability - better

– guaranteed internal consistency

• Flexibility - better• Reusability - better

– reuse concepts

Page 16: PC204 Lecture 5 Programming Methodologies Copyright 2000 by Conrad Huang and the Regents of the University of California. All rights reserved.

Object-oriented Programming

Class

Class

Instance

Instance

Instance

Instance

Page 17: PC204 Lecture 5 Programming Methodologies Copyright 2000 by Conrad Huang and the Regents of the University of California. All rights reserved.

Generic Programming

• Back to algorithms

• Objects that share the same interface can be generically manipulated

• Toolkits of objects and algorithms

Page 18: PC204 Lecture 5 Programming Methodologies Copyright 2000 by Conrad Huang and the Regents of the University of California. All rights reserved.

What Is A Good Design?

• Too few classes, and code is limited in flexibility and reusability– lacks cohesion

• Too many classes, and code is more difficult to verify and maintain– too much coupling

• Design is still an art form

Page 19: PC204 Lecture 5 Programming Methodologies Copyright 2000 by Conrad Huang and the Regents of the University of California. All rights reserved.

Design Evaluation DeploymentCoding

Debugging

Ouch

Design vs. Coding

• Coding from a design is much simpler than “hacking” because most of the hard work has been done

• Sometimes you have to hack to find the right design

Page 20: PC204 Lecture 5 Programming Methodologies Copyright 2000 by Conrad Huang and the Regents of the University of California. All rights reserved.

Object-oriented Programming

• Languages that support object-oriented programming have built-in concept of class

• In addition to design, object-oriented programming also features inheritance

• Base class defines behavior; derived class defines new or redefines base behavior

• Simplifies code reuse

Page 21: PC204 Lecture 5 Programming Methodologies Copyright 2000 by Conrad Huang and the Regents of the University of California. All rights reserved.

Reference Material

• Object Oriented Design with Applications, Grady Booch

• Object-oriented Software Construction, Bertrand Meyer

• Software Tools, Brian Kernighan, et al.