<div dir="ltr"><div class="gmail_default" style="">(looks like you forgot to reply to the list)</div><div class="gmail_default" style=""><br></div><div class="gmail_default" style="font-family:monospace,monospace"><span style="font-family:arial,sans-serif">On Sun, Oct 29, 2017 at 7:47 AM, Greg Ewing </span><span dir="ltr" style="font-family:arial,sans-serif"><<a href="mailto:greg.ewing@canterbury.ac.nz" target="_blank">greg.ewing@canterbury.ac.nz</a>></span><span style="font-family:arial,sans-serif"> wrote:</span><br></div><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">Koos Zevenhoven wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
It looks like you can just as easily drive the car without having the key<br>
</blockquote>
<br></span>
That's been found to be a problem in real life, too.<br>
More than one Python-programming car thief has been<br>
caught with this function in their personal library:<br>
<br>
def hotwire(car):<br>
car.engine.start()</blockquote><div><br></div><div class="gmail_default" style="font-family:monospace,monospace">Yes, but my point was still about what the public API is. Starting the car with the key should be easier than starting it without the key. Surely you should be able to start the engine without the key if you look under the hood and figure it out. And maybe you'd need a tool for that to be kept in your garage for debugging, but not as a button attached to the outside of the car or on the dashboard :-).</div><div class="gmail_default" style="font-family:monospace,monospace"><br></div><div class="gmail_default" style="font-family:monospace,monospace">The problem becomes even worse if you instead make Car inherit from its parts (including Engine), because the relationship of a car and and engine is not well described by inheritance. A car is not a kind of engine, nor should it pretend to be an implementation of an engine. A car *comprises* (or contains) an engine. And who knows, maybe it has two engines!</div><div class="gmail_default" style="font-family:monospace,monospace"><br></div><div class="gmail_default" style="font-family:monospace,monospace">-- Koos</div></div><div><br></div><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">+ Koos Zevenhoven + <a href="http://twitter.com/k7hoven" target="_blank">http://twitter.com/k7hoven</a> +</div>
</div></div>