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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T16:48:52+00:00 2026-06-01T16:48:52+00:00

Just as an example, if House is the base class, and Colonial is a

  • 0

Just as an example, if House is the base class, and Colonial is a subclass of House, and Colonial has a method that is goUpstairs. There is another class called Mansion which is also a subclass of House, and Mansion has a method useElevator (say a mansion can have many floors, such as 1 to 35).

Should things start out this way? Or what if after 6 months, there need to be a new class Duplex which is a subclass of House, and also requires a method goUpstairs? If we duplicate the goUpstairs code in Colonial and Duplex, then it is not so DRY (Don’t Repeat Yourself). Should the classes be designed different initially? Or should be it designed differently only after the 6 months and how should it be changed?

  • 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-01T16:48:54+00:00Added an answer on June 1, 2026 at 4:48 pm

    I don’t think it is a good idea to build such an inheritance tree. As you stated it come to a permutational explosion

    Try using “interfaces”

    In java

    public abstract class House {
     ...
    }
    
    public interface HasStairs {
        public boolean putUpstairs (Thing x);
        public boolean putDownstairs (Thing x);
    }
    
    public interface HasElevator {
        public boolean putUp (Thing x);
        public boolean putDown (Thing x);
        public boolean putTo (Thing x, Floor pFloor);
    }
    
    public MyHouseA extends House {}
    
    public MyHouseB extends House implements HasStairs {}
    
    public MyHouseC extends House implements HasElevator {}
    
    public MyHouseD extends House implements HasStairs, HasElevator {}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have models corresponding to database tables. For example, the House class has color,
The example below, is just an example, I know that I don't need an
This is just an example, but given the following model: class Foo(models.model): bar =
I have a custom c# type like (just an example): public class MyVector {
Usually I was doing something like that (just a example): using (Stream xmlStream =
We have two sites, and we've just now made an in-house development server that
Just for example I have next NSDictionary { { first_name = Paul; last_name =
I'm using logos as just an example. I'm trying to use themes/skins for the
Input: $string = this-is-just-an--example Output: this is just an-example Tried various things centered around
I have an array Y of the form(it is just an example, i have

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.