CSC 212 – Data Structures Prof. Matthew Hertz WTC 207D / 888-2436

Slides:



Advertisements
Similar presentations
Introducing JavaScript
Advertisements

Chapter 1: Computer Systems
Internal Documentation Conventions. Kinds of comments javadoc (“doc”) comments describe the user interface: –What the classes, interfaces, fields and.
Utilities (Part 3) Implementing static features 1.
15-Jun-15 Beginning Style. 2 Be consistent! Most times, you will enter an ongoing project, with established style rules Follow them even if you don’t.
© The McGraw-Hill Companies, 2006 Chapter 9 Software quality.
16-Jun-15 javadoc. 2 Javadoc placement javadoc comments begin with /** and end with */ In a javadoc comment, a * at the beginning of the line is not part.
Object-Oriented Enterprise Application Development Javadoc Last Updated: 06/30/2001.
1 Doc Comment Conventions. 2 Write for your audience Rule 32: Write documentation for– those who must use your code Users should not need to care how.
Lecturer: Dr. AJ Bieszczad Chapter 76-1 Software engineering standards Standards for you Standards for others Matching design with implementation.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Java Software Solutions Foundations of Program Design Sixth Edition by Lewis.
Peter Andreae Computer Science Victoria University of Wellington Copyright: Peter Andreae, Victoria University of Wellington Review COMP 102 #
1 Web Based Programming Section 6 James King 12 August 2003.
Java: Chapter 1 Computer Systems Computer Programming II.
Javadoc. The Plan ● What is Javadoc? ● Writing Javadoc comments ● Using the Javadoc tool ● Demo ● Practice.
CSC 107 – Programming For Science. Announcements  Tutors available MTWR in WTC206/WTC208  Special lab (with Macs) & not in the Tutoring Center  Can.
COMP Flow of Control: Branching 2 Yi Hong May 19, 2015.
Goals of Course Introduction to the programming language C Learn how to program Learn ‘good’ programming practices.
07 Coding Conventions. 2 Demonstrate Developing Local Variables Describe Separating Public and Private Members during Declaration Explore Using System.exit.
Announcements  If you need more review of Java…  I have lots of good resources – talk to me  Use “Additional Help” link on webpage.
Program documentation using the Javadoc tool 1 Program documentation Using the Javadoc tool.
Board Activity Find your seat on the seating chart Login – Remember your login is your first initial your last name and the last three numbers of your.
School of Computer Science & Information Technology G6DICP - Lecture 9 Software Development Techniques.
/* Documentations */ Pre process / Linking statements Global declarations; main( ) { Local Declarations; Program statements / Executable statements; }
Week 91 Introduction to Programming Ms. Knudtzon C Period Quarter 2 – Lecture 20 Monday, November 1 st.
Problem of the Day  Why are manhole covers round?
Question of the Day  On a game show you’re given the choice of three doors: Behind one door is a car; behind the others, goats. After you pick a door,
SE: CHAPTER 7 Writing The Program
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 5: Software Design & Testing; Revision Session.
CSC 107 – Programming For Science. Announcements.
6/3/2016 CSI Chapter 02 1 Introduction of Flow of Control There are times when you need to vary the way your program executes based on given input.
Documentation and Programming Style Appendix A © 2015 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Software Documentation Section 5.5 ALBING’s Section JIA’s Appendix B JIA’s.
Lecture 2: Introduction to C Programming. OBJECTIVES In this lecture you will learn:  To use simple input and output statements.  The fundamental data.
CSC 107 – Programming For Science. History of C  Dennis Ritchie developed C from 1969 – 1973  While at Bell Labs, created language to develop Unix 
Javadoc A very short tutorial. What is it A program that automatically generates documentation of your Java classes in a standard format For each X.java.
Documentation Dr. Andrew Wallace PhD BEng(hons) EurIng
JavaDoc and Contracts Spring Documenting Contracts with JavaDoc Contract model for methods Preconditions Postconditions JavaDoc Industry standard.
Identifiers Identifiers in Java are composed of a series of letters and digits where the first character must be a letter. –Identifiers should help to.
Flow of Control and Program Style n Nested if statements n C++ struct n Program Style n Lab Exercise.
Javadoc. Purpose of javadoc javadoc is a program that reads your Java program and produces great-looking documentation in HTML format Without any help,
Program Style Chapter 22 IB103 Week 12 (part 2). Modularity: the ability to reuse code Encapsulation: hide data access directly but may use methods (the.
Javadoc. Purpose of javadoc  javadoc is a program that reads your Java program and produces great-looking documentation in HTML format  Without any.
CSC 213 – Large Scale Programming Prof. Matthew Hertz WTC 207D /
CSC Programming for Science Lecture 4: Beginning Programming.
CSC Programming for Science Lecture 10: Boolean Expressions & More If ­ Else Statements.
Page 1 – Autumn 2009Steffen Vissing Andersen SDJ I1, Autumn 2009 Agenda: Java API Documentation Code Documenting (in javadoc format) Debugging.
TCU CoSc Introduction to Programming (with Java) Java Language Overview.
1 Documenting with Javadoc CS 3331 Section and Appendix B of [Jia03] How to Write Doc Comments for the Javadoc TM Tool available from
Documentation Javadocs. Design/Documentation An essential ingredient of good Object Oriented programming is known as design by contract. This means that.
PHY 107 – Programming For Science. Announcements no magic formulas exist  Need to learn concepts: no magic formulas exist  Single solution not useful;
Variables in C Topics  Naming Variables  Declaring Variables  Using Variables  The Assignment Statement Reading  Sections
28-Feb-16 How to Write Good Comments. 2 Write for your audience Program documentation is for programmers, not end users There are two groups of programmers,
CMSC 104, Version 8/061L09VariablesInC.ppt Variables in C Topics Naming Variables Declaring Variables Using Variables The Assignment Statement Reading.
Eclipse Basics Create projects Debug Import/Export: s/import_export/
CSC 107 – Programming For Science. Announcements  Lectures may not cover all material from book  Material that is most difficult or challenging is focus.
Copyright © 2014 Pearson Addison-Wesley. All rights reserved. Chapter 2 C++ Basics.
CS/ENGRD 2110 FALL 2013 Lecture 3: Fields, getters and setters, constructors, testing 1.
1 2. Program Construction in Java. 01 Java basics.
1 Documenting with Javadoc How to Write Doc Comments for the Javadoc TM Tool available from java.sun.com.
L071 Introduction to C Topics Compilation Using the gcc Compiler The Anatomy of a C Program Reading Sections
More Sophisticated Behavior
Design by Contract Fall 2016 Version.
Chapter 1: Computer Systems
Introduction to Programming
JavaDoc and Contracts Fall 2008.
CISC124 Labs start this week in JEFF 155.
Variables in C Topics Naming Variables Declaring Variables
Presentation transcript:

CSC 212 – Data Structures Prof. Matthew Hertz WTC 207D /

Programming Environments Continue to use any system you wish  Examples in lectures, labs will use Eclipse Link available on course web page I may be able to burn CDs as well  I really like Eclipse and highly recommend it

Style Guide Good style helps when writing code  Program logic becomes easier to follow  Easier to read and fix errors  Much simpler to start & stop work on a project  Prevents many common errors Style includes two parts:  Formatting and other code issues: optional  Documentation: required

Indentation Always indent code within a set of braces Be consistent with size of indentation Nothing is more annoying than looking for the next line.

Indentation char _ [3141 ],__3141[3141];_314159[31415],_3141[31415];main(){register char* _3_141,*_3_1415, *_3__1415; register int _314,_31415,__31415,*_31, _3_14159,__3_1415;*_ =__31415=2,_ [0][_ ]=1[__3141]=5;__3_1415=1;do{_3_14159=_314=0,__ ;for( _31415 =0;_31415<(3,14-4)*__31415;_ )_31415[_3141]=_314159[_31415]= - 1;_3141[*_314159=_3_14159]=_314;_3_141=_ __3_1415;_3_1415= __3_1415 +__3141;for(_31415 = __3_1415 ;_31415;_ ,_3_141 ++,_3_1415++){_314 +=_314<<2 ;_314<<=1;_314+= *_3_1415;_31 =_ _314; if(!(*_31+1) )* _31 =_314 / __31415,_314 [_3141]=_314 % __31415 ;* ( _3__1415=_3_141 )+= *_3_1415 = *_31;while(* _3__1415 >= 31415/3141 ) * _3__1415+= - 10,(*--_3__1415 )++;_314=_314 [_3141]; if ( ! _3_14159 && * _3_1415)_3_14159 =1,__3_1415 = 3141-_31415;}if( _314+(__31415 >>1)>=__31415 ) while ( ++ * _3_141==3141/314 )*_3_141--=0 ;}while(_3_14159 ) ; { char * __3_14= "3.1415"; write((3,1) (--*__3_14,__3_14 ),(_3_ ,++_3_14159)) ; } for ( _31415 = 1; _31415< ;_ )write( 31415% 314-( 3,14),_ [ _31415 ] + " ","314" [ 3]+1)-_314; puts((*_ =0,_ )) ;_314= *" ";}

Braces Always use braces, even when not required by Java: for (int i = 0; i < n; i++); sum = sum + i; sumSquare = sumSquare + (i*i);

Braces Always use braces, even when not required by Java: for (int i = 0; i < n; i++); sum = sum + i; sumSquare = sumSquare + (i*i);

Increment/Decrement Operators Only use the ++ & -- operators on their own line (or in for loops) // What gets stored at each line while (++k < n) { a[i++] = (2 * i) + 6; b[j] = (j++ * j) - 1; c[j] = a[j] +++ b[j]; }

Statements Use variables to break up complex ideas // What is this computing? return ( (year % 4 == 0) && (year % 100 != 0)) || ( (year % 100 == 0) && (year % 400 == 0));

Statements Use variables to break up complex ideas divisibleBy4 = ((year % 4) == 0); divisible100 = ((year % 100) == 0); divisible400 = ((year % 400) == 0); return (divisible4 && !divisible100) || (divisible100 && divisible400);

Comments We write programs in “code”  It is not easy to read  It is difficult to simplify some ideas  Try reviewing your CSC 111 projects (or, even better, a friend’s CSC 111 project) Comments break up this code  Provide simple English descriptions  State assumptions and preconditions  Explain outcome of section of code

javadoc Tool included with most Java compilers Automatically generates web pages for a class from specially formatted comments  Includes space for every class, method, constructor, and field  Makes using classes much, much simpler  Requires little additional work

javadoc Comments Begin with /** and end at */ /** This is a javadoc comment */ Comment must immediately precede item  Good /** x-coordinate of bottom-left corner */ public int x;  Bad /** Example class that has no javadoc */ import java.util.*; public class JavadocError {... }

What To Say In javadoc Class  What the class does  How it should be used  (Author, when written, version number) Fields  Type of the field  What is stored in the field & how this is used  Assumptions about the field’s value

What To Say In javadoc Methods  Describe what the method will do  Explain what data will be return  List important preconditions  Explain significant postconditions  Any details you think users need to know  (Parameters, return value, exceptions)

More about comments javadoc is MINIMAL set of comments needed  Also include comments within methods  Describe how the method is supposed to work  Explain why this works  Makes your life easier when debugging!