Slimelite BBS

Constructors

Back to EMULATE

From Brian Wisti · 1996-04-09 00:37 · #73573 in EMULATE

Yet another question for anybody out there. In one project I'm working
on, the most conspicuous elements of the program are objects of a
single class MainWorld(a single world in a subsector for a
paper-and-dice role playing game). So far, everything is running
smoothly, but there is a minor thought that occured to me:

  The constructor for class MainWorld is (in comparison to the rest of
the class definition) huge! As most of the class is little more than
translations of concepts(most of which are smaller classes used as
elements of the class), tables, and charts from the game, it seems
unavoidable. I've been kind of curious as to whether this would affect
the speed of the program when creating an object. Note: this is only for
personal use, so it isn't a profound dilemna - just something that's
piqued my interest.

  In an effort to make the program to make the program more readable to
myself, many separate elements of construction have been delegated to
private functions within the class which get called on only to set the
values of MainWorld data. This way, I can make the constructor look more
like a progression of coherent steps rather than a jumble of code. It
works fine within this context, but is it "bad style"(i.e. something I
wouldn't want to do for a program I plan on releasing to the public) to
handle constructors in this way? If so, what would some alternative
approaches be? I didn't specify much code here because it is a more
general context that concerns me :

<How to make an ungainly constructor look and/or function in a coherent
 manner>

Thanks for your attention,

Brian

--- WILDMAIL!/WC v4.12 
 * Origin: R-Squared BBS, Oly WA USA, 33k6bps, 360-705-4475  (1:352/28.0)