Instance Methods vs. static methods in serialization



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
.



Relevant Pages

  • Re: Collection of Collection control @ DESIGN TIME
    ... // Initialize in a common function and call that function in each constructor. ... Serializable Attribute is not a design time attibute.. ... Here the serialization is designtime Serialization. ... Public Overloads Overrides Function CanConvertToAs Boolean ...
    (microsoft.public.dotnet.framework.windowsforms.designtime)
  • Re: Collection of Collection control @ DESIGN TIME
    ... // Initialize in a common function and call that function in each constructor. ... Here the serialization is designtime Serialization. ... Public Overloads Overrides Function CanConvertToAs Boolean ... but I wanted to include some Rich Design Time ...
    (microsoft.public.dotnet.framework.windowsforms.designtime)
  • Re: Design is intent.
    ... I recognize the notion of a "standard we use to judge the code". ... or a Java class named "foo_" are bad design, ... That doesn't seem to be at all on the same level as "all persistence ... will be based on object serialization, ...
    (comp.object)
  • Re: InheritedPropertyDescriptor vs. ReflectedPropertyDescriptor
    ... We also have a custom serializer, ... serializes root design component with all of its sub-components. ... Most everything works properly except in some cases where serialization is ... type InheritedPropertyDescriptor that the call to ShouldSerializeValue ...
    (microsoft.public.dotnet.framework.windowsforms.designtime)
  • Re: Design is intent.
    ... Would you say that people use the term "design" when they talk about writing ... > serialization" statement written somewhere in a document, ... is really a valid, logical exception, then yes (if you don't have a good ... that I can clearly see that all persistence is via serialization ...
    (comp.object)