Lecture 5 - Organizing Programs and Data

Lecture 5 - Organizing Programs and Data - Organizing...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
Organizing Programs and Data Lecture 5 Hartmut Kaiser hkaiser@cct.lsu.edu http://www.cct.lsu.edu/˜hkaiser/fall_2011/csc1254.html
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Abstract We will discuss functions as the main means of organizing computation. We rework the student grades example to be more modularized. 9/6/2011, Lecture 5 CSC 1254, Fall 2011, Organizing Programs and Data 2
Background image of page 2
Programming Principle of the Day DRY - Don’t repeat yourself (DIE – Duplication is Evil) ▫ The probably single most fundamental tenet in programming is to avoid repetition. ▫ Many programming constructs exist solely for that purpose (e.g. loops, functions, classes, and more). ▫ As soon as you start repeating yourself - create a new abstraction. Every piece of knowledge must have a single, unambiguous, authoritative representation within a system (program) Tightly related to the Open/Closed Principle and the Liskov Substitution Principle http://en.wikipedia.org/wiki/Don%27t_repeat_yourself 9/6/2011, Lecture 5 CSC 1254, Fall 2011, Organizing Programs and Data 3
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Programming Principle of the Day I wish I had been taught more about the importance of variable and method naming in school. About writing code that speaks to the reader. Code that is clear and concise. Code that solves the problem in an efficient way but also communicates what it does and why from the perspective of the user. I wish I had been taught more about how to write components that could be changed without actually changing that specific code at all. I wish I had been taught more about polymorphism and composition. About how to structure applications not with a focus on reuse but on change. About why abstractions matter. I’ve written and seen code that is super DRY but that doesn’t contain a single abstraction and that group things in huge inheritance hierarchies. Code that is about as flexible and reusable as a sunken ship. http://joelabrahamsson.com/entry/the-dry-obsession 9/6/2011, Lecture 5 CSC 1254, Fall 2011, Organizing Programs and Data 4
Background image of page 4
Building a program Analysis ▫ Refine our understanding of the problem Think of the final use of our program Design ▫ Create an overall structure for the program Implementation ▫ Write code ▫ Debug ▫ Test Go through these stages repeatedly 9/6/2011, Lecture 5 CSC 1254, Fall 2011, Organizing Programs and Data 5
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Writing a program: Strategy What is the problem to be solved? Is the problem statement clear? Is the problem manageable, given the time, skills, and tools available? Try breaking it into manageable parts Do we know of any tools, libraries, etc. that might help? Yes, even this early: iostreams, vector, etc. Build a small, limited version solving a key part of the problem To bring out problems in our understanding, ideas, or tools Possibly change the details of the problem statement to make it manageable If that doesn’t work Throw away the first version and make another limited version
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 28

Lecture 5 - Organizing Programs and Data - Organizing...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online