Re: Design Question
Paul Lynch <[email protected]>
| Newsgroups | gmane.comp.web.webobjects.devel |
|---|---|
| Message-ID | <[email protected]> |
On 21 Jul 2006, at 02:00, Michael Deninger wrote: > I have some static data that I need to access from within an > EOGenericRecord. The data, unfortunately, is not in the DB (and > even if it were, creating a relationship to the entity would likely > not work for various reasons). The data is essentially a dictionary > of keys / values that describe the meaning of the coded values in > one of the database tables. E.G. > > Entity: PatientAllergy > Attribute: AllergyCode > > where AllergyCode is some number (say 83). The meaning of that > number is in this dictionary (e.g. value = 83, description = > "penicillins") > > What is the best way to accomplish this? I have considered the > following: > > 1) read this dictionary into my Application object at startup. > Sounds great, but I cannot figure out how to access EOApplication > from an EOGenericRecord Application application = (Application)Application.application(); Works from anywhere. > 2) read this dictionary form disk into each EOGenericRecord at the > time it is created. I think that this would work, but it creates a > lot of unnecessary repetition of data. Think classes - I presume that you are using a subclass of EOGenericRecord, and not EOGenericRecord itself. Load the table on first request, as a static method within the appropriate class. > 3) hard-code the dictionary into an abstract class extending > EOGenericRecord and have the Entity inherit from it. This seems a little awkward to me. You could create a class for the sole purpose of holding the values, as Ian suggests, but that strikes me as proliferation of objects. On the whole, I would prefer to implement it as a static method of your entity class. Paul