Browse By

Abstract classes VS interfaces

Ενα απο τα ερωτηματα που ισως σας δημιουργηθουν κατα την εκμαθηση της C# ειναι στο τι διαφερουν οι Abstract classes με τα Interfaces. Η απλουστερη απαντηση που βρηκα ειναι στο δωρεαν βιβλιο του Robert Miles “CSharp Yellow Book” στην σελιδα 117. Αναφερει ακριβως: 

“You might decide that an abstract class looks a lot like an interface. This is true, in that an interface also provides a “shopping list” of methods which must be provided by a class. However, abstract classes are different in that they can contain fully implemented methods alongside the abstract ones. This can be useful because it means you don’t have to repeatedly implement the same methods in each of the components that implement a particular interface. The problem is that you can only inherit from one parent, so you can only pick up the behaviours of one class. If you want to implement interfaces as well, you may have to repeat methods as well.”

Το συγκεκριμενο βιβλιο ειναι απο τα διαμαντια που κυκλοφορουν στο διαδικτυο. Το προτεινω ανεπιφυλακτα. Μπορειτε να το κατεβασετε δωρεαν απο το site του δημιουργου.

Leave a Reply

Your email address will not be published. Required fields are marked *