Thursday, June 18, 2009

Interfaces

                  Every module should communicate with as few others as possible.The Small Interfaces or “Weak Coupling” rule relates to the size of intermodule connections rather than to their number.If two modules communicate, they should exchange as little information as possible.The Small Interfaces requirement follows in particular from the criteria of continuity and protection.Fortran practice which some readers will recognize the “garbage common block”. A common block in Fortran is a directive of the form.

                    The problem, of course, is that every module may also misuse the common data, and hence that modules are tightly coupled to each other the problems of modular continuity and protection are particularly nasty.This time honored technique has nevertheless remained a favorite  no doubt accounting for many a late night debugging session.

                    Developers using languages with nested structures can suffer from similar troubles.With block structure as introduced by Algol and retained in a more restricted form by Pascal,it is possible to include blocks, delimited by begin quater end pairs, within other blocks.In addition every block may introduce its own variables, which are only meaningful within the syntactic scope of the block.

                     Behind this rule stand the criteria of decomposability and composability, continuity and understandability.With block structure,the equivalent of the Fortran garbage common block is the practice of declaring all variables at the topmost level.Block structure, although an ingenious idea,introduces many opportunities to violate the Small Interfaces rule.

No comments:

Post a Comment