Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 193
  • Last Modified:

Please advise on "startup" and inherited constructors

Dear Java Experts,

I'm looking for general guidance on designing the "startup" in Java projects which include inherited constructors.  It would be great if anyone could point me to a good tutorial on this subject.  Of course, if you'd like to respond directly, I'd like that, too.

My project has a single entry point (StartUp.class).  Recently, I've instantiated a number of other classes within StartUp's constructor.  Many of those classes also instantiate other classes, and also Super() their own superclasses.

At first, I was running into problems because I needed certain classes to instantiate in a particular order during the "bootstrap" process.  For instance, I first needed the class that finds the project's home directory.  Next, I needed the class that constructs the names of certain files from that...

To solve the immediate problem, I ordered the instantiation of classes in StartUp's constructor to match what I wanted, and carefully investigated THEIR startups...   However, this doesn't seem to be a very clean solution.  It's still difficult to follow the initial flow of control.

We normally like to think of OOP classes as more or less independent units. But how can we best work with "bootstrap" processes, in which certain classes must instantiate in particular orders?


And advice or links (or books) would be greatly appreciated.

Thanks,
BrianMc1958
0
BrianMc1958
Asked:
BrianMc1958
  • 2
1 Solution
 
objectsCommented:
> We normally like to think of OOP classes as more or less independent units.
> But how can we best work with "bootstrap" processes, in which certain classes must instantiate in particular orders?

If they are independant units, then you shouldn't need a particular order :)

So you need to either make the classes more independant, or have another class (that understands their startup dependencies) handle the stratup order.

0
 
BrianMc1958Author Commented:
Dear objects,

Thanks.  I do want to make the classes more independent.  However, in this case, some dependency will necessarily remain.  

I guesss another way to ask my question is:  Is it necessarily a sign of bad Java design that I NEED a class that understands the startup order?  Furthermore, is it strange that the startup is so heavily dependent on inherited constructors?  Should that type of thing be avoided, or does it just flow naturally from the OOP structure of Java?

Thanks one more time,
BrianMc1958
0
 
BrianMc1958Author Commented:
Dear objects,

Thanks.  I might re-formulate this question, now that I've thought about it some more.

--BrianMc1958
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now