Program Design CMSC 201. Motivation We’ve talked a lot about certain ‘good habits’ we’d like you guys to get in while writing code. There are two main.

Slides:



Advertisements
Similar presentations
Modular Design Using Subroutines (functions later)
Advertisements

Unit 6 Assignment 2 Chris Boardley.
Chapter 3: Modules, Hierarchy Charts, and Documentation
Chapter 3: Modularization
Chapter 2: Modularization
Summaries of brainstorm tutorials lesterk.myweb.port.ac.uk/inse/storms.
Programming Logic and Design Fourth Edition, Introductory
Week 9: Methods 1.  We have written lots of code so far  It has all been inside of the main() method  What about a big program?  The main() method.
CS 201 Functions Debzani Deb.
CS 201 Functions Debzani Deb.
Chapter 2: Developing a Program Extended and Concise Prelude to Programming Concepts and Design Copyright © 2003 Scott/Jones, Inc.. All rights reserved.
Chapter 1 Program Design
Program Design Divide and Conquer –Divide the program into separate tasks Functional Decomposition Top-Down Design –Divide an overall problem into discrete.
Chapter 8: Introduction to High-Level Language Programming Invitation to Computer Science, C++ Version, Fourth Edition.
Problem Solving Chapter 2. What is an algorithm? n A solution to a problem that is: –Precise –Effective –Terminating.
OBJECT ORIENTED PROGRAMMING IN C++ LECTURE
The Project AH Computing. Functional Requirements  What the product must do!  Examples attractive welcome screen all options available as clickable.
COMP An Introduction to Computer Programming : University of the West Indies COMP6015 An Introduction to Computer Programming Lecture 02.
DCT 1123 PROBLEM SOLVING & ALGORITHMS INTRODUCTION TO PROGRAMMING.
Abstraction IS 101Y/CMSC 101 Computational Thinking and Design Tuesday, September 17, 2013 Carolyn Seaman University of Maryland, Baltimore County.
GENERAL CONCEPTS OF OOPS INTRODUCTION With rapidly changing world and highly competitive and versatile nature of industry, the operations are becoming.
Simple Program Design Third Edition A Step-by-Step Approach
Top-Down Design and Modular Development
The Program Development Cycle
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley STARTING OUT WITH Python Python First Edition by Tony Gaddis Chapter 3 Simple.
Chapter 06 (Part I) Functions and an Introduction to Recursion.
Abstraction IS 101Y/CMSC 101 Computational Thinking and Design Tuesday, September 17, 2013 Marie desJardins University of Maryland, Baltimore County.
1 Systems Analysis and Design in a Changing World, Thursday, January 18, 2007.
Top-Down Design and Modular Development. The process of developing methods for objects is mostly a process of developing algorithms; each method is an.
An Object-Oriented Approach to Programming Logic and Design Fourth Edition Chapter 6 Using Methods.
Intermediate 2 Software Development Process. Software You should already know that any computer system is made up of hardware and software. The term hardware.
Making Decisions uCode: October Review What are the differences between: o BlueJ o Java Computer objects represent some thing or idea in the real.
Chapter 1 Program design Objectives To describe the steps in the program development process To introduce the current program design methodology To introduce.
Program Development Cycle Modern software developers base many of their techniques on traditional approaches to mathematical problem solving. One such.
Chapter 10 Software Engineering. Understand the software life cycle. Describe the development process models. Understand the concept of modularity in.
CMSC 104, Version 8/061L17Top-DownDesign.ppt Top-Down Design Topics Top-Down Design Top-Down Design Examples The Function Concept Reading Sections 3.1.
The Software Development Process
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.
1 CS161 Introduction to Computer Science Topic #9.
L061 Algorithms, Part 3 of 3 Topics Top down-design Structure charts Reading Sections , 3.3.
Top-down approach / Stepwise Refinement & Procedures & Functions.
The Art of Programming. The process of breaking problems down into smaller, manageable parts By breaking the problem down, each part becomes more specific.
Introduction to OOP CPS235: Introduction.
04/02/ Procedures Top-down approach / Stepwise Refinement & Sub Procedures.
Introduction to Functions CSIS 1595: Fundamentals of Programming and Problem Solving 1.
1 COS 260 DAY 12 Tony Gauvin. 2 Agenda Questions? 5 th Mini quiz –Chapter 5 40 min Assignment 3 Due Assignment 4 will be posted later (next week) –If.
Functions Part I (Syntax). What is a function? A function is a set of statements which is split off into a separate entity that can be used like a “new.
1 UMBC CMSC 104, Section Fall 2002 Functions, Part 1 of 3 Topics Top-down Design The Function Concept Using Predefined Functions Programmer-Defined.
Program Design. Simple Program Design, Fourth Edition Chapter 1 2 Objectives In this chapter you will be able to: Describe the steps in the program development.
CMSC 104, Section 301, Fall Lecture 18, 11/11/02 Functions, Part 1 of 3 Topics Using Predefined Functions Programmer-Defined Functions Using Input.
CSC 421: Algorithm Design & Analysis
AP CSP: Creating Functions & Top-Down Design
Visit for more Learning Resources
CMSC201 Computer Science I for Majors Lecture 15 – Program Design
CMSC201 Computer Science I for Majors Lecture 15 – Program Design
CSC 421: Algorithm Design & Analysis
Lecture 2 Introduction to Programming
CMSC201 Computer Science I for Majors Lecture 11 – Program Design
Last Class We Covered The range() function Using for loops
CSC 421: Algorithm Design & Analysis
©2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Coding Concepts (Basics)
Last Class We Covered The range() function Using for loops
Algorithms, Part 3 of 3 Topics Top down-design Structure charts
Top-Down Design & JSP Skill Area Part D
Algorithms, Part 3 of 3 Topics Top down-design Reading
Functions, Procedures, and Abstraction
CMSC201 Computer Science I for Majors Lecture 12 – Program Design
Presentation transcript:

