Goals of Coding
Goals of Coding
Goals of Coding
Sequencing Construct
Selection Construct
Iteration Construct
Type 1: while-do looping
Code 1;
Code 2;
if (Cond 2){
break;
2. Data encapsulation
3. Recursion
.Coding Style
The following are some of the major guidelines thatdictates a perfect codig
style
-DO –
– DONT –
.Don’t sub-optimize –
Documentation
methods,files etc.
encapsulation etc.
exception handling
code, instead rewrite the code● Be sure that the comments and code
agree with
Coding Standards
statement.
3. Rules for limiting the use of global:These rules file what types of data
they lead to "spaghetti" code, which is hard toread and maintain, except as
standard within an
Coding Guidelines
lines at orbelow 80 characters. Lines longer than this maynot be visible properly
columns.
2. Spacing: The appropriate use of spaces withina line of code can improve
readability.
Example:
Bad: cost=price+(price*sales_tax)
%5.2f\n",cost);
least one
programming. Thisdoes not only include adding the necessary logicto test for
class, that hides the details of the data representation in order to make the data
type easier to work with. Data abstraction involves creating a representation for
user only has to understand the interface, the commands to use, and not how the
Syntax:
struct address {
char name[50];
char street[100];
char city[50];
char state[20];
int pin;
};
Union: Like Structures, union is a user defined data type. In union, all members
share the same memory location. For example in the following C program, both x
and y share the same location. If we change x, we can see the changes being
reflected in y.
Syntax:
Typedef: C++ allows you to define explicitly new data type names by using the
keyword typedef. Using typedef does not actually create a new data class, rather it
defines a name fo an existing type. This can increase the portability(the ability of a
program to be used across different types of machines; i.e., mini, mainframe,
micro, etc; without much changes into the code)of a program as only the typedef
statements would have to be changed. Using typedef one can also aid in self-
documenting code by allowing descriptive names for the standard data types.
Syntax:
Concurrency control
Concurrency in software engineering means the collection of techniques and
mechanisms that enable a computer program to perform several different tasks
simultaneously, or apparently simultaneously. This allows for parallel execution of
the concurrent units, which can significantly improve overall speed of the
execution. The base goals of concurrent programming include correctness,
performance and robustness.