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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T19:44:35+00:00 2026-06-01T19:44:35+00:00

I was reading a blog post here: http://codeofdoom.com/wordpress/2009/02/12/learn-this-when-to-use-an-abstract-class-and-an-interface/ public interface Actor{ Performance say(Line l);

  • 0

I was reading a blog post here: http://codeofdoom.com/wordpress/2009/02/12/learn-this-when-to-use-an-abstract-class-and-an-interface/

public interface Actor{
   Performance say(Line l);
}
public interface Director{
   Movie direct(boolean goodmovie);
}
public interface ActorDirector extends Actor, Director{
...
}

It says:
In reality, there are Actors who are also Directors. If we are using interfaces rather than abstract classes.We could achieve the same thing using abstract classes. Unfortunately the alternative would require up to 2^n (where n is the number of attributes) possible combinations in order to support all possibilities.

Question: why abstract class is better here ? and why 2^n ?

public abstract class ActorDirector implements Actor,Director{
}
  • 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-01T19:44:36+00:00Added an answer on June 1, 2026 at 7:44 pm

    I think you misunderstood the post: the author is not arguing that an abstract class is better in this situation – on the contrary, he is arguing that an interface is a better fit.

    As far as 2^n (or more precisely 2^n-1) goes, the number comes from realization that if you have n orthogonal behavior contracts, you can make 2^n-1 non-empty combinations from them. If you use interfaces to add contracts to classes that implement them, you need only as many interfaces as there are behaviors: the user will be able to make combinations of behaviors that he chooses to implement, up to 2^n-1. If you were to try achieving the same flexibility with abstract classes, you would end up creating not only your desired implementations, but also all the intermediate ones required all the way to a single root, because Java lets you inherit classes only one at a time.

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

Sidebar

Related Questions

Just finished reading this blog post: http://www.skorks.com/2010/03/an-interview-question-that-prints-out-its-own-source-code-in-ruby/ In it, the author argues the case
I am reading a post about mobile web development and ASP.NET MVC here: http://www.hanselman.com/blog/ABetterASPNETMVCMobileDeviceCapabilitiesViewEngine.aspx
After reading this blog post: http://www.sitepoint.com/javascript-shared-web-workers-html5/ I don't get it. What's the difference between
I was reading this example: http://blog.ondrejsv.com/post/AppSettingsReader-and-reading-typed-and-nullable-application-settings.aspx and I noticed in this line of code:
I'm reading through Rob Ashton's excellent blog post on RavenDB: http://codeofrob.com/archive/2010/05/09/ravendb-an-introduction.aspx and I'm working
After reading Steve Sandersons post on swf upload. http://blog.stevensanderson.com/2008/11/24/jquery-ajax-uploader-plugin-with-progress-bar/ I have implemented the swf
I'm following this tutorial here: http://brenelz.com/blog/implementing-paging-using-php-and-jquery/ Here is what I have: http://eataustineat.com/testingfolder/ I've encountered
I was reading this blog post: http://www.shakie.co.uk/ramblings/feature-driven-development-riding-the-waves-of-change/ and came across the part about TestDox:
Reading this blog post about HttpOnly cookies made me start thinking, is it possible
Should be an easy one. I thought, from reading this blog post that I

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.