Opentopia Directory Encyclopedia Tools

Functional normalization (object-oriented programming)

Encyclopedia : F : FU : FUN : Functional normalization (object-oriented programming)


Functional Normalization (FN) is the process of (1) migrating replicated code or (2) partitioning functionality in an object-oriented codebase.

Mechanisms of inheritance (VI, II) are used to migrate and partition functionality along 'lines of inheritance' formed between parents (base classes) and children (derive classes).

In software refactoring the replicated code is removed and replaced with a single version (implementation) that is shared among the classes which originally contained the replicated versions (of the replicated implementation).

In original design common functionality is partitioned into polymorphic and common implementations. Common code is (functionally) delegated to parents while polymorphic code is delegated to children .

Functional Normalization is commonly applied to migrate replicated common code from children (derived class link) to parents (base class link).

Functional Normalization is commonly applied to migrate polymorphic code from parents (derived class link) to children (base class link).

General

Replicated code is more than one implementation of an identical COMPUTING FUNCTION in the same codebase. Such code replication is not desirable and ideally should be factored out of the codebase.

Functional normalization is the process of factoring out REPLICATED CODE.

Implementation Inheritance (II) has a 'functional migration' aspect to its semantics. This aspect allows Implementation Inheritance to be used in the process of functional normalization by allowing replicated (or commonly needed) functionality to 'migrate' to the base class.

In general replicated (or commonly needed) functionality should be migrated from child classes to base classes. During design the common state space used in a computing function will migrate to the base class. All methods that use the state space directly (and inherently in performing their function) should be grouped in the same class as the state space (the 'base' class).

In the context of object-oriented programming the semantics of Implementation Inheritance is the core design mechanism to structuring functionality along normalized lines of inheritance.

Note that if a codebase is NOT functionally normalized it exhibits replicated code (replicated functionality) throughout and across class hierarchies.

A 'normalized codebase' is one that is functionally normalized.

Normalization Aspects in Data and Function Schema

Implementation Inheritance (II) has normalization aspects to its semantics.

Foreign-keys are used to normalize data in a database. Implementation Inheritance is used to normalize function in an object-oriented codebase.

In both cases (data/function) the goal is to create a more efficient system (less complex) by removing needless replication.

In a relational database, records can share data by using a pointer (foreign-key) to the common data. In the same way child classes can share code by using an inheritance link to a common parent.

A SCHEMA results in both systems (database and codebase) that is based on a SPECIFIC LINKAGE MECHANISM (Foreign-key/Implementation Inheritance link). In data bases its a relational schema between records. In code bases its a functional schema between classes.

Normalization Mechanism

Normalization deals with reducing replication in a system. This reduction of replication is based on a 'normalization mechanism'.

In a relational database the data relationship formed by the foreign-key structure is a 'data schema'. This schema exists to share data between records.

In an object-oriented codebase the relationship formed by Implementation Inheritance (II) forms a 'functional schema'. This schema exists to share code between classes.

Foreign-keys are the 'normalization mechanism' in relational databases. They form the data re-use structure within the database.

Implementation Inheritance is the 'normalization mechanism' in object-oriented code bases. It forms a code re-use structure within the codebase.

As such Implementation Inheritance allows replicated code to be factored out of child classes and moved to parent classes (the process of functional normalization).

Functional Normalization and Performance Turning

Database and codebases have a definitive fixed schema (a stable design) that exists in a single moment of time. As such normalization mechanisms have a spatial aspect to their semantics. This spatial aspect allows the 'schema' to be presented as single structure 'in space' (thus the spatial aspect).

A 'database diagram' (its schema) and a 'class hierarchy' are common presentations used to show the stable structure of the design.

Control mechanisms (method dispatch), on the other hand, use a 'sequence diagram' to present the controlled 'sequence' over a period of time. The sequence of method calls due to changes in state of the codebase forms the 'flow of control' in any given instance of execution.

In a object-oriented language it is important to distinguish the 'functional schema' of Implementation Inheritance (II) from the 'control flow' of Virtual Inheritance (VI). This is because performance tuning (which will effect control flow) can influence functional normalization. The potential result is that some replication or duplication of code may be desirable for better performance.

Composition Vs. Aggregation

Implementation Inheritance (II) is a complement to Virtual Inheritance (II). Neither is a replacement for the other.

It is important to articulate the difference between a normalization mechanism (such as Implementation Inheritance) and a control mechanism (Virtual Inheritance). This, in turn, helps to distinguish compositional effects from aggregation structure.

Software designs are often a balance of composition, aggregation and performance tuning. System design decisions which balance compositional effects and performance with aggregation structures are a very important part of functional normalization.

Functional Aggregation (common code) Vs. Functional Dispersion (polymorphic code)

In contrast to this functional aggregation process (to the parents) is the process of functional dispersion (to the children). In functional dispersion a single implementation (in a parent) must become polymorphic and migrated to various child implementations.

Both processes (functional aggregation, dispersion) use inheritance expression mechanisms such as Virtual Inheritance (VI-LINK) (functional dispersion), and Multiple Implementation Inheritance (MI-LINK) (functional aggregation).

In both design processes the functionality moves along lines of inheritance. In refactoring the functionality MIGRATES from the old to the new locations. In the initial design (prior to production coding) the functionality is PARTITIONED along the lines of inheritance.

Stratification is normally used to 'layer' an inheritance graph to partition inherently complex (but functionally similar) operations.

See also

 


From Wikipedia, the Free Encyclopedia. Original article here. Support Wikipedia by contributing or donating.
All text is available under the terms of the GNU Free Documentation License See Wikipedia Copyrights for details.

Search Titles
0123456789
ABCDEFGHIJ
KLMNOPQRST
UVWXYZ?

E-mail this article to:

Personal Message: