Documentation and Style. Documentation and Comments  Programs should be self-documenting.  Use meaningful variable names.  Use indentation and white.

Slides:



Advertisements
Similar presentations
Variables in C Amir Haider Lecturer.
Advertisements

Classes  All code in a Java program is part of a class  A class has two purposes  Provide functions to do work for the programmer  Represent data.
1 CS1001 Lecture Overview Java Programming Java Programming.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 2 1 Chapter 2 Primitive.
Primitive Data Types and Operations. Introducing Programming with an Example public class ComputeArea { /** Main method */ public static void main(String[]
1 ICS103 Programming in C Lecture 4: Data Types, Operators & Expressions.
Primitive Data Types byte, short, int, long float, double char boolean Are all primitive data types. Primitive data types always start with a small letter.
CS 201 Functions Debzani Deb.
Slides prepared by Rose Williams, Binghamton University Chapter 1 Getting Started 1.3 The Class String.
Writing methods. Calling Methods nameOfMethod(parameters) if method returns something, use that value Math.pow(2, 3) returns 8 System.out.println(Math.pow(2,
1. 2 Chapter 1 Introduction to Computers, Programs, and Java.
Intro to CS – Honors I Documentation and Coding Style GEORGIOS PORTOKALIDIS
© The McGraw-Hill Companies, 2006 Chapter 1 The first step.
3.1 Documentation & Java Language Elements Purpose of documentation Assist the programmer with developing the program Assist other programers who.
Java Programming, Second Edition Chapter Four Advanced Object Concepts.
Primitive Data Types and Operations Identifiers, Variables, and Constants Primitive Data Types Byte, short, int, long, float, double, char, boolean Casting.
Chapter 2 Primitive Data Types and Operations F Introduce Programming with an Example  The MyInput class F Identifiers, Variables, and Constants F Primitive.
Programming Style and Documentation Objective(s) F To become familiar with Java Style and Documentation Guidelines.
Simple Programs from Chapter 2 Putting the Building Blocks All Together (corresponds with Chapter 2)
1 Chapter 2 Primitive Data Types and Operations F Introduce Programming with an Example  The MyInput class F Identifiers, Variables, and Constants F Primitive.
Java Data Types Data types, variable declaration, and initialization.
The Java Programming Language
/* Documentations */ Pre process / Linking statements Global declarations; main( ) { Local Declarations; Program statements / Executable statements; }
Java Syntax and Style JavaMethods An Introduction to Object-Oriented Programming Maria Litvin Gary Litvin Copyright © 2003 by Maria Litvin, Gary Litvin,
Scanf Reads in information from the keyboard Examples –scanf(“%d”, &number); –scanf(“%d%d”, &value1, &value2); WARNINGS! –Don’t forget the & (address of)
Introduction to C++ // Program description #include directives int main() { constant declarations variable declarations executable statements return.
IB Computer Science Unit 1 – Introduction to Java Variables.
C++ Basics C++ is a high-level, general purpose, object-oriented programming language.
Documentation and Programming Style Appendix A © 2015 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Anatomy.1 Anatomy of a Class & Terminology. Anatomy.2 The Plan Go over MoveTest.java from Big Java Basic coding conventions Review with GreeterTest.java.
Code Conventions Tonga Institute of Higher Education.
Classes Java and other Object-Orientated Programs or OOP are based on the creation and interaction of classes. Every program in Java has at least one class.
© 2011 Pearson Education, publishing as Addison-Wesley Tuesday After answering the questions after logging in, open BlueJ and the Formula class.
Anatomy of a Java Program. AnotherQuote.java 1 /** A basic java program 2 * 3 Nancy Harris, James Madison University 4 V1 6/2010.
1 Basic Java Constructs and Data Types – Nuts and Bolts Looking into Specific Differences and Enhancements in Java compared to C.
A Simple Java Program //This program prints Welcome to Java! public class Welcome { public static void main(String[] args) { public static void main(String[]
1 Week 5 l Primitive Data types l Assignment l Expressions l Documentation & Style Primitive Types, Assignments, and Expressions.
Liang, Introduction to Java Programming, Ninth Edition, (c) 2013 Pearson Education, Inc. All rights reserved. 1 Chapter 1 Introduction to Computers, Programs,
Computer Programming with Java Chapter 2 Primitive Types, Assignment, and Expressions.
1 Class and Object Lecture 7. 2 Classes Classes are constructs that define objects of the same type. A Java class uses instance variables to define data.
Variables in C Topics  Naming Variables  Declaring Variables  Using Variables  The Assignment Statement Reading  Sections
Variables in C Topics  Naming Variables  Declaring Variables  Using Variables  The Assignment Statement Reading  Sections
CMSC 104, Version 8/061L09VariablesInC.ppt Variables in C Topics Naming Variables Declaring Variables Using Variables The Assignment Statement Reading.
1 Lecture # 2. * Introducing Programming with an Example * Identifiers, Variables, and Constants * Primitive Data Types * Byte, short, int, long, float,
© 2011 Pearson Education, publishing as Addison-Wesley Chapter 1: Computer Systems Presentation slides for Java Software Solutions for AP* Computer Science.
Chapter 2 Variables and Constants. Objectives Explain the different integer variable types used in C++. Declare, name, and initialize variables. Use character.
The Essentials of a Java Program JavaMethods An Introduction to Object-Oriented Programming Maria Litvin Gary Litvin Copyright © 2003 by Maria Litvin,
DEFINITION Java IDE created by Xinox Software JCreator is a powerful interactive development environment (IDE) for Java technologies. A Java compiler.
Chapter 1 Introduction to Computers, Programs, and Java
ICS103 Programming in C Lecture 4: Data Types, Operators & Expressions
FUNDAMENTALS OF JAVA.
Statements, Comments & Simple Arithmetic
2.1 Parts of a C++ Program.
Variables in C Topics Naming Variables Declaring Variables
Unit-1 Introduction to Java
Chapter 1: Computer Systems
CMSC 202 Java Primer 2.
Documentation and Style
Anatomy of a Java Program
Lecture Notes - Week 2 Lecture-1. Lecture Notes - Week 2 Lecture-1.
Chap 2. Identifiers, Keywords, and Types
Chapter 2 Primitive Data Types and Operations
Variables in C Topics Naming Variables Declaring Variables
CSCE-221 C++ Coding Standard/Guidelines
Variables in C Topics Naming Variables Declaring Variables
Variables in C Topics Naming Variables Declaring Variables
Variables and Constants
Variables in C Topics Naming Variables Declaring Variables
Presentation transcript:

Documentation and Style

Documentation and Comments  Programs should be self-documenting.  Use meaningful variable names.  Use indentation and white space to show program structure (jGRASP does most of this automatically)  Use comments to explain what the program is doing.

Comments in Java  Anything following a double slash ( // ) on a line is considered a comment, e.g., double radius; //in inches  Anything between the symbols /* and */, no matter how many lines are included, is considered to be a comment, e.g., /*This is a comment */

Program Comment Header  It’s good to put a comment header block at the beginning of each separately compilable piece of code. For example, for this class you might have a header like the following: /* Purpose: to determine the area of a circle Author: Jane Q. Programmer Address: Programming Assignment: #3 Last Changed: September 1, 2009 */

Placement of Brackets and Indentation  One convention for the placement of brackets is the one used in our textbook (example).example  A second convention is to line up the open and close brackets in the same column (example).example  The code inside each set of brackets is indented.

Naming Constants  Place the keywords public static final in front of the declaration setting the value of the constant, e.g., public static final double PI = ;  By convention constants are named using all capital letters.