🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.objective-c
Article #11

Re: Object Oriented Design Question

#11
From: Kenneth Lerman
Date: Sat, 25 Jul 1992 12:59
46 lines
2384 bytes
In article <fQbGjid@quack.sac.ca.us> rmd@quack.sac.ca.us (Robert M. Diamond) writes:
|Hello,
|	I am attempting to design a system which reads data in from a
|file and writes it back to another file.  Data items can be of various
|basic types, like number, string, date or time.  They can be read from
|the file or calculated from other read or calculated data items.  They
|can be stored in the database (in various ways) or marked for temporary
|use only.  The scheme I have come up with is thus:  
|Have a class "data_item" which can store itself or retrieve its value.
|Have subclasses "numeric_data_item," "date_data_item, " etc. which
|instantiate the ::store() and ::retrieve() functions.
|	The problem is that the typed_data_item either needs to know how
|to store itself in each possible way, or the storage_class has to know
|how to store each possible type, or I must create classes for the
|cartesian product of type and storage class.
|	This is my first OOD project, and I would appreciate any ideas
|that people can come up with.
|	thanx,
|	Robert Diamond
|	+1 415 493-4122

The examples you give (of numeric, date,...) are primitive types.
What is the need to store them in more than one way?

The classic way of "factoring" a M x N problem like this is to develop
an intermediate representation (IR).  Then write M functions or
methods (one for each of the M classes) to write the data in the IR.
Lastly, write N functions or methods to convert the IR to the N target
representations. 

Stepstone's AsciiFiler class and facility enable every object to be
saved (usually without writing specialized code for that object) in an
ASCII representation.  If you have access to that product, the source
may give you some ideas on how to store and read graphs of complex
objects. 

Ken




-- 
Kenneth Lerman                  ...!uunet!casey!gaboon!seltd!lerman
Systems Essentials Limited                            (203)426-4430
55 Main Street
Newtown, CT 06470
Technical Details
Message-ID: <18@seltd.UUCP>
Path: arc1-ca.pugleaf.net!sparky!uunet!casey!gaboon!seltd!lerman
References: <fQbGjid@quack.sac.ca.us>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!casey!gaboon!seltd!lerman
From: lerman@seltd.UUCP (Kenneth Lerman)
Newsgroups: comp.lang.objective-c
Subject: Re: Object Oriented Design Question
Message-ID: <18@seltd.UUCP>
Date: 25 Jul 92 12:59:25 GMT
References: <fQbGjid@quack.sac.ca.us>
Reply-To: lerman@seltd.UUCP (Kenneth Lerman)
Organization: Systems Essentials Limited
Lines: 46