Different schools of software design

Different  schools of software design

  1. Array programming
  2. Aspect  Oriented design
  3. Class based programming
  4. Recursion
  5. Template meta Programming
  6. Flow based programming
  7. Spreadsheet
  8. Action Language
  9. 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.

Advantages :

  • 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.

Template metaprogramming

       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.

Example

To swap the numbers using the concept of function template.

#include<iostream.h>

#include<conio.h>

template<class t>

void swap(t &x,t &y)

{

t temp=x;

x=y;

y=temp;

}

void fun(int a,int b,float c,float d)

{

cout<<“\na and b before swaping :”<<a<<“\t”<<b;

swap(a,b);

cout<<“\na and b after swaping  :”<<a<<“\t”<<b;

cout<<“\n\nc and d before swaping :”<<c<<“\t”<<d;

swap(c,d);

cout<<“\nc and d after swaping  :”<<c<<“\t”<<d;

}

void main()

{

int a,b;

float c,d;

clrscr();

cout<<“Enter A,B values(integer):”;

cin>>a>>b;

cout<<“Enter C,D values(float):”;

cin>>c>>d;

fun(a,b,c,d);

getch();

}

Output:

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

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: