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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:42:11+00:00 2026-06-10T21:42:11+00:00

Few subclasses extend my abstract Parent class. The subclasses have few the same attributes

  • 0

Few subclasses extend my abstract Parent class. The subclasses have few the same attributes e.g. date. So my question is should I declare the setters and getters for these attributes (date) in my abstract class or just in each subclass?
In one subclass it is “release date” in other “date” so should I “cast” it all to just date?

  • 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-06-10T21:42:12+00:00Added an answer on June 10, 2026 at 9:42 pm

    Depends.

    Many suggests use of composition (ie: Has a) rather than inheritance (ie: Is a). And most of the time, it depends what you want to achieve. There are pros and cons to both approach.

    If you want to put those properties to base class then all classes has those properties, but you are saying not all of them has it. As a good design, if you are not fully populating an object, ie, you leave some fields null or empty, in purpose that is not good. Your object should be fully populated.

    So what you can do is, you can make wrap properties into behaviors (another objects) and delegate them to the classes who want to use those.

    Use your intuition, whichever feels right and simplify your life go with it.

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

Sidebar

Related Questions

Lets say I have an abstract class Cat that has a few concrete subclasses
In Django I have a parent abstract class with a few common fields, and
I have a superclass we can call class A and few subclasses, e.g. class
I have to make a trivial class that has a few subclasses and one
I have a class, called Permissions , it has a few subclasses (and some
I have an object model that contains a class with several subclasses. The subclasses
I have a few QGraphicsScene subclasses CustomScene all deriving from a common interface that
Few days back I put a question regarding mapping two classes Message and MessageStatusHistory
Few basic doubts I have: 1. Is primary key column automatically indexed? 2. What
I have few custom controls (image views) added programmatically to table cell. I want

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.