Designing with Procedures 1. Designing a Program with Procedures If the code for your program is going to be less than one page, normally don’t bother;

Slides:



Advertisements
Similar presentations
CDA 3100 Recitation Week 8. Question 1.data A:.word 21,3,2,9,100,22,6,15,33,90.text.globl main main: la $a0, A li $a1, 17 li $a2, 10 jal funct li $v0,
Advertisements

Chair of Software Engineering Concurrent Object-Oriented Programming Prof. Dr. Bertrand Meyer Exercise Session 1: Eiffel Introduction.
GATEKEEPER MOSTLY STATIC ENFORCEMENT OF SECURITY AND RELIABILITY PROPERTIES FOR JAVASCRIPT CODE Salvatore Guarnieri & Benjamin Livshits Presented by Michael.
Ways to Deal with Annoying People. Introduction Unfortunately, we can’t get along with everyone. And it’s a fact that throughout our life, we’ll be in.
Independent Reading By: Danelle Keninger.
Career Research, Pathways& Course Selection. What is EXPOED ? An internet based program for selecting courses based on career research and pathways.
Web Page Behavior IS 373—Web Standards Todd Will.
CSC 160 Computer Programming for Non-Majors Lecture #7: Variables Revisited Prof. Adam M. Wittenstein
1 CSE1301 Computer Programming: Lecture 25 Software Engineering 2.
Algorithm Programming Coding Advices Bar-Ilan University תשס " ו by Moshe Fresko.
Revising and Editing Checklist - Review
MEGS+ Michigan Electronic Grants System Plus Office of Special Education May 2012.
Study Tips for COP 4531 Ashok Srinivasan Computer Science, Florida State University Aim: To suggest learning techniques that will help you do well in this.
JS Arrays, Functions, Events Week 5 INFM 603. Agenda Arrays Functions Event-Driven Programming.
Progressive Overload.  Cause Long-Term Training adaptations  Applying a workload to an athlete to cause enough stress to continue to adapt  Ensuring.
Supply Unit 5.
Packages. Package A package is a set of related classes Syntax to put a class into a package: package ; public class { …} Two rules:  A package declaration.
Javadoc. The Plan ● What is Javadoc? ● Writing Javadoc comments ● Using the Javadoc tool ● Demo ● Practice.
Nachos Phase 1 Code -Hints and Comments
CMSC 104, Version 9/011 Incremental Programming Topics Review of Incremental Programming Example of Incremental Programming Reading None.
Extreme/Agile Programming Prabhaker Mateti. ACK These slides are collected from many authors along with a few of mine. Many thanks to all these authors.
CPSC 217 T03 Week I Part #1: Unix and HELLO WORLD Hubert (Sathaporn) Hu.
Meet Perl, Part 2 Flow of Control and I/O. Perl Statements Lots of different ways to write similar statements –Can make your code look more like natural.
Testing and Debugging Version 1.0. All kinds of things can go wrong when you are developing a program. The compiler discovers syntax errors in your code.
Low-Level Detailed Design SAD (Soft Arch Design) Mid-level Detailed Design Low-Level Detailed Design Design Finalization Design Document.
SE: CHAPTER 7 Writing The Program
CS 320 Assignment 1 Rewriting the MISC Osystem class to support loading machine language programs at addresses other than 0 1.
CS162B: Pipes Jacob T. Chan. Pipes  These allow output of one process to be the input of another process  One of the oldest and most basic forms of.
CS242.  Reduce Complexity  Introduce an intermediate, understandable abstraction  Avoid code duplication  Support subclassing  Hide sequences  Hide.
Preparing for Assignment 3. Setup Assignment 3 builds on Assignment 2, and we are using the same basic scenario. Save the spreadsheet you used for Assignment.
When you first log in, this is the page you will see. It lists all the courses you’re enrolled in – and differentiates between those that are active and.
Loops Robin Burke IT 130. Outline Announcement: Homework #6 Conditionals (review) Iteration while loop while with counter for loops.
M1G Introduction to Programming 2 3. Creating Classes: Room and Item.
1 COS 260 DAY 14 Tony Gauvin. 2 Agenda Questions? 6 th Mini quiz graded  Oct 29 –Chapter 6 Assignment 4 will be posted later Today –First two problems.
ASSIGNMENT 2 Salim Malakouti. Ticketing Website  User submits tickets  Admins answer tickets or take appropriate actions.
PHP (cont.). 2 Functions Definition – function name(arguments){... } –syntax name as for a variable, but without $ arguments as for variables –to return.
BIT 115: Introduction To Programming Professor: Dr. Baba Kofi Weusijana (say Doc-tor Way-oo-see-jah-nah, Doc-tor, or Bah-bah)
Toolbox Meetings What is a toolbox meeting? An informal 5 to 15 minute meeting held by supervisors used to promote safety.
Advanced Topics in Algorithms SPRING TERM PROJECT Is worth 40% of your final grade Completed project with report is due in week th May,
CMSC 104, Version 8/061L16IncrementalProg.ppt Incremental Programming Topics Review of Incremental Programming Example of Incremental Programming Reading.
Warm-up Program Use the same method as your first fortune cookie project and write a program that reads in a string from the user and, at random, will.
Lecture 25 More Synchronized Data and Producer/Consumer Relationship
Java Unit 11: Inheritance I
Introduction to Events
CSC 253 Lecture 8.
Software and Hardware Circular Buffer Operations
Chapter 6 Sub Procedures
CSC 253 Lecture 8.
VISUAL BASIC .NET Chapter 6 Assignment Sheet
Organize your code with MVC
Code Smells 1.
Post 16 Return SEPTEMBER 2012.
Incremental Programming
Lesson 5: Building an App: Clicker Game
Class Commenting Doxygen for Classes.
Programming in JavaScript
CSE 303 Concepts and Tools for Software Development
Refactoring Types Blake Duncan.
Herbert G. Mayer, PSU CS Status 8/2/2013
Parameter Sniffing: the Good, the Bad, and the Ugly
Add a dues payment to the Dues manager module for the Grand Lodge of Nebraska LSI Lodge Secretary Interface online Membership Database.
Overview of the Lab 2 Assignment: Multicore Real-Time Tasks
Parameter Sniffing: the Good,the Bad, and the Ugly
Programming in JavaScript
Parameter Sniffing: the Good, the Bad, and the Ugly
Post 16 Return SEPTEMBER 2011.
Java Lessons Mr. Kalmes.
Chapter (3) - Procedures
Refactoring.
Agenda for Unit 3: Functions
Presentation transcript:

