Table of Contents Previous Section

When Do You Use Compiled Code?

There are two primary reasons you use compiled code in WebObjects: to boost performance and to provide your own custom classes (remember, WebScript doesn't allow you to create new classes).

Providing your own custom business classes is one common use of compiled Objective-C. Another is to subclass the WebObjects classes that are the building blocks of a WebObjects application:

Instead of using a component script to provide behavior in your application's components, you can instead provide a compiled component by subclassing WOComponentController. Just like component scripts, compiled components have associated declarations and HTML templates. For examples of applications that subclass WOComponentController, see HelloWorldObjC and TimeOffObjC in the WebObjects Examples directory.
You effectively extend the behavior of WOWebScriptApplication when you implement methods in an application script. However, there may be times you need to override WOApplication methods to change the fundamental behavior of the application object. For example, you might want to provide a custom state storage solution. For an example of subclassing WOWebScriptApplication, see the section Example: FaultTolerantApplication in the chapter "Managing State."
You can provide your own dynamic elements by subclassing WODynamicElement.

Many applications use some combination of compiled code and scripts. It's common to write your business logic as compiled Objective-C code and to then use WebScript to provide your interface logic. "Interface logic" refers to activities such as page navigation, capturing the data entered in forms, and managing the appearance of the user interface. Business logic, on the other hand, refers to the behavior associated with custom objects. For example, you could have an OrderProcessing object that validates orders to ensure that their data is correct and then checks them against available inventory.

Table of Contents Next Section