Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7644671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T09:44:49+00:00 2026-05-31T09:44:49+00:00

So I have a PageItem object that I want to possibly reuse elsewhere. I’m

  • 0

So I have a PageItem object that I want to possibly reuse elsewhere.
I’m in ABC framework.

Here’s the PageItem interface :

public interface PageItem {

    public abstract String getUrl();

    public abstract boolean getIsCurrent();

    public abstract PageItem getParent();

    public abstract List<PageItem> getPChildren();

    public abstract void setParent(PageItem pageItem);

    public abstract void addChild(PageItem pageItems);

    public abstract boolean getHasSelectedChild();

}

Here’s the implementation :

public class PageItemImpl implements PageItem {

    private String title = "";
    private String url = "";
    private boolean isCurrent = false;
    private List<PageItem> children = new ArrayList<PageItem>();
    private PageItem parent = null;

    public String getUrl() {
        return url;
    }

    public boolean getIsCurrent() {
        return isCurrent;
    }

    public List<PageItem> 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;
    }

}

Here’s the factory :

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;
    }

}

Is that me or it doesn’t make sense?

PageItemFactory won’t be reusable elsewhere since it has references to ABC framework.

Should I just make a class that overrides PageItem and use a constructor for ABC specific parameters?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T09:44:50+00:00Added an answer on May 31, 2026 at 9:44 am

    That depends. There are two main reasons to have a factory:

    1. The object setup is complex.

    2. You need to translate between two independent parts of your application.

    In the first case, the factory knows how to initialize an object so it can be used right away. In the second case, the factory works like a adapter/converter (converts one object type into another).

    Reuse doesn’t matter – in this case, it separates concerns.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some problem with my code public IQueryable<PageItems> GetPageById(Guid Id) { var xml
have written this little class, which generates a UUID every time an object of
Have an issue with marshall and unmarshall readers and writers. So here it is.
Have finally got a responsive site working (of a fashion). What I want to
I have a list like this: <ul> <li class=pageItem>1</li> <li class=pageItem>2</li> <li class=pageItem current>3</li>
I have a menu that links to content on the same page and through
i have ul li structure like below <ul class=lft_mnu id=menu-main-menu> <li class=menu-item menu-item-type-post_type menu-item-object-page
Okay, I have this form and I want to submit a page in the
i have menu structure like below, <ul> <li class=menu-item menu-item-type-post_type menu-item-object-page current-menu-item page_item page-item-1406
I have a tab-like button interface to interact with my site using the following

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.