I have an object that I instantiate – it’s quite nifty as it also extends a superclass and does some stuff in the constructor – in fact all the vital parameters and method calls are handled in the constructor.
After this I never call the object again to do something – I don’t pass it to any other objects either – after it’s instantiated it does it stuff and all is good. Is this the wrong way to do it?
Yes, doing significant work in the constructor is usually a bad idea.
Could you do this through a static method instead? The static method could create an instance of the superclass and then do whatever it needs to. The only problem with this approach would be if the superclass called virtual methods during its constructor, but that’s a code smell in itself…