UIEvolutin Inc.
UJML Language Reference
Components and Object Oriented Programming

Components offer some object oriented programming advantages, but do not provide true OOP.

Components are similar in many ways to objects in an object oriented programming, but do not provide all of the attributes required for a truly object oriented programming language. By definition object oriented programming is a kind of three legged stool, with the legs consisting of:

  • Encapsulation (Information hiding by exposing some functionality while hiding how the functionality is implemented)
  • Polymorphism (Making objects interchangeable so that calling code can use differently implemented objects in exactly the same way, without changing the calling code)
  • Inheritance (Allowing objects to refine other implementations of similar functionality by starting from them and adding or removing features)

To be object oriented a programming language must provide all three 'legs' of the stool in some way. Encapsulation is usually provided by providing some way of delineating private from public functionality. Polymorphism is provided by either run-time binding or through compile-time interfaces of some kind. Inheritance may be provided directly in parent-child relationships between class definitions or through object prototypes. 

UJML only provides two of these 'legs': Encapsulation and Polymorphism.


Encapsulation in UJML is provided with the Interfaces implemented by a Component. See Components, Interfaces. Only the implemented interface functions and events are exposed to code outside the Component. All other functions and code in a component are hidden and can only be accessed from within the component. 

The one exception to the above is visual UJML elements displayed by a component. See Visual Components. When a component is displayed (via a display-instance element) the visual state of the component appears on the device screen. However you can only change the visual state of the component by calling into its implemented interfaces.


Polymorphism in UJML is also provided with the Interfaces implemented by a Component. See Components, Interfaces. Because UJML uses compile-time binding, you must declare Interfaces separately and explicitly implement each member in a Component. Code outside the component can only access one interface at a type by casting a component reference to an interface type. See Interface Types

This means that different Components can implement the same Interface and calling code only knows about the Interface, not the implementation; making Components 'pluggable' in the sense that the calling code doesn't care what Component reference it has, so long as the reference is to a Component that implements the proper Interface.

Copyright (c) 2000-2007 UIEvolution, Inc. All rights reserved.
What do you think about this topic? Send feedback!