Understanding Abstraction for beginners
I came across this weird term while learning C# a few days back, and to be honest, it slowed down my brain to a crawl. I had heard that word before of course, abstract art is a surprisingly common term for this generation. Though to look at the word abstraction in programming like abstraction in art is rather unhelpful imo. Trust me I have tried.
So, I began on the journey to see example and tutorials on classes and objects, on my way to learning OOP, but on the way, a moment similar to "Eureka" hit me. You know, the moments when the thing finally clicks in, and you wonder why did it not hit you before? This was a similar moment for me.
Declaimer: Now before I go on to tell you what this eureka moment was, let me warn you, I am NOT a experienced programmer. What I tell you had helped me to think about the word abstraction, but it may be incorrect. In fact, maybe I myself would scoff at the innocence of my younger naive self after a few years. Please try to not be enraged if you are a professional and spot what I say is wrong (though, now I think about it, experienced programmers reading my blog would probably make my day itself).
Abstraction - a tool for visualization
Now think of objects, classes and interfaces. What do they all have in common? According to people at microsoft "An abstraction is a type that describes a contract but does not provide a full implementation of the contract". Thus things like classes make a contract but does not provide a full implementation of it. In words of Rob Miles, they are just promises (he specifically says interfaces are just promises, but interfaces are just one way of doing abstraction). Classes similarly acts as a cookie cutter for your object (source: pluralsight)
Now why would a sane human(wait are programmers sane?) just describe something but not fully describe it? Not that the programmer can skip implementing the code, he HAS to implement it. So what would the names of chapters be doing in the book instead of just the contents?
Yeah, you already know the answer, but cannot say it in words. So, here let me phrase it for you, these all help us to **visualize **the requirements. Classes help you visualize the structure and function of an object, interfaces help you visualize the structure of classes. Index help you to visualize the book. See, ain't everything much simpler now?
I wish I had known this earlier, but no matter, at least now you, the dear reader, can visualize what abstraction is now.