Concept : Understanding Interfaces
Contents |
[edit] Description
Interfaces in Bungee Connect, at their most basic level, are identifiers. (Adapter interfaces also act as interfaces.) At design time, you assign the same interface to both a portion of the the View and a corresponding part of the Model. This facilitates loose coupling and dynamic, or late (runtime) binding between the View element and the Model element. In this way, at runtime, changes in that part of the View get propagated to the corresponding portion of the Model, and vice versa.
Note The DynamicForm control epitomizes this late binding. For an example of this behavior, import the DynamicForm sample code and explore the control's functionality.
[edit] Binding the View to the Model
In more concrete terms, you most often bind a control (part of your View) to a member of a class (part of your Model). To do this, you add an interface at the project level of a solution. This is neccessary so that every interface in your project is in the proper scope to be available for you to assign the interface to any Model or View element in your project. You then use properties to assign that interface to the appropriate portions of your Model and your View. The properties on the Interface tab of the Property Editor are for assigning an interface to a control (just select a control within the Design Editor, then select the Interface tab on the Property Editor and use the appropriate property to assign the interface to the control). Use the Interface List property to assign the same interface to the appropriate member of a class. At runtime this binding ensures that when a user changes something in the UI, the appropriate field in your Model updates, and vice-versa.
[edit] Using System Provided Interfaces
Although you can create your own interfaces, there are also many system provided interfaces available in the Bungee Runtime. Using a system provided interface provides the advantage of facilitating easy reuse and sharing of code, and also keeps your project from becoming too cluttered.
There are several types of interfaces in Bungee Connect:
- Category Interface
- Control Interface
- Adapter Interface
- Event Interface
- Form Interface
- Function Interface
- Property Interface
- Sort Interface
[edit] Category Interface
A type of interface that provides a way to declare whether or not an object contains usable properties. This property information is used by the Work Space object when you create an object. The Work Space object inspects the new object you create and, if you have set Category interfaces, makes the properties available for editing at design time.
[edit] Control Interface
A type of interface that is added implicitly when you connect a control to an object, a control interface binds the View element to the Model (object) so that changes in one propagate naturally to the other.
[edit] Adapter Interface
An adapter interface is a type of interface which not only acts as an identifier, but also contains code acting as a generic interface to the specific functionality of a given data type. In the context of system provided interfaces, this generic interface is most often to the behavior of a specific control. Each adapter interface requires an adapter to implement the adapter interface's interface. Because of this extra functionality, when you add an adapter interface, you must choose a class for which the interface can provide a generic interface, so that when you later add an adapter, that adapter can implement the interface provided through the interface.
In the example below, the MyAdapterInterface being created would provide an interface to the GoogleMap control. In order to be fully functional however, the developer creating this adapter would also need to add an interface. The adapter needed to impement the MyAdapterInterface interface to the GoogleMap control would be a GoogleMapAdapter.

[edit] System Provided Adapter Interfaces
Although there are system provided adapter interfaces, there is no wizard yet that easily displays them for you to choose. However, in adding an adapter interface, you can access a host of system classes for which your interface can act as an interface. The most common scenario would be to choose a class from the TypeLib: ControlAdapter project on the Dependencies tab of the Chooser, as these provide interfaces to each of the Bungee system controls (see the image above).
[edit] Event Interface
A type of interface used to bind any events an object may throw, for use by a second object.
[edit] Form Interface
Form interfaces provide a way to identify a form so that either the DynamicForm control or FormList control can locate and display that form at runtime. Typically, you add a form interface to your project at the same time as you add a form to your class. The form interface you add gets implemented at the project level .
After you add the form interface to your project, you assign a form interface to a form using the Interface List property. You must also specify the same form interface for the control in which you want the form to appear. You do this using an appropriate control property such as the DynamicForm control's Form property, so the control can identify the correct form to display.
[edit] System Provided Form Interfaces
System provided form interfaces appear in the Runtime.FormInterface tab of the Add Form wizard, as well as other wizards. The advantage of using these provided interfaces is to facilitate reuse and sharing of code based on standardization of interface names. Since interfaces function primarily as identifiers, you can use any of the interfaces below to identify any form you create. The names of the interfaces are just aids to your memory as you construct your application.
[edit] Function Interface
Function Interfaces provide an interface for locating the right function to use for a given action, such as a double-click action or a drag-and-drop action. For example, in the case of a FormList control bound to a collection, you may want to execute a function when a user double-clicks an element in the collection. To accomplish this, you assign the OnDoubleClick function interface to the FormList control using the Double Click property on the control, and then assign the same function interface to a function (using the function's Interface List property). At runtime, when a user double-clicks a particular element, the function you identified with the interface gets invoked.
Likewise, you use the Drag Function property to assign a function interface to a control. You can then create functions that implement that function interface's function signature to specify an action to take when a user drags-and-drops an element from the control.
Important Each type of system-provided function interface provides a set of arguments as part of the function signature. You must implement these arguments in your function in the same order as they appear in the function signature if you want your function to pass parameters properly. You can find the function signatures for system-provided function interfaces in the property documentation for a particular function interface.
Function interfaces have an added benefit if you rename a function. Because the function gets invoked by being identified (using an integer) by the interface you specified, you do not need to write code to account for the name change.
For more information on working with function interfaces, see Using Function Interfaces.
[edit] System Provided Function Interfaces
System provided function interfaces are listed in the Runtime.FunctionInterface tab of the Choose FunctionInterface dialog that appears when you assign a function interface to a control (for example when you use the Double Click property on a FormList control). The advantage of using these provided interfaces is to facilitate reuse and sharing of code based on standardization of interface names. Since interfaces function primarily as identifiers, you can use any of the interfaces below to identify any form you create. The names of the interfaces are just aids to your memory as you construct your application.
[edit] Property Interface
A property interface is an interface exposed as a property in the Bungee Builder.
[edit] Sort Interface
Sort interfaces are used for sorting data in a collection. If you set a field of a class to be a sorted collection, then you can specify a Sort interface. The Sort interface allows you to define the sort criteria to be used in order to sort an object in a collection. At runtime, the collection will ask each object it references for the interface view as specified by the collection's field properties.
[edit] See Also
Adding an Interface
Understanding Adapters
Adding an Adapter




