Is builder design pattern is the right one to create itemBrowsePanel object? this object needs 2 others objects (iconBrowsePanel,textBrowsePanel) in order to be ready to use, as follows:
HTMLPanel itemBrowsePanel=new HTMLPanel("");
HTMLPanel iconBrowsePanel=new HTMLPanel("");
HTMLPanel textBrowsePanel=new HTMLPanel("");
HTMLPanel titlePanel=new HTMLPanel(titlePanelText);
HTMLPanel subTitlePanel=new HTMLPanel(subTitlePanelText+" "+panelName);
textBrowsePanel.add(titlePanel);
textBrowsePanel.add(subTitlePanel);
itemBrowsePanel.add(iconBrowsePanel);
itemBrowsePanel.add(textBrowsePanel);
if builder design pattern is the right one, is it applicable to pass arguments to any object on creation in order to construct other objects ?
iconBrowsePanelandtextBrowsePanelare added toitemBrowsePanelbefore it is used, then it is better to create anItemBrowsePanelclass with a specific constructor which takes these parameters and ensures the invariantIf you want to reuse the existing construction algorithm elsewhere, it is better to wrap in into a method which takes parameters like
titlePanelText,subTitlePanelTextorpanelNameand returns a fully constructedHTMLPanel, which represents anitemBrowsePanelIf there are too many parameters and / or parameter combinations to create
itemBrowsePanel, then yes, it may be appropriate to use a builder