in reply to Help with ADT

Isn't this exactly what objects are supposed to handle? Just make an object, have a bunch of accessors, and store the stuff any way you damn well please. The client only does stuff through the accessors, so you don't have the coercion issues.

As a note - while you're developing it, DO NOT deal with optimization. You have no idea what to optimize yet. Just use the easiest way to code it, then optimize later. Much, much later.

------
We are the carpenters and bricklayers of the Information Age.

Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

Replies are listed 'Best First'.
Re: Help with ADT
by Abigail-II (Bishop) on Jul 25, 2002 at 11:33 UTC
    Objects aren't a magic wand that just make your problems go away. You still have the same potential problems if you are going to use an object. Don't forget, Perl makes you implement the objects yourself. All you have is a single reference, and you have to store all your instance data there. Guess what, then you are facing exactly the same problems! After all, the post is about storing data in a reference.... You still have to write your accessors.

    Abigail

      Yes, you are absolutely correct. I should have been more specific in my post.

      What I was driving at was that he wasn't quite sure how the ADT was going to be specified. In fact, he says that the ADT's definition is constantly changing. This implies, to me, that he's using this thing. By creating some API, he is able to deal with the ADT in some abstract manner within the client. He gets to figure out what exactly he wants this thing's behavior to be.

      Then, and only then, does he have enough information to be able to actually design the darn thing. He's trying to put the cart before the horse.

      For example, I only skimmed the original post, but I'm pretty sure that he doesn't need one ADT, but a composition of ADT's.

      ------
      We are the carpenters and bricklayers of the Information Age.

      Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

        Well, you wrote:
        The client only does stuff through the accessors, so you don't have the coercion issues.
        which sounds specific enough to me, and that was what I argued against.

        You are right about that it's good to do the design first (if only all programmers would). It's also good to have an API, but that's already implied if you are using an ADT, because it wouldn't be much of an ADT if you'd poke around in the datastructure outside of defined set of functions. However, you do not need objects to be able to deal with ADTs. Your password file can be seen as an ADT which you access via the *pwent set of functions.

        Abigail