Re: Good practise?
- From: "Daniel Dyer" <dan@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 17 Jul 2006 14:03:16 +0100
On Mon, 17 Jul 2006 13:40:15 +0100, Rhino <no.offline.contact.please@xxxxxxxxxx> wrote:
I don't see why it would be a problem to invoke a method that enables or
disables GUI controls from a constructor. I've done so many times and have
no regrets.
Then again, I've never had the particular code examined by an OO design guru
so maybe such an activity violates a design precept of some kind.
To my way of thinking, the constructor's job is to build an instance of an
object. If that object is a GUI, then I don't see why enabling/disabling
controls on that GUI should be avoided within the constructor.
I agree. However, you should be aware of the potential issues around calling overrideable methods from a constructor. If the method is private or final there should be no problem. If not, there could be subtle bugs if the method is over-ridden by a sub-class. This is because the object is not guaranteed to have been initialised before the method is invoked (the superlcass constructor will then be calling a method on the sub-class).
Dan.
--
Daniel Dyer
http://www.dandyer.co.uk
.
- References:
- Good practise?
- From: Gargoyle
- Re: Good practise?
- From: Rhino
- Good practise?
- Prev by Date: Re: A file writing dilemma....!
- Next by Date: Re: A file writing dilemma....!
- Previous by thread: Re: Good practise?
- Next by thread: Problem with JCombo box
- Index(es):
Relevant Pages
|