<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class="gmail_quote">Enrico Bianchi:<span class=""><br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Per curiosita`, perche` e` visto come un antipattern? Mi va bene anche un po' di letteratura</blockquote></span></div></blockquote><div> </div>Me: <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div><div><div class="gmail_extra">>>> class X(int): pass</div><div class="gmail_extra">>>> type(X()) == int</div><div class="gmail_extra">False</div><div class="gmail_extra">>>> isinstance(X(), int)</div><div class="gmail_extra">True</div><div><br></div><div>vedi: Liskov Substitution Principle</div></div></div></blockquote></div><br><div><div class="gmail_signature"><div>Cmq Scott Meyers in Effective C++ scriveva: </div><div><br></div><div><div>"Anytime you find yourself writing code of the form "if the object is of type T1, then do something, but if it's of type T2, then do something else," slap yourself.</div></div><div><br></div><div>Il che mi sembra abbastanza esplicativo, visto che abbiamo l'OOP: basta fare una inversione.</div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"></blockquote></div></div>
</div></div>