Presentation is loading. Please wait.

Presentation is loading. Please wait.

Class 0: Review and Perspective. cis 335 Fall 2001 Barry Cohen Class info n Barry Cohen n n Office hours: W 3:15-4:40.

Similar presentations


Presentation on theme: "Class 0: Review and Perspective. cis 335 Fall 2001 Barry Cohen Class info n Barry Cohen n n Office hours: W 3:15-4:40."— Presentation transcript:

1 Class 0: Review and Perspective

2 cis 335 Fall 2001 Barry Cohen Class info n Barry Cohen n bcohen@cs.njit.edu bcohen@cs.njit.edu n Office hours: W 3:15-4:40 F 4:00-5:25 n www.cs.njit.edu/~bcohen/601 www.cs.njit.edu/~bcohen/601 n Text: Irvine, C++ And Object- Oriented Programming n Recommended: Schildt, C++ the Complete Reference

3 cis 335 Fall 2001 Barry Cohen Grading n 35% homework n 30% midterm n 35% final

4 cis 335 Fall 2001 Barry Cohen Homework n Include the following F student name F student ID F date F class and section F homework number n Homework must be handed in on or before the due date. Multiple pages must be stapled together. n You must hand in source code and program output. Programs must compile in VC++.

5 cis 335 Fall 2001 Barry Cohen Honesty policy n You may discuss class content and assignments with others. You may not present someone else’s work as your own. Any instance of cheating will be disciplined under NJIT rules.

6 cis 335 Fall 2001 Barry Cohen HW 0 n Due: Sept 13, 2002 n p 20, problems 1,2,3 n p 54, problem 1

7 cis 335 Fall 2001 Barry Cohen Life Cycle of a Program n Specification. Analyze and describe the problem. n Design. Choose your data structures and algorithms. n Coding. Translate the design into the programming language of your choice. n Debugging. Squash those pesky beasties. Test and squash some more. n Maintenance. More bug fixes. Add more features. Make friendlier and more efficient.

8 cis 335 Fall 2001 Barry Cohen What’s a Good Solution? n Correctness. Solve the problem that’s been posed. n Robustness. Handle the unexpected. n Modularity. Make it logical and reusable. n Clarity. Think clearly. Explain your thinking. n Can be maintained and extended.

9 cis 335 Fall 2001 Barry Cohen How to document n Precondition. Where are you starting from. n Invariant. What stays the same as you progress. n Progress. Show you’re not going in circles. n Post condition. Where you need to end up. n Use asserts.

10 cis 335 Fall 2001 Barry Cohen Pseudocode n High level summary n One line for each ‘idea’ n Example 1: ‘Read the initialization files’ n Example 2: ‘Perform a topological sort’

11 cis 335 Fall 2001 Barry Cohen Flowcharts n Make the logic visible. n Stop or start n Decide n Do

12 cis 335 Fall 2001 Barry Cohen Use Functions n A function is a unit of code. n The one-page rule. n Keep data private. n Clearly define inputs and outputs.

13 cis 335 Fall 2001 Barry Cohen Programming Style n Consistent indentation. Use white space. n Document. Give yourself credit. Use comments. n Descriptive names. Follow name conventions.

14 cis 335 Fall 2001 Barry Cohen Why Document? n Someone will read it - beginning with you. n Programs live longer than programmers. n Tells you where you need to go.

15 cis 335 Fall 2001 Barry Cohen Quick Review of C n Data types. int, double, char. C++: bool n Data structures. Arrays.

16 cis 335 Fall 2001 Barry Cohen Control Structures n if.. else n for loop n while loop n do loop n switch.. case

17 cis 335 Fall 2001 Barry Cohen Scope n Auto u Declared in function u Allocated on stack n Static u Declared outside function u Declared as static u Allocated permanently

18 cis 335 Fall 2001 Barry Cohen Pass by reference n In C++, you can pass by reference n Example: void swap(int & a, int & b) { int temp = x; x = y; y = temp; }

19 cis 335 Fall 2001 Barry Cohen Stream I/O Stream output: int n = 65; cout << n; Stream input: int n; cin >> n;

20 cis 335 Fall 2001 Barry Cohen Comments n Two kinds of comments /* This is a multiline comment. */ int n; // 1-line comment

21 cis 335 Fall 2001 Barry Cohen C, C++ n C++ is ‘C with classes’ n Class groups object with operations n Object is instance of a class n Example: class coin n Attributes: value, upside n Actions: flip, getValue


Download ppt "Class 0: Review and Perspective. cis 335 Fall 2001 Barry Cohen Class info n Barry Cohen n n Office hours: W 3:15-4:40."

Similar presentations


Ads by Google