Re: Design Question

Ray Kiddy <[email protected]>
Newsgroups gmane.comp.web.webobjects.devel
Message-ID <[email protected]>
On Jul 21, 2006, at 7:12 AM, Michael Deninger wrote:

> Thanks everyone for the input. The problem was necessarily  
> complicated by the fact the I did not create nor can I change the  
> DB being used (hence the extra effort needed)
>

The current documentation could be making this unclear. You are  
saying that it is a problem that you cannot change the DB.

This is exactly one what EOF and WebObjects was built to do. It is  
exactly the situation WebObjects was built to handle. When WO was  
first developed and Next was marketing it to big-metal data centers  
with 10 year old databases, this was _the_ main selling point.

You should try to think of it this way. The EOModels you build up are  
object representations that should hide the database from your  
application. There should be en entity for the AllergyCodes. So make  
one. How you actually get data into that is a seperate question.  
There are many ways to do it, some cool and some clunky. Maybe the  
data comes from the database. Maybe it is calculated at run time.  
Maybe it is loaded into an array in memory by your application on  
launch. It really does not matter. As long as it is something you can  
get at with KeyValueCoding, you can get it to act like an EO.

If you think of how you want your data to look, in an ideal world,  
that is the object side of your EOModels. That is the view of the  
data you should try to make available to your views.

The WOComponents of your application should deal with the data as you  
want it to be structured. If you are trying to get data for a  
WOComponent and you are thinking about the database, your EOModel  
schema design was not sufficient and it is not done.

MVC is a very powerful idea but it will only work if you actually use  
your C to keep your M and V away from each other. The more you mix  
your M and V, the weaker the design and the less re-usable your code  
will be.

- ray

> The winning solution is one that I  but SHOULD have figured out  
> myself (I was on the right track). I have loaded the static data  
> from disk into Application. Where I fell on my face is in accessing  
> Application from an EOGenericRecord. While it does not have an  
> inherited application() method (which I was trying to use) I can use:
>
> On Jul 21, 2006, at 2:01 AM, Paul Lynch wrote:
>
>> Application application = (Application)Application.application();
>
> from anywhere. This is exactly what I was missing as I was trying...
>
> Application application = (Application)application(); // doesn't  
> work in EOGenericRecords while it does work in WOComponents
>
> <Homer Simpson>DOH!</Homer Simpson>
>
> Regards,
>
> Mike
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.