<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
    <title>jodal.dev - scala</title>
    <subtitle>Personal blog of Stein Magnus Jodal</subtitle>
    <link rel="self" type="application/atom+xml" href="https://jodal.dev/tags/scala/atom.xml"/>
    <link rel="alternate" type="text/html" href="https://jodal.dev"/>
    <generator uri="https://www.getzola.org/">Zola</generator>
    <updated>2011-03-15T00:00:00+00:00</updated>
    <id>https://jodal.dev/tags/scala/atom.xml</id>
    <entry xml:lang="en">
        <title>Traits in Python using multiple inheritance</title>
        <published>2011-03-15T00:00:00+00:00</published>
        <updated>2011-03-15T00:00:00+00:00</updated>
        
        <author>
          <name>Unknown</name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://jodal.dev/2011/03/15/traits-in-python-using-multiple-inheritance/"/>
        <id>https://jodal.dev/2011/03/15/traits-in-python-using-multiple-inheritance/</id>
        
        <summary type="html">&lt;p&gt;As you probably know, if a class needs to handle two mostly unrelated concerns, the
class should probably be split into two. This way, your will achieve
&lt;a rel=&quot;external&quot; href=&quot;http://en.wikipedia.org/wiki/Cohesion_(computer_science)&quot;&gt;higher cohesion&lt;/a&gt; in your
code, which is generally considered a good thing. Though, there are times where
you need to address two mostly unrelated concerns in a single class.&lt;/p&gt;
&lt;p&gt;The Scala programming language has a concept they call
&lt;a rel=&quot;external&quot; href=&quot;http://www.scala-lang.org/node/126&quot;&gt;traits&lt;/a&gt;. Scala traits can be compared to
Java interfaces, except that Scala traits may be partially or fully
implemented, like abstract classes. As with Java interfaces, you can &lt;em&gt;mixin&lt;/em&gt;
multiple traits in a class. If any of the traits has colliding method
signatures, the last trait mixed in overrides the earlier ones. Just as with
regular inheritance and interfaces, the class &lt;em&gt;must&lt;/em&gt; implement any methods that
has not been implemented by the traits, and &lt;em&gt;may&lt;/em&gt; override any methods that
already has been implemented.&lt;/p&gt;</summary>
        
    </entry>
</feed>
