Wednesday, August 13, 2008

PRPC OOP Terms: Public versus Private Access

In computer science, the principle of information hiding is the hiding of design decisions in a computer program that are most likely to change, thus protecting other parts of the program from change if the design decision is changed. The protection involves providing a stable interface which shields the remainder of the program from the implementation (the details that are most likely to change). In modern programming languages, the principle of information hiding manifests itself in a number of ways, including encapsulation (given the separation of concerns) and polymorphism. PRPC supports information hiding through both polymorphism (though somewhat limited polymorphism) and separation of concerns through its implementation of the class hierarchy and Ruleset packaging. Consider the following three "access modifiers" popular in most Object Oriented languages.

A concern is a generic term used to encompass any programmatic element (aka rule instances) including class definitions, activities, properties, streams, or other rule types.

Friendly: a property, activity, stream, or class that is accessible to the class itself and to all classes in the same Ruleset. A property or method is declared friendly by virtue of the absence of any more specific access modifiers.

Friendly access is accomplished by defining classes and other concerns directly inside the Ruleset housing the primary application. There is no restriction applied to internal knowledge between classes and concerns declared thusly. It is the easiest to implement (indeed it is the default) and the hardest to maintain.


Friendly Classes

Public: a property, activity, stream, or class that is accessible to every class with visibility to the Ruleset. It is distinguished from friendly access in that explicit access is must be specified to allow interaction between concerns contained by different Rulesets.

Public access in PRPC is implemented by allowing an application's primary Ruleset Version to have prerequisite knowledge of the Ruleset in which a class and related concerns are defined. It may be accomplished with a minimum of two Rulesets.


Public Class A

Private: a property, activity, stream that is accessible only to the class in which it is defined. Note that a class cannot be declared private as a whole.

Private access in PRPC is implemented by allowing an application's primary Ruleset Version to have prerequisite knowledge of the public Ruleset as above. The class in question is defined within the public Ruleset. Additionally, the public RuleSet Version is allowed prerequisite knowledge of a second private Ruleset into which private concerns are placed. The application itself may not refer to any concern defined within the private Ruleset; invocation of these concerns may only be accomplished through access to public methods (which may be a virtual method). This may be accomplished with a minimum of three Rulesets.


Public (partial) Class A with Private Class B

In such an arrangement, concerns that extend Public Class A may be included in the private Ruleset making Class A into a partial class. This allows concerns within Class A to be a mix of Private and Public access. Indeed, multiple Private Rulesets may be created to extend the private capabilities of Class A without impacting the integration between the application classes and the public interface of Class A.

Labels:

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home