CS 152 Computer Programming Fundamentals Coding Standards

Similar documents
CS 251 Intermediate Programming Coding Standards

CS 351 Design of Large Programs Coding Standards

CS 351 Design of Large Programs

Assignment Marking Criteria

Identifiers and Variables

CS 251 Intermediate Programming Methods and Classes

CS 251 Intermediate Programming Methods and More

Documentation Requirements Computer Science 2334 Spring 2016

CSE 11 Style Guidelines

Java Programming Style Guide

What does this program print?

Programming Syntax and Style. David Greenstein Monta Vista High School

CSE 142/143 Unofficial Style Guide

11 Coding Standards CERTIFICATION OBJECTIVES. Use Sun Java Coding Standards

CSCI 2101 Java Style Guide

Using C++, design an Abstract Data Type class named MyGrades. The class must have the following private members :

CS 1027b Foundations of Computer Science II Assignment 1: File Compression Due Date: February 5, 11:55 pm Weight: 10%

CSCI 1060U Programming Workshop

For the purposes of this course, the following coding guidelines are in effect.

Coding Style Handout #15 February 1, CS106A Winter

Expanded Guidelines on Programming Style and Documentation

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 3: SEP. 13TH INSTRUCTOR: JIAYIN WANG

Full file at

Chapter 2: Programming Concepts

CS 152: Data Structures with Java Hello World with the IntelliJ IDE

Java Program Coding Standards Programming for Information Technology

COMP 401 Midterm. Tuesday, Oct 18, pm-3:15pm. Instructions

CS 231 Data Structures and Algorithms, Fall 2016

CS 251 Intermediate Programming Java Basics

Lecture 27. Lecture 27: Regular Expressions and Python Identifiers

Supplement D: Expanded Guidelines on Programming Style and Documentation

D2: explain how the structure and design of a game can assist in maintenance and capacity for extension.

class objects instances Fields Constructors Methods static

Makefiles Makefiles should begin with a comment section of the following form and with the following information filled in:

1.00 Lecture 7. Classes

C++ Programming Style Guide

CMSC 201 Fall 2018 Python Coding Standards

COMP 111. Introduction to Computer Science and Object-Oriented Programming. Week 2

C++ Style Guide. 1.0 General. 2.0 Visual Layout. 3.0 Indentation and Whitespace

Enums. In this article from my free Java 8 course, I will talk about the enum. Enums are constant values that can never be changed.

CS106A, Stanford Handout #30. Coding Style

Beginning Style. 16-Nov-15

Java Style Guide. 1.0 General. 2.0 Visual Layout. Dr Caffeine

This course supports the assessment for Scripting and Programming Applications. The course covers 4 competencies and represents 4 competency units.

PROGRAMMING STYLE. Fundamentals of Computer Science I

Objectives. Coding Standards. Why coding standards? Elements of Java Style. Understand motivation for coding standards

Coding Standards for Java

Fall 2017 CISC124 9/16/2017

Variables in C. Variables in C. What Are Variables in C? CMSC 104, Fall 2012 John Y. Park

QueueBlock, ReversalADT, LinkedList,CustomerAccount, not MaintainCustomerData

CPS122 Lecture: Defining a Class

Fundamentals of Programming Session 25

Java Fall 2018 Margaret Reid-Miller

Note : Your program must contain the following 6 functions :

JOSE LUIS JUAREZ VIVEROS com) has a. non-transferable license to use this Student Guide

12/22/11. Java How to Program, 9/e. Help you get started with Eclipse and NetBeans integrated development environments.

CSCI 262 C++ Style Guide

ACORN.COM CS 1110 SPRING 2012: ASSIGNMENT A1

IT Web and Software Developer Software Development Standards

Coding Standard for ECE3090 August 24, 2005

Java objects: a first view [Reading: chapters 1 & 2] CSC 142 B 1

Lesson 1A - First Java Program HELLO WORLD With DEBUGGING examples. By John B. Owen All rights reserved 2011, revised 2015

5/3/2006. Today! HelloWorld in BlueJ. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont.

Chapter 2 Author Notes

Project #1 rev 2 Computer Science 2334 Fall 2013 This project is individual work. Each student must complete this assignment independently.

BASIC COMPUTATION. public static void main(string [] args) Fundamentals of Computer Science I

PROGRAM READABILITY. A program's readability readability, which is a measure of how

Software and Programming 1

Object Declaration. <class name>: the name of the class to which the object belongs <object name>: the name of the object (any valid identifier)

CT 229 Fundamentals of Java Syntax

BLM2031 Structured Programming. Zeyneb KURT

Lecture 02, Fall 2018 Friday September 7

CSCI 161: Introduction to Programming I Lab 1b: Hello, World (Eclipse, Java)

CS 4218 Software Testing and Debugging Ack: Tan Shin Hwei for project description formulation

Project 1. Java Control Structures 1/17/2014. Project 1 and Java Intro. Project 1 (2) To familiarize with

Identifiers. Identifiers are the words a programmer uses in a program Some identifiers are already defined. Some are made up by the programmer:

