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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:32:46+00:00 2026-05-26T21:32:46+00:00

I am having a bit of trouble understanding how I will design a class.

  • 0

I am having a bit of trouble understanding how I will design a class.

I want to be able to get n amount of System fields out onto a report alongside custom fields.

I want a simple method on an interface called:

ICollection<Field> GetFieldDefinitions();

Internally this should get all the fields that I need to show on the report.

A second method will return field and their values too:

ICollection<Field> GetFieldDefinitionsWithValues(T src);

T is the source of where the information for each field will be populated from, e.g. if I pass in Company, the field definition if it contains CompanyName, I will do a lookup on the Company table and retrieve the info and add it to the field.

public Class SystemFieldCompany
{
    IDictionary<string,Field> list;
    private readonly ValidationEngine _val;
    public SystemFieldCompany(ValidationEngine val)
    {
      _val = val;
      list = new Dictionary<string,Field>();
    }

    public ICollection<Field> GetFields()
    {

     list.add("id",new Field{name = "id", value = "5"});
     list.add("nameofcompany",new Field{name = "nameofcompany", value = "super guys"});      
     return list.Values;   
    }

    //pass in model object with values on it, set up fields, then pass back all fields
    ICollection<Field> GetFieldsWithValues(T object);
}

Should this class above be a concrete class?
e.g. var fields = new FieldClass().GetFields();

or should I use composition? How can I do this via an interface?

  • 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-26T21:32:46+00:00Added an answer on May 26, 2026 at 9:32 pm

    Abstract Class is what your after

    public abstract class FieldBase
    {
    ICollection<Field> _data=new List<Field>();
    
    abstract void DoValidationOrSomething();
    
    ICollection<Field> virtual GetFields()  //perform validation internally - return back the object 
    {
    DoValidationOrSomething();
    return _data;
    }
    
    T virtual UpdateFields(ICollection<Field> fields);  //pass in model object with values on it, set 
    {
    _data.Clear();
    _data.AddRange(fields);
    }
    up fields, then pass back all fields
    ICollection<Field> virtual GetFieldsWithValues(T object)
    {
    return _data.Where(f=>f.Name=T);
    }
    }
    

    then in your concrete

    public class SomeTable:FieldBase
    {
    public void DoValidationOrSomething()
    {
    //per class validation here
    }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having a bit of a trouble understanding how to fit a particular design
Im having a bit of trouble understanding the more complex system calls in assembly.
I'm having a bit of trouble understanding what the assignment operator is used for
I'm having a bit of trouble understanding how to send a 2D array to
So I'm having a bit of trouble understanding this example that was shown in
I am having trouble understanding the difference between a 32 bit processor and 64
I'm having some trouble understanding a bit of code. I've got 2 classes Company
When designing both the domain-model and class-diagrams I am having some trouble understanding what
I am having a bit of trouble understanding this bug. Here is the code:
I'm new to Java and I'm having a bit of trouble understanding the concept

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.