Re: Design Question
Guido Neitzer <[email protected]>
| Newsgroups | gmane.comp.web.webobjects.devel |
|---|---|
| Message-ID | <C0E64E36.31443%[email protected]> |
On 21.07.2006 3:00 Uhr, "Michael Deninger" wrote: > 1) read this dictionary into my Application object at startup. Sounds > great, but I cannot figure out how to access EOApplication from an > EOGenericRecord It is generally a bad idea to implement "bottom-up dependencies". You wouldn't be able to re-use your code with a different Application. > 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. Yes, this generates unnecessary hits to the filesystem. Not a real problem though. > 3) hard-code the dictionary into an abstract class extending > EOGenericRecord and have the Entity inherit from it. Hmmm. Why so complicate? You could have an AllergyCode class, with a static dictionary and use "AllergyCode.codesDict.valueForKey(foo)". Or have a class created at startup time, which reads this dictionary from a file and use something like a "*Factory" class to receive the AllergyCode singleton. What *I* would do is just a simple table in the database and do the lookup there. With a simple EO subclass (lets call it AllergyCode) and a static method there which implements "valueForCode(code)" by looking up a code in the database. This has some advantages: you can have an edit interface for the codes in your app, you can use db tools to alter the content of the table and you don't have to restart your application. As EOF does caching for you, it wouldn't be so bad from the performance point (a simple lookup of a small object on an indexed field should be done in less than a millisecond. > Obviously, I would love to use 1) but I am stuck as I describe above... Is this really obvious? You would create a dependency from your EO to the application class which is bad design! cug _______________________________________________ WebObjects-dev mailing list [email protected] http://www.omnigroup.com/mailman/listinfo/webobjects-dev
smime.p7s
(application/pkcs7-signature, 2.1 KB) - not displayed