On Thu, Sep 27, 2012 at 1:59 PM, Igor Vaynberg <[email protected]>wrote:
> ok. lets start with a bit of history to have more context. > setDefaultModel() only exists because of type-erasure. before wicket > supported generics all components had a public setModel() method. so, > one might say that having a public setModel() is "the wicket way" > because it was there since 1.0. just to establish the baseline. > > lets take a concrete example of FormComponent. right now it has a > public setModel() method, but by your thinking we would have to make > both setDefaultModel and setModel methods protected, because we do not > know that all FormComponents support changing the model. after all, a > common subclass of FormComponent is FormComponentPanel which pretty > much always distributes its model. so, we leave it to subclasses of > FormComponent and FormComponentPanel to decide whether or not to > override setModel() to make it public. > > a TextField would make its setModel() public - because it properly > handles the usecase, correct? so it is still possible for your > developers to call setModel() on a textfield and rewire it so it no > longer links with a model of another component correctly. > > so we are now back to square one with the addition that a lot of > components have to override setModel() just to change its visibility > from protected to public - introducing a lot of noise. > > im all for making the code better, but i do not think that this change > does. in the end, the developer has to know what the method does if > they chose to call it. > > -igor > +100 ... there are valid usecases for calling setModel and setDefaultModel. Very valid usecases. If you, in your programming model, don't want your developers to call setModel/setDefaultModel ... tell them not to. If you have developers that don't understand / listen to / follow your direction, it's not a Wicket problem. For that, set up some kind of code-check that looks for that and other conventions that you follow. -- Jeremy Thomerson http://wickettraining.com *Need a CMS for Wicket? Use Brix! http://brixcms.org*
