FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Freezing my Pickle? and other nonsense...

 
Post new topic   Reply to topic     Forum Index -> Mango
View previous topic :: View next topic  
Author Message
gtbass



Joined: 22 Jul 2004
Posts: 7
Location: Austin, TX

PostPosted: Mon Jan 16, 2006 10:58 pm    Post subject: Freezing my Pickle? and other nonsense... Reply with quote

Ok, I can kinda understand the usage of the word "pickle" in the verb sense, "to pickle". Classes, however, are nouns, not verbs, and "a pickle" doesn't make any sense as an object unless you're composing it with a burger object.

The method names for "pickling" are equally counterintuitive.

PickleWriter.freeze()?!? Now, lets see, what is a PickleWriter? Is it a pickle that writes? An author who writes on pickles? Surprise, it's neither! In fact PickleWriter is a new brand of kitchen appliance as evidenced by its action, freezing things. Why else would a "writer" be doing any freezing?

PickleReader.thaw()?!? I guess it's a microwave oven or something, not very good brand identity though.

Seriously though, shouldn't writers write() and readers read()? The individual method names do capture their own purpose, and freeze/thaw are good opposites, but they don't fit into the larger scheme of things. You're mixing all kinds of metaphors here!

Maybe the pickle example wouldn't need commentary to inform me:

Code:
        // serialize it
        w.freeze (foo);

if the method were just called "serialize()". Of course, Serializable, and other such names might not win you any software obfuscation awards, but that's kinda the point isn't it? Next time I want to freeze my pickle I'll fly to Antarctica and drop some trou.
Back to top
View user's profile Send private message
kris



Joined: 27 Mar 2004
Posts: 1494
Location: South Pacific

PostPosted: Mon Jan 16, 2006 11:09 pm    Post subject: Reply with quote

I'll see what can be done about the names Very Happy
Back to top
View user's profile Send private message
gtbass



Joined: 22 Jul 2004
Posts: 7
Location: Austin, TX

PostPosted: Mon Jan 16, 2006 11:29 pm    Post subject: Reply with quote

Actually, I'm working on a set of serialization primitives now. I just need to finish my sample serialization format class before I release it for public consumption. It might be a good alternative to Pickle.

The key advantage with my technique is that a serializable object needs no code to explicitly deal with reading/writing.

Code:
class Foo : SerializableObject {
    int    i;
    int[]  a;
    float  f;
    double d;
    real   r;
    Foo    o;

    this() {
        serializableMembers["i"] = new GenericIntrinsicSerializer!(int)(i);
        serializableMembers["a"] = new GenericArraySerializer!(int)(a);
        serializableMembers["f"] = new GenericIntrinsicSerializer!(float)(f);
        serializableMembers["d"] = new GenericIntrinsicSerializer!(double)(d);
        serializableMembers["r"] = new GenericIntrinsicSerializer!(real)(r);
        serializableMembers["o"] = new GenericReferenceSerializer!(Foo)(o);
    }

    this(int i, int[] a, float f, double d, real r, Foo o = null) {
        this();
        this.i = i;
        this.a = a;
        this.f = f;
        this.d = d;
        this.r = r;
        this.o = o;
    }

}

int main(char[][] args) {
    int[] ia;
    ia ~= 1;
    ia ~= 2;
    ia ~= 3;
    auto Foo foo = new Foo(-2, ia, -2.5, -2.25, -2.125);
    auto Stream file = new File("serialized.txt", FileMode.Out);
    file.writeString("foo = ");
    auto Format sof = new SimpleObjectFormat(file);
    sof.serialize(array);
    return 0;
}
Back to top
View user's profile Send private message
kris



Joined: 27 Mar 2004
Posts: 1494
Location: South Pacific

PostPosted: Mon Jan 16, 2006 11:49 pm    Post subject: Reply with quote

That's cool.

I had looked into something vaguely similar back when (before templates arrived; I needed something to efficiently send classes around a network), and decided that all of this serialization malarky is somewhat interim until we get reflection. That was almost two years ago, and we're still waiting Smile

Regardless, I quite like the way it's done in Mango, since the notion was intended to be the 'override' for some future automated mechanism. Sure, PickeWriter et. al. might not have the best names, but the mechanism works just fine with standard writers too (text, binary, whatever), which makes PickleRegistry redundant for some applications. Just think ~ I almost named that module PickleFactory instead Very Happy

I like your approach also ~ just a somewhat different flavour.
Back to top
View user's profile Send private message
JJR



Joined: 22 Feb 2004
Posts: 1104

PostPosted: Tue Jan 17, 2006 12:18 am    Post subject: Reply with quote

gtbass, I had a real laugh at your critique on "Pickle", "Freeze", and "Thaw". Sorry, Kris, I usually have nothing but praise for Mango, but this made me stop and think a bit.

Yes, gtbass, you are right on this one. The names are not logical. I think sticking with a simple "Serialize" idea might be best for now, unless Kris can think of something else creative. Smile

kris wrote:
Just think ~ I almost named that module PickleFactory instead Very Happy


Now that would have been choice! Laughing

Oh... maybe we could stick with the pickle theme afterall... just use "jar" and "unjar" instead? Don't know.... Smile

-JJR
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Mango All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group