Program Design CMSC 201

Motivation We’ve talked a lot about certain ‘good habits’ we’d like you guys to get in while writing code. There are two main reasons for this: readability, adaptability.

Readability Having your code be readable is important, both for your sanity and someone else’s. Having highly readable code makes it easier to: Figure out what you’re doing while writing the code Figure out what the code is doing when you come back a year later Have other people read your code.

Readability Ways to improve readability: Comments Meaningful variable names Breaking code down into functions Following your own naming conventions Language choice File organization

Adaptability A lot of times, what a program is supposed to do evolves and changes as time goes on. Well written flexible programs can be easily altered to do something new, whereas rigid, poorly written programs take a lot of work to modify. When writing code, always take into account the fact that you might want to change / extend something later.

Adaptability: Example Remember how early in the class, we talked about not using “magic numbers”? Bad: def makeGrid(): temp = [] for i in range(0, 10): temp.appen([0] * 10) return temp Good: GRID_SIZE = 10 def makeGrid(): temp = [] for i in range(0, GRID_SIZE): temp.appen([0] * GRID_SIZE) return temp

Adaptability: Example GRID_SIZE = 10 def makeGrid(): temp = [] for i in range(0, GRID_SIZE): temp.appen([0] * GRID_SIZE) return temp Imagine in this program we use GRID_SIZE a dozen times or more, and we suddenly want a bigger or smaller grid. Or a variable sized grid. If we’ve left it as 10, it’s very hard to change. GRID_SIZE however is very easy to change. Our program is easier to adapt.

a problem is broken into parts those parts are solved individually the smaller solutions are assembled into a big solution Computer programmers use a divide and conquer approach to problem solving: These techniques are known as top-down design and modular development. Top Down Design It’s easier to solve small problems than big ones

Top-down design is the process of designing a solution to a problem by systematically breaking a problem into smaller, more manageable parts. Top Down Design

First, start with a clear statement of the problem or concept – a single big idea. Top Down Design

Next, break it down into several parts. Top Down Design

Next, break it down into several parts. If any of those parts can be further broken down, then the process continues… Top Down Design

… and so on. Top Down Design

… and so on. The final design might look something like this organizational chart, showing the overall structure of separate units that form a single complex entity. Top Down Design

An organizational chart is like an upside down tree, with nodes representing each process. Top Down Design

The bottom nodes represent modules that need to be developed and then recombined to create the overall solution to the original problem. Top-down design leads to modular development. Top Down Design

Modular development is the process of developing software modules individually… Modular Development

Modular development is the process of developing software modules individually… …then combining the modules to form a solution to an overall problem. Modular Development

Modular development of computer software: makes a large project more manageable is faster for large projects leads to a higher quality product makes it easier to find and correct errors increases the reusability of solutions Modular Development

… makes a large project more manageable. Smaller and less complex tasks are easier to understand than larger ones and are less demanding of resources. Modular Development

… is faster for large projects. Different people can work on different modules, and then put their work together. This means that different modules can be developed at the same time, which speeds up the overall project. Modular Development

…leads to a higher quality product. Programmers with knowledge and skills in a specific area, such as graphics, accounting, or data communications, can be assigned to the parts of the project that require those skills. Modular Development

…makes it easier to find and correct errors. Often, the hardest part of correcting an error in computer software is finding out exactly what is causing the error. Modular development makes it easier to isolate the part of the software that is causing trouble. Modular Development

… increases the reusability of solutions. Solutions to smaller problems are more likely to be useful elsewhere than solutions to bigger problems. They are more likely to be reusable code. Modular Development

Reusable code makes programming easier because you only need to develop the solution to a problem once; then you can call up that code whenever you need it. Most computer systems are filled with layers of short programming modules that are constantly reused in different situations. Modular Development

Modules developed as part of one project, can be reused later as parts of other projects, modified if necessary to fit new situations. Over time, libraries of software modules for different tasks can be created. Libraries of objects can be created using object-oriented programming languages. Modular Development

In Class Exercise What functions would you need to write a tic tac toe program that plays from the terminal? How would they interact? Draw a diagram!