Programming pitfalls to avoid, Isolating portions of a page, Webscript programming pitfalls – Apple WebObjects 3.5 User Manual

Page 60

Advertising
background image

Chapter 4

Debugging a WebObjects Application

60

methods are useful if you want to see all or part of the call stack. The following
table describes the trace methods:

The output from the trace methods appears in Project Builder’s launch panel.

You use the trace methods wherever you want to turn on tracing. Usually, you do
this in the

init

method (or constructor) of a component or the application:

- init {

[super init];
[self.application traceAssignments:YES];
[self.application traceScriptedMessages:YES];
return self;

}

Isolating Portions of a Page

If a component is producing unexpected HTML output, you can try to isolate
the problem by printing small portions of the page at a time. Use HTML
comments (

<!--

) to comment out all but the suspect portion of the page and

reload the component. Verify that this portion works as you intend it to. Reduce
the size of the commented out portion of the page until more and more of the
page is visible in the browser. Continue until you have found the offending area.

Programming Pitfalls to Avoid

This section describes some things to look out for as you debug your application.

WebScript Programming Pitfalls

Because WebScript looks so much like Objective-C and C, it’s easy to forget that
WebScript isn’t either of these languages. When you’re debugging WebScript
code, watch out for the following tricky spots:

Method

Description

– trace:

Enables all tracing.

– traceAssignments:

Logs information about all assignment statements.

– traceStatements:

Logs information about all statements.

– traceScriptedMessages:

Logs information when an application enters and exits a scripted method.

– traceObjectiveCMessages:

Logs information about all Objective-C methods invocations.

Advertising