Principles of Program Design What should be taught in core programming curricula.

Slides:



Advertisements
Similar presentations
Michael Alves, Patrick Dugan, Robert Daniels, Carlos Vicuna
Advertisements

1 ICS102: Introduction To Computing King Fahd University of Petroleum & Minerals College of Computer Science & Engineering Information & Computer Science.
Overview of Programming and Problem Solving ROBERT REAVES.
Programming Languages Marjan Sirjani 2 2. Language Design Issues Design to Run efficiently : early languages Easy to write correctly : new languages.
File Management Chapter 12. File Management A file is a named entity used to save results from a program or provide data to a program. Access control.
Object Oriented Design An object combines data and operations on that data (object is an instance of class) data: class variables operations: methods Three.
© Janice Regan, CMPT 102, Sept CMPT 102 Introduction to Scientific Computer Programming The software development method algorithms.
1 Programming for Engineers in Python Autumn Lecture 5: Object Oriented Programming.
Iterators T.J. Niglio Computer & Systems Engineering Fall 2003 Software Design & Documentation Object Behavioral.
CS 501: Software Engineering Fall 2000 Lecture 16 System Architecture III Distributed Objects.
Chapter 1 Assuming the Role of the Systems Analyst
CPSC-608 Database Systems Fall 2011 Instructor: Jianer Chen Office: HRBB 315C Phone: Notes #11.
Introduction to Computer Programming CSC 1401: Introduction to Programming with Java Lecture 2 Wanda M. Kunkle.
Chapter 2: Impact of Machine Architectures What is the Relationship Between Programs, Programming Languages, and Computers.
Chapter 1 Introduction to C Programming. 1.1 INTRODUCTION This book is about problem solving with the use of computers and the C programming language.
1 CMSC 132: Object-Oriented Programming II Nelson Padua-Perez William Pugh Department of Computer Science University of Maryland, College Park.
IEG 3080 Tutorial 1 Wilson Ip. Outline Lecture reviews: Some basics of Software Engineering principle Some basics of OOP How to use Visual Studio.NET.
1 ES 314 Advanced Programming Lec 2 Sept 3 Goals: Complete the discussion of problem Review of C++ Object-oriented design Arrays and pointers.
An Introduction to Software Engineering
Computational Thinking Related Efforts. CS Principles – Big Ideas  Computing is a creative human activity that engenders innovation and promotes exploration.
Your Interactive Guide to the Digital World Discovering Computers 2012.
CS-EE 481 Spring Founders Day, 2005 University of Portland School of Engineering Project Pocket Gopher Conversational Learning Agent Team Josh Jones.
Introduction to Computational Thinking Vicky Chen.
สาขาวิชาเทคโนโลยี สารสนเทศ คณะเทคโนโลยีสารสนเทศ และการสื่อสาร.
An Introduction to Software Architecture
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 1 Slide 1 An Introduction to Software Engineering.
1 ECE 453 – CS 447 – SE 465 Software Testing & Quality Assurance Instructor Kostas Kontogiannis.
Putting together a complete system Chapter 10. Overview  Design a modest but complete system  A collection of objects work together to solve a problem.
An Introduction to Java Chapter 11 Object-Oriented Application Development: Part I.
Chapter 06 (Part I) Functions and an Introduction to Recursion.
CSE 331 SOFTWARE DESIGN & IMPLEMENTATION MIDTERM REVIEW Autumn 2011.
1 CS 350 Data Structures Chaminade University of Honolulu.
ISBN Chapter 3 Describing Semantics -Attribute Grammars -Dynamic Semantics.
Cohesion and Coupling CS 4311
 2007 Pearson Education, Inc. All rights reserved C Functions -Continue…-
IXA 1234 : C++ PROGRAMMING CHAPTER 1. PROGRAMMING LANGUAGE Programming language is a computer program that can solve certain problem / task Keyword: Computer.
Objective At the conclusion of this chapter you will be able to:
ECE450 - Software Engineering II1 ECE450 – Software Engineering II Today: Design Patterns IX Interpreter, Mediator, Template Method recap.
(c) University of Washington01-1 CSC 143 Java Programming as Modeling Reading: Ch. 1-6.
Chapter 1 1 Lecture # 1 & 2 Chapter # 1 Databases and Database Users Muhammad Emran Database Systems.
NQT Conference 30 th January 2015 Using Programming to Develop Children’s Mathematical Understanding Richard English Faculty of Education
Introduction to Software Engineering. Why SE? Software crisis manifested itself in several ways [1]: ◦ Project running over-time. ◦ Project running over-budget.
ECE450 - Software Engineering II1 ECE450 – Software Engineering II Today: Introduction to Software Architecture.
Behavioral Patterns CSE301 University of Sunderland Harry R Erwin, PhD.
Distributed Models for Decision Support Jose Cuena & Sascha Ossowski Pesented by: Gal Moshitch & Rica Gonen.
Scientific Debugging. Errors in Software Errors are unexpected behaviors or outputs in programs As long as software is developed by humans, it will contain.
Week 3: Requirement Analysis & specification
Design Patterns Software Engineering CS 561. Last Time Introduced design patterns Abstraction-Occurrence General Hierarchy Player-Role.
1 Technical & Business Writing (ENG-715) Muhammad Bilal Bashir UIIT, Rawalpindi.
 Programming - the process of creating computer programs.
