What is the difference between an interface and a class, and why I should use an interface when I can implement the methods directly in the class?

Interfaces are excellent when you want to create something like it: using System; namespace MyInterfaceExample { public interface IMyLogInterface { //I want to have a specific method that I’ll use in MyLogClass void WriteLog(); } public class MyClass : IMyLogInterface { public void WriteLog() { Console.Write(“MyClass was Logged”); } } public class MyOtherClass : IMyLogInterface … Read more

Abstraction VS Information Hiding VS Encapsulation

Go to the source! Grady Booch says (in Object Oriented Analysis and Design, page 49, second edition): Abstraction and encapsulation are complementary concepts: abstraction focuses on the observable behavior of an object… encapsulation focuses upon the implementation that gives rise to this behavior… encapsulation is most often achieved through information hiding, which is the process … Read more