Note that there are some explanatory texts on larger screens.

plurals
  1. POIs using the Factory pattern make sense here?
    primarykey
    data
    text
    <p>So I have a PageItem object that I want to possibly reuse elsewhere. I'm in ABC framework.</p> <p>Here's the PageItem interface :</p> <pre><code>public interface PageItem { public abstract String getUrl(); public abstract boolean getIsCurrent(); public abstract PageItem getParent(); public abstract List&lt;PageItem&gt; getPChildren(); public abstract void setParent(PageItem pageItem); public abstract void addChild(PageItem pageItems); public abstract boolean getHasSelectedChild(); } </code></pre> <p>Here's the implementation :</p> <pre><code>public class PageItemImpl implements PageItem { private String title = ""; private String url = ""; private boolean isCurrent = false; private List&lt;PageItem&gt; children = new ArrayList&lt;PageItem&gt;(); private PageItem parent = null; public String getUrl() { return url; } public boolean getIsCurrent() { return isCurrent; } public List&lt;PageItem&gt; getChildren() { return children; } public PageItem getParent() { return parent; } public void setUrl(String url) { this.url = url; } public void setIsCurrent(boolean isCurrent) { this.isCurrent = isCurrent; } public void setParent(PageItem parent) { this.parent = parent; } public void addChild(PageItem pageItem) { this.children.add(pageItem); } public boolean getHasSelectedChild() { return false; } } </code></pre> <p>Here's the factory :</p> <pre><code>public class PageItemFactory { public static PageItem getPageItem(ABCPage page, ABCRequestParams params) throws ABCException { PageItemImpl pageItem = new PageItemABCImpl(); pageItem.setTitle(page.getTitle()); pageItem.setUrl(page.getUrl()); pageItem.setIsCurrent(params.getUrl().equals(page.getUrl()); return pageItem; } } </code></pre> <p>Is that me or it doesn't make sense?</p> <p>PageItemFactory won't be reusable elsewhere since it has references to ABC framework.</p> <p>Should I just make a class that overrides PageItem and use a constructor for ABC specific parameters?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload