Documentation and Style

Slides:



Advertisements
Similar presentations
Variables in C Amir Haider Lecturer.
Advertisements

CS324e - Elements of Graphics and Visualization A Little Java A Little Python.
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.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 2 1 Chapter 2 Primitive.
LESSON 3 - Identifiers JAVA PROGRAMMING. Identifiers All the Java components —classes, variables, and methods— need names. In Java these names are called.
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,
Intro to CS – Honors I Documentation and Coding Style GEORGIOS PORTOKALIDIS
Chapter 2 Classes and Methods I Lecture Slides to Accompany An Introduction to Computer Science Using Java (2nd Edition) by S.N. Kamin, D. Mickunas, E.
© The McGraw-Hill Companies, 2006 Chapter 1 The first step.
Introduction to C++ Programming Introduction to C++ l C is a programming language developed in the 1970's alongside the UNIX operating system. l C provides.
Programming Style and Documentation Objective(s) F To become familiar with Java Style and Documentation Guidelines.
1 Chapter 2 Primitive Data Types and Operations F Introduce Programming with an Example  The MyInput class F Identifiers, Variables, and Constants F Primitive.
The Java Programming Language
CSC204 – Programming I Lecture 4 August 28, 2002.
Classes CS 21a: Introduction to Computing I First Semester,
/* 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.
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.
Documentation and Style. Documentation and Comments  Programs should be self-documenting.  Use meaningful variable names.  Use indentation and white.
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.
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,
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.
Copyright © Texas Education Agency, Computer Programming Variables and Data Types.
Topic: Python’s building blocks -> Variables, Values, and Types
Introduction to Programming
Chapter 1 Introduction to Computers, Programs, and Java
Input and Output: I/O Finish reading chapters 1 and 2 of the text
ICS103 Programming in C Lecture 4: Data Types, Operators & Expressions
Topic: Python’s building blocks -> Variables, Values, and Types
FUNDAMENTALS OF JAVA.
Program Style Console Input and Output
2.1 Parts of a C++ Program.
مساق: خوارزميات ومبادئ البرمجة الفصل الدراسي الثاني 2016/2015
Variables in C Topics Naming Variables Declaring Variables
Unit-1 Introduction to Java
Chapter 1: Computer Systems
CMSC 202 Java Primer 2.
Variables in C Topics Naming Variables Declaring Variables
Statements and expressions - java
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 to show program structure. 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 E-mail Address: jqprogrammer@csun.edu Programming Assignment: #3 Last Changed: January 6, 2006 */

Placement of Brackets and Indentation One convention for the placement of brackets was demonstrated in the code examples in Programming Project #1. A second convention is used in the textbook. In this approach the matching brackets are lined up in the same column. 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 int PI = 3.14159; By convention constants are named using all capital letters.