View Full Version : BasicDialog.setDefaultButton return type
1 Dec 2006, 3:05 PM
Do you think it would make more sense for setDefaultButton to return the button rather than the dialog?
If you're going to chain things together, it would seem more likely to want to operate on the button like
or get a local ref to the added button.
1 Dec 2006, 3:13 PM
I think it would be more common to say:
For chaining on the button, I would think it would make more sense on the addButton():
Unfortunately since it's already out there, changing the return type isn't really an option anyway. :(
1 Dec 2006, 3:33 PM
Yeah, true. What I suggested could be accomplished by moving a closing paren. I'd probably never actual code that anyway - chaining that many together just gets ugly unless it's simple methods with minimal parms.
I guess from a consistency standpoint it's confusing. In this case, there isn't getDefaultButton() (yet), but if a 'set' is going to return something, IMO it makes more sense to return the same type as the 'get'.
I'm not suggesting breaking things, but it might be something to consider for future additions. Wonder how other people feel - I've done mostly C# lately, which would do this via a property that doesn't return anything.
1 Dec 2006, 3:49 PM
Personally I don't do the chaining thing either. But generally, all set operations and methods that don't have a return value return this.
Powered by vBulletin® Version 4.1.5 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.