CSC/ECE 517 Fall 2011/ch1 1e dm: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 11: Line 11:


Structured Programming uses three types of control flow: sequential, test, and iteration.
Structured Programming uses three types of control flow: sequential, test, and iteration.


==Characteristics==
==Characteristics==
Line 19: Line 18:
*The names of variables and other objects such as procedures which are declared in outer blocks are visible inside other inner blocks, unless they are shadowed by an object of the same name.
*The names of variables and other objects such as procedures which are declared in outer blocks are visible inside other inner blocks, unless they are shadowed by an object of the same name.
*It splits the tasks into modular forms.  
*It splits the tasks into modular forms.  


==Advantages==
==Advantages==
*Splitting of tasks into blocks/modules makes the program simpler and easier to read with less lines and codes.
*Splitting of tasks into blocks/modules makes the program simpler and easier to read with less lines and codes.
*In a solution space where there are widely varying spatial and temporal scales one can
*Put more grid where the solution is more interesting.
*Leave the solution coarse where the solution is not interesting.
*Can save an order of magnitude in memory.
*Can save an order of magnitude in run time.
*Numerical accuracy improves with more grid where gradients are strongest.
*Being block-structured allows Fortran to be used for array operations.
*Overhead involved involved in coarse-fine interactions can be amortized over larger array calculations.
*Numerical accuracy is improved if the coarse-fine interface is kept to a codimension smaller than the solution.
==Limitations==
*Communication patterns between levels can be complex.
*Algorithm complexity can be substantial.




Line 29: Line 40:


Programming techniques may include features such as data abstraction, encapsulation, messaging, modularity, polymorphism, and inheritance.
Programming techniques may include features such as data abstraction, encapsulation, messaging, modularity, polymorphism, and inheritance.


==Characteristics==
==Characteristics==
Line 37: Line 47:
*Each object or module has the data and the instruction of what to do with the data in it. This can be reused in other software .
*Each object or module has the data and the instruction of what to do with the data in it. This can be reused in other software .
*An object-oriented program is decomposed into a network of collaborating objects. An object represents a thing or concept and has a known set of behaviors that may be invoked by other objects. For any activity of the program, an object responsible for that activity may interact with other objects by invoking their behaviors, or "methods", until the activity is complete.
*An object-oriented program is decomposed into a network of collaborating objects. An object represents a thing or concept and has a known set of behaviors that may be invoked by other objects. For any activity of the program, an object responsible for that activity may interact with other objects by invoking their behaviors, or "methods", until the activity is complete.


==Advantages==
==Advantages==

Revision as of 20:22, 30 August 2011

CSC/ECE 517 Fall 2011/ch1 1e dm


Introduction

This wiki article describes the block structured and object oriented languages. It also highlights their advantages and limitations along with providing the comparison between them.


Block Structured Languages

A block is a section of code which can be grouped together. Blocks consist of one or more declarations and statements. A block structured programming language uses and permits the creation of blocks and nested blocks. The major function of using blocks is to enable the groups of statements within the block to be treated as if they were a single statement.

Structured programming is 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. A structured program is decomposed into a hierarchy of processes. A process in this context is a body of code, typically a function or subroutine, that takes some input and manipulates it to produce an output. A process may be composed of other, more specialized processes, i.e., it may be a function that calls other functions.

Structured Programming uses three types of control flow: sequential, test, and iteration.

Characteristics

  • It takes on the top-to-bottom approach.
  • It is based around data structures and subroutines.
  • It uses single entry and exit block.
  • The names of variables and other objects such as procedures which are declared in outer blocks are visible inside other inner blocks, unless they are shadowed by an object of the same name.
  • It splits the tasks into modular forms.

Advantages

  • Splitting of tasks into blocks/modules makes the program simpler and easier to read with less lines and codes.
  • In a solution space where there are widely varying spatial and temporal scales one can
  • Put more grid where the solution is more interesting.
  • Leave the solution coarse where the solution is not interesting.
  • Can save an order of magnitude in memory.
  • Can save an order of magnitude in run time.
  • Numerical accuracy improves with more grid where gradients are strongest.
  • Being block-structured allows Fortran to be used for array operations.
  • Overhead involved involved in coarse-fine interactions can be amortized over larger array calculations.
  • Numerical accuracy is improved if the coarse-fine interface is kept to a codimension smaller than the solution.

Limitations

  • Communication patterns between levels can be complex.
  • Algorithm complexity can be substantial.


Object Oriented Languages

An approach to programming in which each data item with the operations used on it is designated as an object; the routines used to operate on the data item are called methods; and objects are grouped in a hierarchy of classes, with each class inheriting characteristics from the class above it.

Programming techniques may include features such as data abstraction, encapsulation, messaging, modularity, polymorphism, and inheritance.

Characteristics

  • This type of programming uses sections in a program to perform certain tasks.
  • It splits the program into objects that can be reused into other programs.
  • They are small programs that can be used in other software.
  • Each object or module has the data and the instruction of what to do with the data in it. This can be reused in other software .
  • An object-oriented program is decomposed into a network of collaborating objects. An object represents a thing or concept and has a known set of behaviors that may be invoked by other objects. For any activity of the program, an object responsible for that activity may interact with other objects by invoking their behaviors, or "methods", until the activity is complete.

Advantages

Conclusion

References