Program Commenting CS-212 Dick Steflik. Commentary Commentary are pieces of information included in a program’s source files to provide additional information.

Slides:



Advertisements
Similar presentations
Etter/Ingber Engineering Problem Solving with C Fundamental Concepts Chapter 4 Modular Programming with Functions.
Advertisements

Introduction to C Programming
C Functions. What are they? In general, functions are blocks of code that perform a number of pre-defined commands to accomplish something productive.
C Language.
Programming Paradigms Introduction. 6/15/2005 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved. L1:
Programming with Java. Problem Solving The purpose of writing a program is to solve a problem The general steps in problem solving are: –Understand the.
Code Documentation. Important!  It’s for you  It’s for others.
Functions ROBERT REAVES. Functions  Interface – the formal description of what a subprogram does and how we communicate with it  Encapsulation – Hiding.
Overview Reference parameters Documenting functions A game of craps. Design, code, test and document.
Documentation 1 Comprehending the present – Investing in the future.
1 Engineering Problem Solving With C++ An Object Based Approach Chapter 5 Functions.
Software Engineering and Design Principles Chapter 1.
 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!
CHAPTER 6 Stacks. 2 A stack is a linear collection whose elements are added and removed from one end The last element to be put on the stack is the first.
 2007 Pearson Education, Inc. All rights reserved C++ as a Better C; Introducing Object Technology.
C++ fundamentals.
CMSC 104, Version 8/061L18Functions1.ppt Functions, Part 1 of 4 Topics Using Predefined Functions Programmer-Defined Functions Using Input Parameters Function.
CH07: Writing the Programs Does not teach you how to program, but point out some software engineering practices that you should should keep in mind as.
Nyhoff, ADTs, Data Structures and Problem Solving with C++, Second Edition, © 2005 Pearson Education, Inc. All rights reserved Software.
Object Oriented Data Structures
Fruitful functions. Return values The built-in functions we have used, such as abs, pow, int, max, and range, have produced results. Calling each of these.
Chapter 3 Getting Started with C++
Operator Precedence First the contents of all parentheses are evaluated beginning with the innermost set of parenthesis. Second all multiplications, divisions,
GCSE OCR 3 A451 Computing Professional standards
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
Chapter 6: Modularity Using Functions. In this chapter, you will learn about: – Function and parameter declarations – Returning a single value – Returning.
Object Orientation “Thinking” Object Oriented, Further Constraints, and Documentation.
Introduction to C++ Systems Programming. Systems Programming: Introduction to C++ 2 Systems Programming: 2 Introduction to C++  Syntax differences between.
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.
David Streader Computer Science Victoria University of Wellington Copyright: David Streader, Victoria University of Wellington Java Programing Basics COMP.
David Streader Computer Science Victoria University of Wellington Copyright: David Streader, Victoria University of Wellington Java Programing Basics COMP.
111 Protocols CS 4311 Wirfs Brock et al., Designing Object-Oriented Software, Prentice Hall, (Chapter 8) Meyer, B., Applying design by contract,
Oct 15, 2007Sprenkle - CS1111 Objectives Creating your own functions.
Object Orientation “Thinking” Object Oriented, Further Constraints, and Documentation.
Advanced Computer Science Lab Coding Style & Documentation.
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
Copyright 2004 Scott/Jones Publishing Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 7 Structured Data and Classes.
CPS120: Introduction to Computer Science Decision Making in Programs.
CPS120: Introduction to Computer Science Functions.
CPS120: Introduction to Computer Science Lecture 14 Functions.
Chapter 7 Functions. Types of Functions Value returning Functions that return a value through the use of a return statement They allow statements such.
1 A simple C++ program // ======================================================= // File:helloworld.cpp // Author:Vana Doufexi // Date:1/4/2006 // Description:Displays.
Lecture 6: Writing the Project Documentation Part IV.
Chapter 3 Top-Down Design with Functions Part II J. H. Wang ( 王正豪 ), Ph. D. Assistant Professor Dept. Computer Science and Information Engineering National.
Protocols Software Engineering II Wirfs Brock et al, Designing Object-Oriented Software, Prentice Hall, Mitchell, R., and McKim, Design by Contract,
(3-1) Functions II H&K Chapter 3 Instructor - Andrew S. O’Fallon CptS 121 (September 9, 2015) Washington State University.
Copyright © 2002 Delmar Thomson Learning Chapter 14 Documenting Your PLC System.
INLS 560 – F UNCTIONS Instructor: Jason Carter.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Brief Edition Chapter 6 Functions.
Chapter 11: Advanced Inheritance Concepts. Objectives Create and use abstract classes Use dynamic method binding Create arrays of subclass objects Use.
In this class, we will cover: Overriding a method Overloading a method Constructors Mutator and accessor methods The import statement and using prewritten.
Creating Java Applications (Software Development Life Cycle) 1. specify the problem requirements - clarify 2. analyze the problem - Input? Processes? Output.
Introduction to Algorithmic Processes CMPSC 201C Fall 2000.
Testing It is much better to have a plan when testing your programs than it is to just randomly try values in a haphazard fashion. Testing Strategies:
Variable Scope & Lifetime
Unit 2 Technology Systems
CS Data Structures Chapter 6 Stacks Mehmet H Gunes
Popping Items Off a Stack Using a Function Lesson xx
Coupling and Cohesion Rajni Bhalla.
ANNOUNCEMENT The missed lecture will be made up this Monday evening in the Tech PC classroom (MG51). A tentative time interval is 6:30-8:00. The exact.
Introduction to C++ Systems Programming.
About the Presentations
User-Defined Functions
2011/11/20: Lecture 15 CMSC 104, Section 4 Richard Chang
Stack Lesson xx   This module shows you the basic elements of a type of linked list called a stack.
Stack ADT & Modularity 2 implementations of the Stack abstract data type: Array Linked List Program design: modularity, abstraction and information hiding.
User-defined Functions
User-defined Functions
Assertions References: internet notes; Bertrand Meyer, Object-Oriented Software Construction; 4/25/2019.
Functions Students should understand the concept and basic mechanics of the function call/return pattern from CS 1114/2114, but some will not. A function.
Presentation transcript:

