CSC/ECE 517 Fall 2011/ch1 1e aa

From Expertiza_Wiki
Revision as of 22:09, 30 August 2011 by Argholka (talk | contribs)
Jump to navigation Jump to search

Wiki Chapter: CSC/ECE 517 Fall 2011/ch1 1e aa

Introduction

This Wiki chapter talks about the basic fundamentals of block structured programming and Object Oriented programming and explains the advantages of Object Oriented programming over block structured programming which made O-O languages more common and widely used in the Software Industry today. We also focus on the practicability of using block structured approach in O-O languages.

Block-Structured Languages

A Block is a part of code that is clustered together. A Block of code thus is a group of program statements and variables referred to in those statements. Block of code can be contained within delimiters typically 'begin'-'end', opening and closing curly braces '{}' which can be compiled and executed as a single execution unit. Block of code can be the body of a subroutine, a function or an entire program. The main block can contain subsections consisting of inner blocks. Those inner blocks can contain more inner blocks giving rise to a nested block strucutre. One such example of a block structure is Pascal. In most primitive block structured languages, the scope of a variable can be limited to the block in which it is declared. This is called lexical scoping. Thus, referring to the nested structure of the blocks; all the variables declared in the outer block can be accessed within that block and all of its inner blocks but are not accessible outside that block. <example> Block structured programming language is fundamentally based on these principles.