home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / objectiv / 453 < prev    next >
Encoding:
Internet Message Format  |  1992-07-25  |  2.3 KB

  1. Path: sparky!uunet!casey!gaboon!seltd!lerman
  2. From: lerman@seltd.UUCP (Kenneth Lerman)
  3. Newsgroups: comp.lang.objective-c
  4. Subject: Re: Object Oriented Design Question
  5. Message-ID: <18@seltd.UUCP>
  6. Date: 25 Jul 92 12:59:25 GMT
  7. References: <fQbGjid@quack.sac.ca.us>
  8. Reply-To: lerman@seltd.UUCP (Kenneth Lerman)
  9. Organization: Systems Essentials Limited
  10. Lines: 46
  11.  
  12. In article <fQbGjid@quack.sac.ca.us> rmd@quack.sac.ca.us (Robert M. Diamond) writes:
  13. |Hello,
  14. |    I am attempting to design a system which reads data in from a
  15. |file and writes it back to another file.  Data items can be of various
  16. |basic types, like number, string, date or time.  They can be read from
  17. |the file or calculated from other read or calculated data items.  They
  18. |can be stored in the database (in various ways) or marked for temporary
  19. |use only.  The scheme I have come up with is thus:  
  20. |Have a class "data_item" which can store itself or retrieve its value.
  21. |Have subclasses "numeric_data_item," "date_data_item, " etc. which
  22. |instantiate the ::store() and ::retrieve() functions.
  23. |    The problem is that the typed_data_item either needs to know how
  24. |to store itself in each possible way, or the storage_class has to know
  25. |how to store each possible type, or I must create classes for the
  26. |cartesian product of type and storage class.
  27. |    This is my first OOD project, and I would appreciate any ideas
  28. |that people can come up with.
  29. |    thanx,
  30. |    Robert Diamond
  31. |    +1 415 493-4122
  32.  
  33. The examples you give (of numeric, date,...) are primitive types.
  34. What is the need to store them in more than one way?
  35.  
  36. The classic way of "factoring" a M x N problem like this is to develop
  37. an intermediate representation (IR).  Then write M functions or
  38. methods (one for each of the M classes) to write the data in the IR.
  39. Lastly, write N functions or methods to convert the IR to the N target
  40. representations. 
  41.  
  42. Stepstone's AsciiFiler class and facility enable every object to be
  43. saved (usually without writing specialized code for that object) in an
  44. ASCII representation.  If you have access to that product, the source
  45. may give you some ideas on how to store and read graphs of complex
  46. objects. 
  47.  
  48. Ken
  49.  
  50.  
  51.  
  52.  
  53. -- 
  54. Kenneth Lerman                  ...!uunet!casey!gaboon!seltd!lerman
  55. Systems Essentials Limited                            (203)426-4430
  56. 55 Main Street
  57. Newtown, CT 06470
  58.