CSC/ECE 517 Fall 2009/wiki3 17 VR: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
Line 87: Line 87:
Consider the following example:
Consider the following example:
Assume you are building a system to manage a library. Considering Publications of a library, this type can be represented as follows in Pascal-Ada syntax:
Assume you are building a system to manage a library. Considering Publications of a library, this type can be represented as follows in Pascal-Ada syntax:
<code>
<pre language="ADA">
type PUBLICATION =
type PUBLICATION =
record
record
Line 98: Line 98:
proceedings: (editor, place: STRING) -- Conference proceedings
proceedings: (editor, place: STRING) -- Conference proceedings
end
end
</code>
</pre>


== Characteristics ==
== Characteristics ==

Revision as of 06:43, 18 November 2009

Single-Choice Principle

This article explains in detail about the single choice principle which is one of the five modularity principles.

Modularity

Modular Programming is used to break up a large program into small sub programs like functions and subroutines. These broken up pieces are called as modules.

Concept

The various modules designed by use of modular programming must satisfy five fundamental requirements as follows:

  • Decomposability
  • Composability
  • Understandability
  • Continuity
  • Protection

In order to ensure modularity the following five rules must be followed:

  • Direct mapping
  • Small interfaces(weak coupling)
  • Explicit interfaces
  • Information Hiding
  • Few interfaces

There are five principles of software construction which are to be followed along with the above stated requirements and rules. They are:

The Linguistic Modular Units principle  :

This principle states that modules must correspond to syntactic units in the language used.

The self-documentation principle

 :

This principle states that the designer of a module should strive to make all information about the module part of the module itself.

The uniform access principle

 :

This principle states that all services offered by a module should be available through a uniform notation, which does not betray whether they are implemented through storage or through computation.

The open-closed principle

 :

This principle states that the modules should be both open and closed.

The single choice principle

 :

This principle states that whenever a software system must support a set of alternatives, one and only one module in the system should know their exhaustive list.

In detail

This principle is a consequence of both the open closed principle and the information hiding rule. Consider the following example: Assume you are building a system to manage a library. Considering Publications of a library, this type can be represented as follows in Pascal-Ada syntax:

type PUBLICATION =
record
author, title: STRING;
publication_year: INTEGER

case pubtype: (book, journal, conference_proceedings) of
book: (publisher: STRING);
journal: (volume, issue: STRING);
proceedings: (editor, place: STRING) -- Conference proceedings
end

Characteristics

Conclusion

References

1. Object Oriented Software Construction by Bertrand Meyer, Second Edition.