Instance Methods vs. static methods in serialization
- From: Joerg Simon <j_simon@xxxxxx>
- Date: Mon, 29 May 2006 14:28:04 +0200
Hello to the complete comp.object newsgroup!
I really like this newsgroub, and read it regularly (althoug I don't post really often), and allready learned very much from it.
Currently I started learning ruby, and together with some other articles (f.e. about serialization in .NET), I found that there is a little konflikt between two approches:
Some say that If I design utility methods, like serialization, why not put it into a static method of the class. Then we would have something like:
ClassX.serialize(objectX).
On the other hand, I found some articles about serialization where the people claimed that this is not really beautifull OOD, and such a method should be part of the object, much like Ruby too implements things. So coude would look similar to:
objectX.serialize();
However, beside asthetic issues I am not really shure what advantage brings the latter over the former?
And is it bad design to have the following (out of an Design and an implementation view):
<java_pseudo_code>
Class X {
public static void Serialize(ClassX x) {
// do serialization
}
public static void serialize() {
Serialize(this);
}
}
</java_pseudo_code>
Thanks,
Jörg Simon
.
- Follow-Ups:
- Re: Instance Methods vs. static methods in serialization
- From: H. S. Lahman
- Re: Instance Methods vs. static methods in serialization
- Prev by Date: Re: Searching OO Associations with RDBMS Persistence Models
- Next by Date: Re: Searching OO Associations with RDBMS Persistence Models
- Previous by thread: sequence diagram for observer pattern
- Next by thread: Re: Instance Methods vs. static methods in serialization
- Index(es):
Relevant Pages
|