Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / March 2005

Tip: Looking for answers? Try searching our database.

Destroy all constructors!

Thread view: 
Paul Chapman - 09 Mar 2005 05:21 GMT
Has anyone taken the approach of just forgetting about constructors in Java
and instead using a conventionally-named initializer?  I'm very, very tired
of having to define (and often edit) the same ctor over and over again in
subclasses.  Ctors are not virtual, while an initializer can be.

Cheers, Paul
M van Leeuwen - 09 Mar 2005 07:07 GMT
Taken a subclass PipeLine based on a Vector the initializer in class Vector
would create a Vector object, not a PipeLine. Therefor instance variables
for class PipeLine are not availabe.

Do you really need that much subclasses? Besides, editing a ctor is often
not necessary. It calls the ctor of the baseclass by default. You only need
to initialize the instance variables of that specific class; otherwise,
leave the ctor out.

Regards,
Michael.

> Has anyone taken the approach of just forgetting about constructors in
> Java and instead using a conventionally-named initializer?  I'm very,
[quoted text clipped - 3 lines]
>
> Cheers, Paul
Tom Dyess - 11 Mar 2005 01:53 GMT
> Taken a subclass PipeLine based on a Vector the initializer in class
> Vector
[quoted text clipped - 17 lines]
>>
>> Cheers, Paul

And you don't even need a constructor for that, you can do:

class Mine {
 public String = "";
 public HashMap = new HashMap();
}

Signature

Tom Dyess
OraclePower.com



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.