An Introduction to Software Engineering. Objectives  To introduce software engineering and to explain its importance  To set out the answers to key.
Main tasks of system analysis ? 1-study exit=sting information system 2-identify problem 3-spelify system requirement 4-asalysis decision ========= How.
Chapter – 8 Software Tools.
Test Automation Steffen Goerlitz Barry Lange Mitchell Meerman Harry Schultz Trevor Spees.
Operating Systems A Biswas, Dept. of Information Technology.
서울대한양대 ( 안 산 ) 충남대 1년1년 컴퓨터기초 (C) 컴퓨터프로그래밍 (C, Java) 컴퓨터프로그래밍 (C) 2. 봄 프로그래밍 원리 (Scheme, ML) Structure & Interpretation of Computer Programs 프로그래밍 방법론.
Chapter 1 Assuming the Role of the Systems Analyst.
Wrap up. Structures and views Quality attribute scenarios Achieving quality attributes via tactics Architectural pattern and styles.
© 2017 by McGraw-Hill Education. This proprietary material solely for authorized instructor use. Not authorized for sale or distribution in any manner.
Sub-fields of computer science. Sub-fields of computer science.
Advanced Computer Systems
Chapter 2: The Visual Studio .NET Development Environment
Testing Tutorial 7.
Chapter 5 – Requirements Engineering
Operating System Interface between a user and the computer hardware
C++ Classes & Object Oriented Programming
13 Text Processing Hongfei Yan June 1, 2016.
Software Architecture
Introduction to Computer Science for Majors II
Decidability continued….
Presentation transcript:

Principles of Program Design What should be taught in core programming curricula

Basic Principles Design the data first and let the structure of the data guide the structure of the code. Design for unit testing. Document all code with contracts. Avoid mutation. Avoid duplicating code [use patterns]. Look for higher-order solutions (code as data). Simpler is better, if it meets requirements. In OO programs, maximize polymorphism.

Relationship to Extreme Programming XP only mandates  Design for unit testing  Simpler is better XP focuses on program evolution rather than program structure XP program evolution must be guided by intelligent design; otherwise the resulting code will be ugly

Design Principles To Supplement XP Data Directed Design  Taught in Comp 210  Key observation: most program data types have natural formulations as free term (word) algebras which are represented in OO languages using the composite pattern. Aside: free term algebras are simply context free grammars that define trees rather than strings.

Design Principles To Supplement XP Document code with contracts when feasible Why? So that the intended behavior of the code can be understood without reading the code. Reverse engineering contracts from code is extremely difficult and error-prone. Unit tests (examples) can help, but good contracts are equally important. Partial contracts are better than no contracts.

Design Principles To Supplement XP Avoid Mutation.  Mutating data breaks algebraic laws that we take for granted such as “substituting equals for equals”.  If a method uses mutation, it can potentially modify any accessible object. Hence, it is difficult to determine if calling such a method can break a given program invariant.  In the absence of mutation, objects can safely be shared (rather than copied). Example: DAG tree representations.  Objects subject to mutation cannot be used in contexts that depend on immutable values such as hash table keys.  In multi-threaded programs, access to immutable data does not need not be synchronized

When Mutation is Justified When execution recapitulates evolution. Many programs model processes that change over time (physical simulations, financial transactions, etc.). The data representing entities in the model changes as the modeled entities change. Examples:  Solving a time dependent partial differential equation  Banking software  Document editor

When Mutation Is Justified (cont.) When faster algorithms require mutation. Examples:  Depth-first searching of a DAG.  Memo-ization of a recursively defined function (dynamic programming from a functional perspective)  Avoiding recopying when attributing a tree, as in a compiler.

When Mutation is Justified (cont.) When the most accurate data model requires circularity.  Example: Josephus problem (see Knuth, The Art of Computer Programming, Volume 1: Fundamental Algorithms) You cannot build circular structures without performing mutation.

When Mutation is Justified (cont.) When instrumenting a program. Examples:  Inserting print statements to log debugging output.  Maintaining event counters. (How many times is a particular constructor called?) Note that instrumentation involves modeling the execution of a program, a process that unfolds in time. Hence, this justification is really a special case of “execution recapitulating evolution”.

When Mutation is Justified (cont.) When interacting with hardware (e.g., controlling devices via device registers) When interacting with agents external to the program. Some interactions can be modeled using lazy functional programming, e.g., interaction involving console input and output. But this form of modeling does not address external persistent data structures like file systems.

Use Closures To Represent Dynamic Behavior