Different schools of software design
- Array programming
- Aspect Oriented design
- Class based programming
- Template meta Programming
- Flow based programming
- Action Language
- Structured programming
Structured programming :
A technique for organizing and coding computer programs in which a hierarchy of modules is used, each having a single entry and a single exit point, and in which control is passed downward through the structure without unconditional branches to higher levels of the structure.
Three types of control flow are used: sequential, test, and Repetation
- Sequence: one task after another
- Test : making a choice between actions
- In “repetition” : a statement is executed until the program reaches a certain state, or operations have been applied to every element of a collection. This is usually expressed with keywords such as while, dowhile etc, Often it is recommended that each loop should only have one entry point (and in the original structural programming, also only one exit point, and a few languages enforce this).
Almost any language can use structured programming techniques to avoid common pitfalls of unstructured languages. Unstructured programming must rely upon the discipline of the developer to avoid structural problems, and as a consequence may result in poorly organized programs
Object-oriented programming can be thought of as a type of structured programming, uses structured programming techniques for program flow, and adds more structure for data to the model.
- Easy to write:
Modular design increases the programmer’s productivity by allowing them to look at the big picture first and focus on details later.Several Programmers can work on a single, large program, each working on a different module
Studies show structured programs take less time to write than standard programs.
is a metaprogramming technique in which templates are used by a compiler to generate temporary source code, which is merged by the compiler with the rest of the source code and then compiled. The output of these templates include complile timeconstants, data structures, and complete functions. The use of templates can be thought of as compile time time execution. The technique is used by a number of languages, the best-known being C++, but also Curl , D etc
The use of templates as a metaprogramming technique requires two distinct operations: a template must be defined, and a defined template must be instantiated.
The template definition describes the generic form of the generated source code, and the instantiation causes a specific set of source code to be generated from the generic form in the template.
To swap the numbers using the concept of function template.
void swap(t &x,t &y)
void fun(int a,int b,float c,float d)
cout<<“\na and b before swaping :”<<a<<“\t”<<b;
cout<<“\na and b after swaping :”<<a<<“\t”<<b;
cout<<“\n\nc and d before swaping :”<<c<<“\t”<<d;
cout<<“\nc and d after swaping :”<<c<<“\t”<<d;
cout<<“Enter A,B values(integer):”;
cout<<“Enter C,D values(float):”;
Enter A, B values (integer): 10 20
Enter C, D values (float): 2.50 10.80
A and B before swapping: 10 20
A and B after swapping: 20 10
C and D before swapping: 2.50 10.80
C and D after swapping: 10.80 2.50