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 3426496
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T06:43:23+00:00 2026-05-18T06:43:23+00:00

firstly, pardon my pseudo-code, i think in this case it is more legible than

  • 0

firstly, pardon my pseudo-code, i think in this case it is more legible than full code. Please assume that a property in the pseudo-code is in fact a field with a getter & setter method, except for the ArticleElement where it just needs be a property accessible from the object either by a direct getter method, or a two step getter method (ie getArticleSource().getName()).

Say i have a template entity:

ArticleTemplate
    Long id;
    String name;
    String description;
    Integer amount;
    Schedule schedule;

and it is used (via its schedule) to create many potential children entities on different dates:

Article
    Long id;
    String name;
    String description;
    Integer amount;
    Date date;
    Boolean complete;
    ArticleTemplate template;

some children entities are not created from a parent, they can be stand-alone (template can be null).

for my UI I want to create a sorted & merged list of :
a) potential children entities from parent entities
b) real children entities previously created from parent entities
c) orphan children entities created stand-alone

however, I need to add some properties to the elements of this list to determine the differences between the elements:

ArticleElement
    // actual value if from Article, null if from potential from ArticleTemplate
    Long id;
    // actual value if from Article or ArticleTemplate
    String name;
    // actual value if from Article or ArticleTemplate
    String description;
    // actual value if from Article or ArticleTemplate
    Integer amount;
    // actual value if from Article, simulated if from potential from ArticleTemplate
    Date date;
    // actual value if from Article, false if from potential from ArticleTemplate
    Boolean complete;
    // actual value (nullable) if from Article, self if from potential from ArticleTemplate
    ArticleTemplate template;
    // false if from Article, true if from potential from ArticleTemplate
    Boolean templateSimulation;
    // once the list is sorted, a running tally of this.amount is to be stored on this object
    Integer runningTally;
    // would be type of interface if Article and ArticleTemplate implement same
    Object source;

Clearly I’m going to have at least 3 classes but there’s a few different approaches with interfaces etc.

I’d like to avoid cloning and property copying wherever possible, and use inheritence wherever beneficial.

suggestions appreciated!

p.

  • 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-18T06:43:23+00:00Added an answer on May 18, 2026 at 6:43 am

    Here’s my current solution, and i’m not sure I like it, but i haven’t come up with anything better just yet:

    firstly, i’ll leave Article and ArticleTemplate alone. I could make them implement an interface describing their similarities but it doesn’t add much benefit for this case.

    create the UI contract

    public interface UiElement<T>
    {
        T getSource();
        Class<T> getType();
        // redundant - refer to source
        // Long getId();
        String getName();
        String getDescription();
        Integer getAmount();
        Date getDate();
        Boolean getComplete();
        // redundant - not needed anymore
        // ArticleTemplate getTemplate();
        // redundant - replaced by getType()
        // Boolean getTemplateSimulation(); 
        Integer getRunningTally();
    }
    

    create implementation for Article – pass through contracted calls to the source object for most properties

    public class ArticleUiElement implements UiElement<Article>
    {
        private Article source;
        private Integer tally;
    
        public ArticleUiElement(Article source) {
            this.source = source;
        }
    
        public Article getSource() {
            return source;
        }
    
        public Class<Article> getType() {
            return Article.class;
        }
    
        public String getName() {
            return source.getName();
        }
    
        public String getDescription() {
            return source.getDescription();
        }
    
        public Integer getAmount() {
            return source.getAmount();
        }
    
        public Date getDate() {
            return source.getDate();
        }
    
        public Boolean getComplete() {
            return source.getComplete();
        }
    
        public String getRunningTally() {
            return tally;
        }
    
        public void setRunningTally(String tally) {
            this.tally = tally;
        }
    }
    

    create implementation for ArticleTemplate – pass through contracted calls to the source object for most properties

    public class ArticleTemplateUiElement implements UiElement<ArticleTemplate>
    {
        private ArticleTemplate source;
        private Integer tally;
        private Date date;
    
        public ArticleTemplateUiElement(ArticleTemplate source) {
            this.source = source;
        }
    
        public ArticleTemplate getSource() {
            return source;
        }
    
        public Class<ArticleTemplate> getType() {
            return ArticleTemplate.class;
        }
    
        public String getName() {
            return source.getName();
        }
    
        public String getDescription() {
            return source.getDescription();
        }
    
        public Integer getAmount() {
            return source.getAmount();
        }
    
        public Date getDate() {
            return date;
        }
    
        public void setDate(Date date) {
            this.date = date;
        }
    
        public Boolean getComplete() {
            return false;
        }
    
        public String getRunningTally() {
            return tally;
        }
    
        public void setRunningTally(String tally) {
            this.tally = tally;
        }
    }
    

    can someone offer improvements, or an entirely better solution?

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

Sidebar

Related Questions

Firstly, I've asked this question elsewhere , but meta.stackoverflow.com seems to think that asking
Firstly, is it possible? Been struggling with this one for hours; I think the
Firstly, let me set out what I'd like to do. Assume I have three
Firstly, I'm a newbie to C# and SharePoint, (less than a month's experience) so
Firstly, I'm pretty new to C++. I believe that getline() isn't a standard C
Firstly, thanks for your help. Here's my situation: I'm trying to edit the code
Firstly, here's my script: #!/usr/bin/python import sys, os sys.path.append('/home/username/python') sys.path.append(/home/username/python/flup) sys.path.append(/home/username/python/django) # more path
Firstly, this is not a question about repository synchronisation for which there are numerous
Firstly, I want to restrict this question to web development only. So this is
Firstly, this seems like (from ContourPlot) a fairly straightforward maximization problem, why is FindMaximum

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.