From: "Steven Fisher" <[EMAIL PROTECTED]>
> A coworker and I are having a bit of an argument over whether or not 
> multiple forms should be handled by a single source file. I'm a big fan 
> of considering .c files to be objects, and trying to use an 
> object-oriented approach to developing forms. However, he's right that 
> handling related forms with a single .c file takes a lot less source 
> code (though I'm not really convinced it's that much less object code).
> 
So where are your costs?  When using one C file per form (and
I also use one resource file per form) it takes very little time to 
copy an existing set of resource and source files and rename 
everything to create a new form.  Yes, there is more source code,
but this only becomes an issue when an application becomes too
big.  Until that happens what's needed is fast, robust development.

I agree with the principle that any application should be implemented
in the least code necessary, but as far as repeated code goes this is 
best managed by creating work functions so that the form handler is 
small and streamlined.

I developed these practices while working on a suite of applications
under tight deadlines.  We were frequently being asked to copy or
move sets of functionality from one app to another at short notice.
By isolating each form to a managed set of resource and C files
I could reliably pass these jobs to junior programmers because 
they were just a matter of copying the required module and connecting
the new form into the interface and application framework.  No
side-effects meant fewer bugs.  Combining this with an approach
that wrapped each database and function set in it's own C module
as an API meant that I could employ programmers trained in 
java and VB and apply them quickly to Palm programming because
they didn't have to interact significantly with the db or 
memory-handling.

The other change that I found improved robustness considerably 
was to copy the form resource ID definition into the C header that
exposed the event handler.  This allowed me to limit the resource
include file to only the form that owned it.  While this seems obvious 
I found that errors caused by copying logic from one form to another
and forgetting to alter the resource ID names produced bugs that,
while rare, were time-wasters.  Again, I found that by isolating
resource ids so that it was impossible to reference a form element
outside of it's form I could pass work to junior programmers with 
more confidence that they wouldn't lose half a day debugging.

Chris Tutty


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to