ENERGY 211 / CME 211 Lecture 27 November 21, 2008.

Slides:



Advertisements
Similar presentations
Chapter 3: Modularization
Advertisements

Computers Are Your Future
Object Oriented Design An object combines data and operations on that data (object is an instance of class) data: class variables operations: methods Three.
CSE 111: Object Oriented Design. Design “To program is human but to design is divine” (WEH)
1 SYSTEM and MODULE DESIGN Elements and Definitions.
Lecture Notes 1/21/04 Program Design & Intro to Algorithms.
Chapter 1 Principles of Programming and Software Engineering.
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
DCT 1123 PROBLEM SOLVING & ALGORITHMS INTRODUCTION TO PROGRAMMING.
Introduction to High-Level Language Programming
Software Construction. Implementation System Specification Requirements Analysis Architectural Design Detailed Design Coding & Debugging Unit Testing.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 12 Object-Oriented.
Programming. What is a Program ? Sets of instructions that get the computer to do something Instructions are translated, eventually, to machine language.
Python Mini-Course University of Oklahoma Department of Psychology Day 2 – Lesson 6 Program Design 4/18/09 Python Mini-Course: Day 2 - Lesson 6 1.
1 ENERGY 211 / CME 211 Lecture 26 November 19, 2008.
SE: CHAPTER 7 Writing The Program
Software Development. Software Developers Refresher A person or organization that designs software and writes the programs. Software development is the.
REFACTORINGREFACTORING. Realities Code evolves substantially during development Requirements changes 1%-4% per month on a project Current methodologies.
1 CSCD 326 Data Structures I Software Design. 2 The Software Life Cycle 1. Specification 2. Design 3. Risk Analysis 4. Verification 5. Coding 6. Testing.
Introduction to c++ programming - object oriented programming concepts - Structured Vs OOP. Classes and objects - class definition - Objects - class scope.
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
© 2006 Pearson Addison-Wesley. All rights reserved 2-1 Chapter 2 Principles of Programming & Software Engineering.
Chapter 10: Classes and Data Abstraction. Objectives In this chapter, you will: Learn about classes Learn about private, protected, and public members.
PC204 Lecture 5 Programming Methodologies Copyright 2000 by Conrad Huang and the Regents of the University of California. All rights reserved.
ANU COMP2110 Software Design in 2003 Lecture 10Slide 1 COMP2110 Software Design in 2004 Lecture 12 Documenting Detailed Design How to write down detailed.
How Are Computers Programmed? CPS120: Introduction to Computer Science Lecture 5.
Peter Andreae Computer Science Victoria University of Wellington Copyright: Peter Andreae, Victoria University of Wellington Java Programs COMP 102 #3.
Object-Oriented Design Concepts University of Sunderland.
CSci 162 Lecture 8 Martin van Bommel. Large-scale Programming Up to now we have been writing relatively short programs to solve simple problem Want to.
Chapter 10: Classes and Data Abstraction. Classes Object-oriented design (OOD): a problem solving methodology Objects: components of a solution Class:
Chapter – 8 Software Tools.
PROGRAMMING FUNDAMENTALS INTRODUCTION TO PROGRAMMING. Computer Programming Concepts. Flowchart. Structured Programming Design. Implementation Documentation.
CSCE 240 – Intro to Software Engineering Lecture 3.
1 ENERGY 211 / CME 211 Lecture 14 October 22, 2008.
Learning Objectives Today we will Learn: The different methods of implementation The differences between user and technical documentation.
Principles of Programming & Software Engineering
CSC 222: Object-Oriented Programming
Programming paradigms
Working with Java.
Lecture 1 Introduction Richard Gesick.
CSCI-235 Micro-Computer Applications
Key Ideas from day 1 slides
Chapter 11 Object-Oriented Design
GENERAL OOPs CONCEPTS.
Principles of Programming and Software Engineering
CS101 Introduction to Computing Lecture 19 Programming Languages
About the Presentations
Lecture 2 Introduction to Programming
Lecture 2 of Computer Science II
INTRODUCTION TO OBJECT-ORIENTED PROGRAMMING (OOP) & CONCEPTS
Application Development Theory
Lecture 1 Introduction.
Creating and Using Classes
Computer Programming.
Problem Solving Techniques
Introduction to Data Structures
The Object-Oriented Thought Process Chapter 05
Chapter 5 Designing the Architecture Shari L. Pfleeger Joanne M. Atlee
Chapter 1: Computer Systems
Chapter 1 Introduction(1.1)
The Programming Process
Programming We have seen various examples of programming languages
Data Structures and Algorithms for Information Processing
Creating Computer Programs
Introduction to Object-Oriented Programming
Tonga Institute of Higher Education IT 141: Information Systems
Tonga Institute of Higher Education IT 141: Information Systems
ENERGY 211 / CME 211 Lecture 8 October 8, 2008.
Creating Computer Programs
Lecture 8 Object Oriented Programming (OOP)
Presentation transcript:

ENERGY 211 / CME 211 Lecture 27 November 21, 2008

Programming in the Middle How should functions be organized? Short functions easy to debug and test If you can't briefly describe what a function does, break it up! Essential question: how do functions communicate with each other? That is, what are their interfaces? Use data structures such as a struct to package information and simplify interfaces

Interface Design What arguments are needed? Which are input or output? Pass input arguments by value, or const reference if copying is expensive Output arguments should be returned (if only one) or passed by reference Use multiple interfaces (by overloading or default arguments) for expert or novice usage

Top-down and Bottom-up Top-down design: start with high-level description of task, break it down into subtasks, and repeat on subtasks Bottom-up design: implement operations on low-level data structures, then build functionality on top of them Can start in the middle, work both ways Recommended: begin with top-down to understand high-level structure, then use bottom-up to build components

Don't Hard-wire! Hard-wiring is the practice of imposing fixed choices on the design of the code Re-wire code by refactoring: changing design of the code, not what it does Hard-wired: integrating cos(x) using the trapezoidal rule with 20 points Re-wired: a function that implements the trapezoidal rule, passing the integrand and number of points as arguments

What to Comment Interfaces! These comments are "contracts" with users of your code Loop invariants and assertions: document conditions that are guaranteed to be true Warnings about unusual behavior What the code is trying to do What not to comment: don't simply restate what the code is doing!

Documentation User documentation: how to use the code, but not how it works Developer documentation: for other programmers, to change code for their purposes Document only what is necessary; long documents won't be read Be sure to keep documentation in sync with your code

Cross-Language Development Code is rarely translated into other languages (too much time!) Applications often mix languages To help, compiled languages are translated into same object code Must account for conventions in: naming functions passing arguments layout of data structures

Cross-Language Strategies Most features of languages are implemented in ways that limit compatibility: classes, input/output, etc. Calls to functions in other languages should be restricted to simple exchange of data only Write routines to convert data structures Java provides JNI (Java Native Interface) to call compiled code Fortran 2003 provides C types

Procedural vs Object-Oriented In procedural programming, code and data are independent In object-oriented programming, code and data are packaged into objects C is procedural; C++ is both Procedure more efficient, similar to assembly language Object-oriented supports abstraction and modularity through data hiding Can be more efficient using inline

Layered Software Large software projects are typically divided into layers that correspond to (higher or lower) levels of functionality Example: LAPACK is built on top of BLAS, which contains low-level functions that work directly with matrices, while LAPACK focuses on algorithmic details Code should not reach across layers; communicate only through interfaces

Next Time Calling C++ from MATLAB And vice versa!