Last Time. University of British Columbia CPSC 111, Intro to Computation Alan J. Hu. Readings

Fundamentals of Programming Session 23

Programming Style Guide v1.1

Computational Expression

Week 7 - More Java! this stands for the calling object:

CIS220 In Class/Lab 1: Due Sunday night at midnight. Submit all files through Canvas (25 pts)

CSE 131 Introduction to Computer Science Fall Final Exam

4 Programming Fundamentals. Introduction to Programming 1 1

CS Problem Solving and Object-Oriented Programming

Mobile App:IT. Methods & Classes

Setting Up Your Dissertation Format Using MS Word2000. Overview of the Process

BIT Java Programming. Sem 1 Session 2011/12. Chapter 2 JAVA. basic

Introduction to Java. Java Programs Classes, Methods, and Statements Comments Strings Escape Sequences Identifiers Keywords

Project 1 Computer Science 2334 Spring 2016 This project is individual work. Each student must complete this assignment independently.

Comp151 Lab Documentation using Doxygen

User Interface Programming OOP/Java Primer. Step 3 - documentation

EE 382 Style Guide. March 2, 2018

Math Modeling in Java: An S-I Compartment Model

CS11 Java. Fall Lecture 1

Introduction to Computers, Programs, and Java. CSE 114, Computer Science 1 Stony Brook University

Objectives. Problem Solving. Introduction. An overview of object-oriented concepts. Programming and programming languages An introduction to Java

Software and Programming 1

Notes on Chapter Three

Variables in C. CMSC 104, Spring 2014 Christopher S. Marron. (thanks to John Park for slides) Tuesday, February 18, 14

Transcription:

CS 152 Computer Programming Fundamentals Coding Standards Brooke Chenoweth University of New Mexico Fall 2018

CS-152 Coding Standards All projects and labs must follow the great and hallowed CS-152 coding standards. These standards do not necessarily represent the best nor the only good way to write Java code. If you have experience programming, then these standards may not be the standards you are used to using. However, in this class, these are the standards we will use.

Primary Reasons for Defined Standard 1. A standard makes it easier for the instructors to read your code. 2. A class standard makes it easier for a grader to recognize when a program does not use a consistent standard. Often when each student is allowed to define his or her own standard, students switch standards multiple times in a single project. It is tedious for a grader to deduce each persons standard and then check for self-consistency. 3. It is good practice to learn to follow a standard.

Coding Standard: Naming Multi-word names are generally written in mixed-case (also known as camelcase). Internal words start with a capital letter. All variables not declared final shall begin with a lowercase letter. Variables that do not ever change value (that is, constants) shall be declared final and shall be all uppercase with words separated by underscores. All class and member variables (non-local variables) will be given descriptive names. Never use the single letter l nor the single letter O as a name.

Coding Standard: Naming Method names must be descriptive (usually verbs) and start with a lowercase letter. All class names shall be descriptive (usually nouns) and begin with an uppercase letter.

Coding Standard - Indenting Code blocks will be indented to show the block structure with four spaces per level. (Note: I often use only two spaces in order to fit on the slides. Do as I say, not as I do.) Tab characters shall not be used for indenting. All statements within a block must be indented to the same level.

Coding Standard: Brackets Open bracket is last non-space character on a line. Closing bracket begins a line and is indented to the beginning of the block. Exceptions: Empty/single statement class/method body. public class ExampleClass { private int mynumber ; } public static void main ( String [] args ) { // statements go here } private void emptymethod () {} private void singlestatementbody () { mynumber ++; }

Coding Standard Blocks and { } Whenever a structure spans more than one line, brackets must be used. For example: /* OK */ if (x == 5) y=y +1; /* OK */ if (x == 5) { y=y +1; } /* Not CS - 152 standard */ if (x == 5) y=y +1; /* OK */ if (x == 5) { y=y +1; }

Comments At the top of every.java file, there must be a Javadoc comment block with your name, a description of the what the class/interface is used for and how to use it. At the top of every method, there must be a Javadoc comment block describing what the method does, its parameters, and its return value. For more information on writing Javadoc comments, see the Javadoc conventions online.

Coding Standard 80 Character Line Max No line shall be more than 80 characters. The best way to avoid overly long statements is by not doing too much in a single statement.

Principle of Least Privilege In computer science, the Principle of Least Privilege requires that in a particular abstraction layer of a computing environment, every module must be able to access only such information and resources that are necessary for its legitimate purpose. Variables used in only one method shall be local variables. Don t make an instance or class variable public without good reason. (Note: I couldn t make it work otherwise is not a good reason!)

Write Self-Documenting Code Self-documenting code uses well-chosen names and has a clear style. The program s purpose and workings should be obvious to any programmer who reads the program, even if the program has no comments. To the extent that is possible, strive to make your programs self-documenting.

Java Code Conventions For examples of how to format specific constructs and guidance on issues not covered in these slides, see Java code conventions online.

Last Word... Use clean coding standards as you code. Of course, only the end product is graded; however, if you take the time to maintain proper indenting and formatting as you write your code, then you will find coding easier. When you show clean code to an instructor, the instructor is more likely to be friendly and will require less time to help you.