Class 0: Review and Perspective - PowerPoint PPT Presentation

1 / 21
About This Presentation
Title:

Class 0: Review and Perspective

Description:

Class 0: Review and Perspective. cis 335 Fall 2001 Barry Cohen. Class info. Barry Cohen ... More bug fixes. Add more features. Make friendlier and more efficient. ... – PowerPoint PPT presentation

Number of Views:52
Avg rating:3.0/5.0
Slides: 22
Provided by: barry59
Category:

less

Transcript and Presenter's Notes

Title: Class 0: Review and Perspective


1
Class 0 Review and Perspective
2
Class info
  • Barry Cohen
  • bcohen_at_cs.njit.edu
  • Office hours W 315-440F 400-525
  • www.cs.njit.edu/bcohen/601
  • Text Irvine, C And Object-Oriented Programming
  • Recommended Schildt, C the Complete Reference

3
Grading
  • 35 homework
  • 30 midterm
  • 35 final

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.

5
Honesty policy
  • You may discuss class content and assignments
    with others. You may not present someone elses
    work as your own. Any instance of cheating will
    be disciplined under NJIT rules.

6
HW 0
  • Due Sept 13, 2002
  • p 20, problems 1,2,3
  • p 54, problem 1

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.

8
Whats a Good Solution?
  • Correctness. Solve the problem thats been posed.
  • Robustness. Handle the unexpected.
  • Modularity. Make it logical and reusable.
  • Clarity. Think clearly. Explain your thinking.
  • Can be maintained and extended.

9
How to document
  • Precondition. Where are you starting from.
  • Invariant. What stays the same as you progress.
  • Progress. Show youre not going in circles.
  • Post condition. Where you need to end up.
  • Use asserts.

10
Pseudocode
  • High level summary
  • One line for each idea
  • Example 1 Read the initialization files
  • Example 2 Perform a topological sort

11
Flowcharts
  • Make the logic visible.
  • Stop or start
  • Decide
  • Do

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

13
Programming Style
  • Consistent indentation. Use white space.
  • Document. Give yourself credit. Use comments.
  • Descriptive names. Follow name conventions.

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

15
Quick Review of C
  • Data types. int, double, char. C bool
  • Data structures. Arrays.

16
Control Structures
  • if .. else
  • for loop
  • while loop
  • do loop
  • switch .. case

17
Scope
  • Auto
  • Declared in function
  • Allocated on stack
  • Static
  • Declared outside function
  • Declared as static
  • Allocated permanently

18
Pass by reference
  • In C, you can pass by reference
  • Example
  • void swap(int a, int b)
  • int temp xx yy temp

19
Stream I/O
  • Stream output
  • int n 65
  • cout ltlt n
  • Stream input
  • int n
  • cin gtgt n

20
Comments
  • Two kinds of comments
  • /
  • This is a multiline comment.
  • /
  • int n // 1-line comment

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
Write a Comment
User Comments (0)
About PowerShow.com