The question is: Use constructor or setter method?
...I am not sure if that is a correct way to deal with problem. I think in above mentioned case user is anyway going to change the text, so why not force him while constructing the action?
I am not quite comfortable with this answer. It contains nothing but code and the code does not look self-explanatory to me:
public abstract class Action { protected String text = "Default action text"; protected String toolTip = "Default action tool tip"; protected String imageURl = "http://myserver.com/images/default.png"; .... rest of code, I guess setters and getters } public class MyAction extends Action { public MyAction() { } public MyAction(String actionText) { setText(actionText); } public MyAction(String actionText, String toolTip_) { setText(actionText); setToolTip(toolTip_); } public MyAction(String actionText, String toolTip_; String imageURL_) { setText(actionText); setToolTip(toolTip_); setImageURL(imageURL_); } }
Am I missing something here? Could above be really a valuable answer to the question asked?
update
As of now, answer is removed (self deleted).