Designing with Procedures 1

Designing a Program with Procedures If the code for your program is going to be less than one page, normally don’t bother; otherwise: List the major steps of the program. See if it makes sense to use a procedure for each major step Look for opportunities to use a procedure to avoid duplication of code 2

Information Sharing What information does each procedure need? What should the formal parameters be? What should the global variables be? What should be handled by local variables? Keep in mind that variables should be local unless there is a very good reason to make them global! 3

Procedure Specification For each procedure in your design, write a brief description of what it does, what global variables it changes, and what parameters it needs. If it is a function, include what value it returns Step through an execution of your process and make sure the information flow is correct Remember to develop tests before you write code! 4

Implementation DO NOT WRITE THE WHOLE PROGRAM AT ONCE!!!! You can write just one procedure, or just parts of a couple of procedures, and test them. Keep adding bits using your design as a guide until you have all the functionality. Write enough printing code as you go along to see what’s happening. If you have to write extra code, it will save you time in the long run. Or, step through. 5

Refactoring Rewriting existing code to improve it is a common operation Often features are added to a program incrementally and at some point it just gets too messy, unwieldy, and hard to understand Changing and improving the code structure is called refactoring 6

Example We’ll redo the IceCream V2 program using procedures. Your Assignment 4 is to do the same thing with your Assignment 3. Or, if you want to start fresh, you can adapt an alternative program, which is posted in the Week 4 folder A version of the procedurized Ice Cream program is posted on the website in the Week 4 folder. 7

Demo: Ice Cream Order with Procedures