Class and Members

Shang is objected oriented and has full support for most of the OOP features including access control of member attributes and multi-inheritance. Each attribute of a class can have a domain so that public class attributes can often be used for convenience yet object integrity is still protected. This can help eliminate the need of private attributes and "setter/getters" and make the class interfaces both safe and clean. The attributes a subclass inherited from super classes may violate the validity of the member of sub class. A class may have a validator to guard against illegal actions performed by super class attributes.

Shang has also extended the traditional concept of class to conditional class. A conditional class is a collection of loosely connected objects. Unlike a traditional class, it doesn't ``create'' new members using the constructor, but issues membership to members of other classes that satisfy certain conditions. Such memberships may be cancelled once the conditions are no longer satisfied, or the member can choose to withdraw from the class voluntarily. By using conditional classes, it is possible to avoid unnecessary programming complexity, too many levels of multiple inheritance, and frequent object creations and destructions.

oz 2009-12-22