Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Why Use Interfaces
Message
 
To
10/01/2008 11:06:47
General information
Forum:
ASP.NET
Category:
Class design
Miscellaneous
Thread ID:
01278205
Message ID:
01280911
Views:
31
Perry,

>I don't know if you look at ALL the examples myself and others have shown carefully or not. But several examples did show simulating MI.
>
>Simple example, you have an Employee class. You also want to make this class comparable to each other alphabetically, or by salary grade, etc. You want to make this class sortable also. And you also want to make it Serializable:
>
>public class MyEmployee : Person, IComparable, ISortable, ISerializable
>{
>...
>}


In that example, like most the others, the only reason you need IComparable, ISortable and ISerializable is to use polymorphism


>
>Here's another quick example. Basically, you can use Interfaces to simulate MI to implement multiple, unrelated behaviors in your class:
>
>http://www.codeguru.com/csharp/csharp/cs_syntax/interfaces/article.php/c7563/#more
>
>

I understand the use of Interfaces, well, that is an overstatement, let me rephrase it, I think I understand the use of Interfaces, but I also happen to believe that the over use of it, like in the example you show, can also be bad as the developers might get lazy with the class design in favour of Interfaces that might be more forgiven with design flaws. Let's read his premises "Because Human is the only subclass that has the characteristic of intelligence that distinguishes it from the other subclasses of Mammal" so, if Human is the only subclass that has the characteristic of intelligence, why would I need the Interface? I am sure confused, but it looks as if I can just have those properties and methods in the Human class directly.
"The five senses obstruct or deform the apprehension of reality."
Jorge L. Borges?

"Premature optimization is the root of all evil in programming."
Donald Knuth, repeating C. A. R. Hoare

"To die for a religion is easier than to live it absolutely"
Jorge L. Borges
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform