Public: Concord Software Projects : Creating OTClasses
This page last changed on Dec 10, 2008 by skim.
There are currently 3 ways to make a new OTClass. They are listed in order of preference. The first is the preferred way to make an OTClass.
Make a new interface which extends OTObjectInterface. The properties of the OTClass are defined by defining get and set methods for those properties.
The OTrunk framework will dynamically create an implementation of this interface at runtime. You do not need to implement your interface
DefaultOTObject implements all of the methods of OTObject. The only thing you need to do is make an interface that extends OTResourceSchema and make a constructor for your class that takes a parameter whose type is this interfaces. You add properties to your OTClass by defining get and set methods for those properties. You do not need to implement your ResourceSchema interface, the OTrunk framework will dynamically create an implementation at runtime.
The difference between this approach and the Interface approach above is you can add behavior to your OTClass. But it also means if you want to provide access to the properties of your OTClass you need to write methods in the OTClass which delegate to the resource schema that was passed in the constructor.
You need to create a resource schema interface like above, and you need to implement all the methods of OTObject.
This option should only be necessary if you want to turn an existing class into an OTObject. You can subclass it and implement the OTObject methods. There are alternative ways to link existing classes with OTObjects, particularly the OTView System and the OTController System. These alternative ways are preferred because they separate the data structure from the behavior.
|Document generated by Confluence on Jan 27, 2014 16:52|