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

  • Home
  • SEARCH
  • 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 96387
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T23:48:25+00:00 2026-05-10T23:48:25+00:00

I have 6 classes, which are all document types. All the document types have

  • 0

I have 6 classes, which are all document types. All the document types have the same 8 fields. There is one class which consists of only these 8 fields. The rest of the classes have more fields. Some of these classes have the same fields (beside the 8 fields).

Example:

class Document: fields 1 to 8

class Form: fields 1 to 8 and field 9 and 10

class WorkInstruction: fields 1 to 8 and field 9 and 10

class Procedure: fields 1 to 10 and field 11

Hopefully this will make clear my point.

My question is, what is the best way to implement this? Should i make one or more interfaces, or should i use abstract classes?

Thnx

  • 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. 2026-05-10T23:48:25+00:00Added an answer on May 10, 2026 at 11:48 pm

    Either make Document the base type of Form etc, or make a form have the extra fields and a reference to a separate Document (i.e. use composition instead of inheritance). In this case it sounds like inheritance would quite possibly be the best option, but it really depends on what you want to do with it. Do you have code which is meant to work on any document, including Form, WorkInstruction etc?

    EDIT: For example, suppose you have a user interface control which can show the common parts of any document – i.e. the common 8 fields. That would take an instance of Document. You may want to be able to pass a Form or WorkInstruction to it directly – in which case it’s best to derive from Document. Alternatively, when rendering a Form or WorkInstruction, you could create an instance of the control passing in the document part separately. i.e. it’s the difference between this (in C# – you haven’t specified which language you’re interested in):

    class Form : Document { ... }  // Later on Controls.Add(new DocumentDisplay(form)); 

    and this:

    class Form {     private Document Document { get; set; }     // Other stuff }  // Later on Controls.Add (new DocumentDisplay(form.Document)); 

    Without knowing the rest of your design, it’s hard to recommend one or the other. I usually prefer composition over inheritance, but this feels like more of a natural inheritance situation.

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

Sidebar

Ask A Question

Stats

  • Questions 57k
  • Answers 57k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer If you're wanting to replicate the data, not just set… May 11, 2026 at 8:27 am
  • added an answer Since your question is 2 months old, I presume your… May 11, 2026 at 8:27 am
  • added an answer window.open('http://www.google.com', 'mywindow', 'location=0,toolbar=0'); See this site for more attributes. May 11, 2026 at 8:27 am

Top Members

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

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

MEILI PLUGIN ACTIVE

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.