Lecture 7 - Organizing Programs and Data (2)

Lecture 7 - Organizing Programs and Data (2) - Organizing...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Organizing Programs and Data 2 Lecture 7 Hartmut Kaiser hkaiser@cct.lsu.edu http://www.cct.lsu.edu/hkaiser/fall_2011/csc1254.html Programming Principle of the Day Abstraction Principle Related to DRY as it aims to reduce duplication Each significant piece of functionality in a program should be implemented in just one place in the source code. The basic mechanism of control abstraction is a function or subroutine. Data abstractions include various forms of type polymorphism. http://en.wikipedia.org/wiki/Abstraction_principle_(programming) 9/15/2011, Lecture 7 CSC 1254, Fall 2011, Organizing Programs and Data (2) 2 Abstract We will discuss data structures as the main means of organizing data. We extend the student grades example to work with more than one students grades. We will introduce the concept of partitioning the program into several files, separate compilation, and linking. 9/15/2011, Lecture 7 CSC 1254, Fall 2011, Organizing Programs and Data (2) 3 Language technicalities Are a necessary evil A programming language is a foreign language When learning a foreign language, you have to look at the grammar and vocabulary Because: Programs must be precisely and completely specified A computer is a very stupid (though very fast) machine A computer cant guess what you really meant to say (and shouldnt try to) So we must know the rules Some of them (the C++ standard is 782 pages) However, never forget that What we study is programming Our output is programs/systems A programming language is only a tool 9/15/2011, Lecture 7 CSC 1254, Fall 2011, Organizing Programs and Data (2) 4 Technicalities Dont spend your time on minor syntax and semantic issues. There is more than one way to say everything Just like in English Most design and programming concepts are universal, or at least very widely supported by popular programming languages So what you learn using C++ you can use with many other languages Language technicalities are specific to a given language But many of the technicalities from C++ presented here have obvious counterparts in C, Java, C#, etc. 9/15/2011, Lecture 7 CSC 1254, Fall 2011, Organizing Programs and Data (2) 5 Organizing Data Lets revise student grades program for a whole course (many students) Read grades from a file: Smith 93 91 47 90 92 73 100 87 Carpenter 75 90 87 92 93 60 0 98 We want to produce output (overall grade) Carpenter 90.4 Smith 86.8 Alphabetical, formatting vertically lining up 9/15/2011, Lecture 7 CSC 1254, Fall 2011, Organizing Programs and Data (2) 6 Organizing Data Need to store all student data Sorted by name Line up: find longest name Lets assume we can store all data about one student (student_info) All students data: vector<student_info> Set of auxiliary functions to work with that data Solve the overall problem using those 9/15/2011, Lecture 7 CSC 1254, Fall 2011, Organizing Programs and Data (2) 7 Organizing Data...
View Full Document

This note was uploaded on 12/29/2011 for the course CSC 1254 taught by Professor Blanks,l during the Fall '08 term at LSU.

Page1 / 27

Lecture 7 - Organizing Programs and Data (2) - Organizing...

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

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