Re: Help with code screen using model-view-controller
Re: Help with code screen using model-view-controller
- Subject: Re: Help with code screen using model-view-controller
- From: Art Isbell <email@hidden>
- Date: Fri, 2 Jun 2006 12:00:15 -1000
On Jun 1, 2006, at 10:23 AM, Carter Wojcik wrote:
Does anyone know of a good reference or examples that
can demonstrate model-view-controller?
I have found WO apps to be much more difficult to model using MVC
than Cocoa apps. Maybe one reason is because WO is a server-side
technology (ignoring Java Client :-) so Views aren't so obvious. But
one could probably argue that dynamic element classes that generate
UI elements on a Web page are View classes. A typical WO app
probably doesn't contain many custom dynamic element classes, so the
main MVC modeling challenge is probably between Controllers and Models.
But maybe a bigger problem is that WebObjects Builder supports easy
mixing of Model and Controller. I look at Model classes as those
that contain logic that manipulates data without any assumption about
the display of that data. Controller classes are the glue between
Models and Views. So for me, custom WOComponents are Controllers.
However, WOBuilder supports associating data directly with UI
elements, so the data model is exposed to the WOComponent. I tried
to fight this at one point by not typing custom WOComponent keys
(i.e., instance variables and methods) as custom data types (i.e.,
those property types specified in an eomodel) instead creating Model
classes that custom WOComponent methods would invoke for data to
display and to set data values. That was a painful process that
resulted in much more bug-prone code. So I gave up on strict Model
and Controller separation.
Now I take advantage of WOBuilder's ability to associate data with
UI elements whenever possible. But when doing so is not possible, I
use custom WOComponent methods to access Model objects in which data
manipulation and logic is implemented. My custom WOComponents don't
reference any EOF libraries and my Model classes don't reference any
WO libraries. This seems to be working fairly well. So my Java code
seems well-separated into Controller and Model classes even though
the wod files contain Model knowledge.
Aloha,
Art
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden