Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

So what's the difference between a mixin and an abstract base class?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Alpha_ProgDes   Crossbones+   -  Reputation: 3306

Like
0Likes
Like

Posted 03 September 2012 - 02:51 PM

Based on everything that I've read on both, they seem to do the exact same thing. They both can be inherited but not instantiated. They're both for code reuse. They both provide implementations and can be used polymorphically.

So what am I missing here?

Beginner in Game Development? Read here.  

 

Super Mario Bros clone tutorial written in XNA 4.0 [MonoGame, ANX, and MonoXNA] by Scott Haley

 

If you have found any of the posts helpful, please show your appreciation by clicking the up arrow on those posts smile.png
 

Spoiler

Sponsor:

#2 Telastyn   Members   -  Reputation: 3331

Like
2Likes
Like

Posted 03 September 2012 - 04:39 PM

In certain languages, a mix-in or trait has special limitations that allow it to be multiply inherited sanely.

In general, a mix-in is a standalone set of functionality that is tacked onto something, whereas an abstract base class represents a incomplete implementation of a core concept. In C++ (and a few other languages), these are done using the same construct. From a design perspective and from a conceptual perspective they're different.

#3 GlenDC   Members   -  Reputation: 468

Like
1Likes
Like

Posted 04 September 2012 - 05:08 AM

Found some useful websites that may help you:A quote from dsimcha on another webpage:

At a language-agnostic level, a mixin just adds functionality to a class, and is more for programmer convenience and to avoid code duplication. An abstract (base) class forms an is-a relationship and allows for polymorphism. One reason why inheritance is overused is that it's an easy way to implement mixins without writing any boilerplate in languages that don't really support them. The problem is that you're declaring a polymorphic is-a relationship as a side effect, making your API more confusing and possibly adding ambiguity. Hence, newer languages like D and Ruby support mixins as native features, allowing a convenient way to add a bunch of functionality to a class without declaring a polymorphic is-a relationship.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS