On Oct 8, 8:16 am, "Austin Ziegler" <halosta... / gmail.com> wrote:

[snip]

>   class Package
>     def self.from_yaml(yaml)
>       pkg = Package.new
>
>       YAML.load(yaml).each do |key, value|
>         case key
>         when 'package' then # ...
>         when 'version' then # ...
>         when 'created' then # ...
>         when 'homepage' then # ...
>         when 'devsite' then # ...
>         when 'authors' then # ...
>         when 'description' then # ...
>         when 'libpaths' then # ...
>         else
>           # save the unknown pairs somewhere so that subclasses can deal
>           # with them, too.
>         end
>       end
>     end
>   end
>
> Just because your storage representation is flat doesn't mean your
> in-memory object has to be. (And you can define your own #to_yaml on the
> Package class that flattens things for saving.)
>
> This is no different than what I wrote for Ruwiki four years ago (I
> eschewed YAML because Syck was broken in a couple of different releases
> of Ruby.)

Good. this is a much better approach. Obviously we can argue until
we're blue in the face and insult each other all day long and make
assumptions about what each is saying. So lets just scrap all that and
lets deal with some concrete code.

You have thus far claimed that any class with 50 attributes is dumb,
and that you would fire any employee of yours who used modules as I
have suggested. You have also so far shown a delegating form of the
Package class (which is a real production class for me) and have above
given an unfinished rendition of how you'd load it from the YAML
serialization (which is an import human readable part of this classes
purpose). So how about completing the whole thing?

Lets do this. I'll give you a complete list of attributes, their
aliases, default values and their categorizations. Then you use your
way and I'll use mine. Will present them here and let others judge
whose it more maintainable, reusable, easy to read, faster, etc.

And lets get a third party to arbitrate, so neither has to post their
solution before the other. James, since this is sort of like a Ruby
Quiz, would you like to do the honors?

What do you say, Austin?

T.