Dan Zambonini, in "What would you put in the ultimate Base Class?," brings up an interesting theoretical exercise: what methods or attributes would you put into the ultimate base class? (Note that Mr. Zambonini is thinking of PHP4 here, so for Java programmers the exercise is merely theoretical.)
Mr. Zambonini suggests the following as a start:
A save or persist method, which could record the current object data to a configurable location: database, disk, memory (e.g. memCache), or session (cookie). This would also require a set of methods that define the mapping of properties to database tables/fields, and relations between classes (e.g. compositions).
Conversely, a load method, based on a unique identifier or condition.
A getAsXml() method that returns an XML representation of the object (either as a string, or appended to a provided DOM Node). Actually, maybe this should just be an ultra-flexible export or getRepresentation type method, that can also return the object as HTML, CSV and other formats.
Considering the problems Java has had with those same ideas, it's slightly amusing that someone suggests PHP go down the same paths. What do you think?
Threaded replies
· Dan Zambonini: What would you put in the ultimate Base Class? by Joseph Ottinger on Wed Nov 02 08:26:19 EST 2005
· No such thing by Nate Sammons on Tue Nov 08 16:05:17 EST 2005
· Back To Basics by Samir Mishra on Tue Nov 08 18:16:00 EST 2005
· Inheritance is for whimps by Jonny LeRoy on Tue Nov 08 21:16:40 EST 2005
· Use aspects instead of "hard-wiring" specific features by Dean Wampler on Tue Nov 08 23:38:30 EST 2005
· Use aspects instead of "hard-wiring" specific features by Remi Vankeisbelck on Wed Nov 09 07:36:15 EST 2005
· Use aspects instead of "hard-wiring" specific features by Dean Wampler on Wed Nov 09 11:42:06 EST 2005
· Use aspects instead of "hard-wiring" specific features by Remi Vankeisbelck on Wed Nov 16 04:48:35 EST 2005
· Dan Zambonini: What would you put in the ultimate Base Class? by Jens Wyke on Wed Nov 09 15:56:23 EST 2005
· Dan Zambonini: What would you put in the ultimate Base Class? by Alex Koyfman on Wed Nov 16 12:58:22 EST 2005
没有评论:
发表评论