1 / 21

Class 0: Review and Perspective

Class 0: Review and Perspective. Class info. Barry Cohen bcohen@cs.njit.edu Office hours: W 3:15-4:40 F 4:00-5:25 www.cs.njit.edu/~bcohen/601 Text: Irvine, C++ And Object-Oriented Programming Recommended: Schildt, C++ the Complete Reference. Grading. 35% homework 30% midterm 35% final.

Télécharger la présentation

Class 0: Review and Perspective

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Class 0: Review and Perspective

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

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

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

  5. Honesty policy • 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. cis 335 Fall 2001 Barry Cohen

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

More Related