Advanced Computer Science Lab Coding Style & Documentation.

Slides:



Advertisements
Similar presentations
PHP Reusing Code and Writing Functions.
Advertisements

Algorithms Series of mathematical or variable manipulations Integer a,b,c a = 12 b = 22 c = a * b (what is c?) 12 * 22 = 264.
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.
Documentation 1 Comprehending the present – Investing in the future.
Coding Standards A Presentation by Jordan Belone.
 Monday, 9/30/02, Slide #1 CS106 Introduction to CS1 Monday, 9/30/02  QUESTIONS (on HW02, etc.)??  Today: Libraries, program design  More on Functions!
Fall 2007CS 2251 Software Engineering Intro. Fall 2007CS 2252 Topics Software challenge Life-cycle models Design Issues Documentation Abstraction.
Program Commenting CS-212 Dick Steflik. Commentary Commentary are pieces of information included in a program’s source files to provide additional information.
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.
Concordia University Department of Computer Science and Software Engineering Click to edit Master title style ADVANCED PROGRAMING PRACTICES API documentation.
By: Mr. Baha Hanene Chapter 3. Learning Outcomes We will cover the learning outcome 02 in this chapter i.e. Use basic data-types and input / output in.
Java Programming, 2E Introductory Concepts and Techniques Chapter 2 Creating a Java Application and Applet.
Java Programming, 3e Concepts and Techniques Chapter 2 Creating a Java Application and Applet.
Javascript and the Web Whys and Hows of Javascript.
Advanced File Processing
1 Web Based Programming Section 6 James King 12 August 2003.
Chapter 3 Getting Started with C++
General Programming Introduction to Computing Science and Programming I.
CS0004: Introduction to Programming Variables – Strings.
JavaDoc1 JavaDoc DEPARTMENT OF COMPUTER SCIENCE AND SOFTWARE ENGINEERING CONCORDIA UNIVERSITY July 24, 2006 by Emil Vassev & Joey Paquet revision 1.2 –
Program documentation Using the Doxygen tool Program documentation1.
Creating your first C++ program
Programming With C.
Documentation and Comments. What’s a comment? A comment is a simple form of documentation. Documentation is text that you the programmer write to explain.
Advanced File Processing. 2 Objectives Use the pipe operator to redirect the output of one command to another command Use the grep command to search for.
Chapter Five Advanced File Processing Guide To UNIX Using Linux Fourth Edition Chapter 5 Unix (34 slides)1 CTEC 110.
Java Syntax and Style JavaMethods An Introduction to Object-Oriented Programming Maria Litvin Gary Litvin Copyright © 2003 by Maria Litvin, Gary Litvin,
Introduction to programming in the Java programming language.
Documentation and Programming Style Appendix A © 2015 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Algorithms  Problem: Write pseudocode for a program that keeps asking the user to input integers until the user enters zero, and then determines and outputs.
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
CSC 212 – Data Structures Prof. Matthew Hertz WTC 207D /
Javadoc. Purpose of javadoc javadoc is a program that reads your Java program and produces great-looking documentation in HTML format Without any help,
Javadoc. Purpose of javadoc  javadoc is a program that reads your Java program and produces great-looking documentation in HTML format  Without any.
Documentation and Style. Documentation and Comments  Programs should be self-documenting.  Use meaningful variable names.  Use indentation and white.
CMSC 1041 Introduction to C Creating your first C program.
4. Javascript M. Udin Harun Al Rasyid, S.Kom, Ph.D Lab Jaringan Komputer (C-307) Desain.
– Intermediate Perl 1/6/ Intermediate Perl - POD, parameters and configuration Intermediate Perl – Session 7 · POD –
Creating a Java Application and Applet
L071 Introduction to C Topics Compilation Using the gcc Compiler The Anatomy of a C Program Reading Sections
Dani Vainstein1 VBScript Session 8. Dani Vainstein2 What we learn last session? VBScript procedures. Sub procedures. Function Procedures. Getting data.
Problem Solving With C++ Doxygen Oct/Nov Introduction Doxygen is a documentation generator, a tool for writing software reference documentation.
GCSE COMPUTER SCIENCE Practical Programming using Python
Automatic Documentation Systems
Introduction to Computing Science and Programming I
Advanced Programing practices
CS170 – Week 1 Lecture 3: Foundation Ismail abumuhfouz.
Input and Output: I/O Finish reading chapters 1 and 2 of the text
Algorithms Problem: Write pseudocode for a program that keeps asking the user to input integers until the user enters zero, and then determines and outputs.
Introduction to C Topics Compilation Using the gcc Compiler
Introduction to C Topics Compilation Using the gcc Compiler
4. Javascript Pemrograman Web I Program Studi Teknik Informatika
Guide To UNIX Using Linux Third Edition
Software Testing and Maintenance Modifying Code
Chapter 1: Computer Systems
Class Commenting Doxygen for Classes.
Creating your first C program
Introduction to Programming
Documentation and Style
Advanced Programing practices
Beginning Style 27-Feb-19.
HTML: Pages and Tools.
Tutorial 10: Programming with javascript
Word Processing Software Photo credit: © 2007 JupiterImagesCorporation.
HTML Basics.
Introduction to Programming
CSCE-221 C++ Coding Standard/Guidelines
Presentation transcript:

Advanced Computer Science Lab Coding Style & Documentation

Indentation Tabs are 8 characters, so indentations are also 8 characters. if you need more than 3 levels of indentation you should fix your program.

Indentation Easy to read Used to warn when functions are nested too deep

Placing Braces preferred way ( Kernighan and Ritchie), is to put the opening brace last on the line, and put the closing brace first Functions:

Placing Braces Exceptions for closing bracket on its own line:

Naming C programmers do not use cute names like ThisVariableIsATemporaryCounter BUT rather “tmp” GLOBAL variables (to be used only if you _really_ need them) need to have descriptive names, as do global functions

Naming function that counts the number of active users GOOD:"count_active_users()" BAD:"cntusr()" LOCAL variable names ->short BAD: loop_counter GOOD: i or j

Functions Short & Sweet Max 1-2 screens of text (80x24) maximum length of a function is inversely proportional to the complexity and indentation level 5-10 local vars or something’s WRONG =>rethink, split in smaller pieces

Commenting Good Danger: over commenting DON’T explain HOW code works BUT WHAT it does (&WHY) Not too many comments inside function, BUT at the head

Classes- Suggestions public variables must begin with m like mFooVar (m=member) protected variables must begin with mt, like mtFooVar and methods with t, like tFooNum(). (t=protected) private variables must begin with mv, like mvFooVar and methods with v, like vFooLone(). (v stands=private)

Classes- Suggestions All public, protected and private variables must begin with uppercase after m like F in mFooVar. All pointer variables must be prefixed with p, like Public variables mpFooVar and methods like FooNum() Protected variables mtpFooVar and methods with t like tFooNum() Private variables mvpFooVar and methods with v like vFooNum()

Classes- Suggestions

You have made a mess… Use “indent” with "-kr -i8" (stands for "K&R, 8 character indents") See “man indent” for more Indent does not fix bad programming!

Documentation Style Standard C++ Comments -Allow maintenance of code by people not involved in its development. -Allow understanding of requirements, inputs and outputs, algorithms, and software design techniques, when reviewing code. -Allow understanding of code structure for purposes of reusability

Doxygen mainly extracted from the comments in header files description of a class is placed before the class statement (/**.... */ or ///… ) Can embed HTML @param > doxygen –g doxyfile.cfg > doxygen doxyfile.cfg