Program Commenting CS-212 Dick Steflik

Commentary Commentary are pieces of information included in a program’s source files to provide additional information about; –what the program does textual description of –how it does it information about non-trivial aspects of the program –inputs & outputs data required for operation and information produced –who wrote it author & maintenance –release information –copyright information who owns the IP (Intellectual Property)

Comment Characters multi-line comments –must be included between /* and */ –used mostly for information blocks such as header blocks for programs and functions single line comments –preceded with // characters –used in-line usually preceding a program control statement end-of-line comments – precede with // –used mostly for data definition, explaining variable use (program and state)

Target Audience maintenance programmers –maintain a program throughout its lifecycle, leave a paper trail of everyone that has worked on a program and what they did software engineers –to design programs and interfaces to programs auditors –not programmers, have programs to strip away code and leave the comments, used to insure specification compliance application programmers –to figure out how to use reuseable packages (ex. math.h)

Header Comments in.c files comments at the beginning of the program or function address things needed by a maintenance programmer –explanation of non-trivial algorithms –side-effects – global data that the program or function might modify without going through the program or function arguments –date and author of both original code and modifications. –version information –copyright notice –explanation of inputs and outputs –data limitations

Header Comments in.h files The header file can be thought of as a user’s manual for the package comments should address how to use information (not how it works) should state any limitations of the code –range limits –exceptions doesn’t usually need to identify author should have version information copyright information (IP)

Variable Comments All variables should have an end-of-line comment saying what the variable is used for –this includes individual fields of a struct –#defines should be commented and collected together at the beginning of the code unit (file)

In-line comments these are whole line comments usually places on the line preceding program control statements (if, while, for, switch, function invocations…) the idea is that all statements that alter to top to bottom execution of a program increase the program complexity and deserve an explanation what is going to happen

Pre and Post Conditions an approach to commenting data structures where the variables defined to represent a data structure represent its state each function, in its header block states the state before a function invocation (precondition) and the expected state modification caused by the invocation (postcondition)

stack, push example /**********************************************************************************************/ /* Name: void push(stack * id, int value) */ /* inputs : id – variable name of the stack ; value – integer to be added to stack */ /* outputs : none */ /* precondition – the stack is empty */ /* postcondition – the stack is non empty and contains one additional item at its top */ /**********************************************************************************************/