Nearly in all of the "Abstraction" principle definitions, it says sth. like "Hiding the irrelevant (or extra, not needed to know) codes from the user". And I could not get how this is about "abstraction".
Let's say "This is because we can define the methods in the base abstract classes, and we can use these methods after we created the objects in child classes without knowing the internal functionality" But we could already have base non-abstract classes for this purpose. We could have already created objects and used the functionality of the base class without knowing the internal structure of those methods. How is this feature belongs to "abstraction" ????
The main advantage of creating an abstract base class over a non-abstract base class is, that it can not be instantiated; so it is just be there for creating a "common concept", right? But other than that, i don't see a difference between them in the sense of hiding the internal structure.
Let's say I have 2 types of coffee-machine; CheapMachine
and ExpensiveMachine
. I created a non-abstract base class and added several methods with definitions like StartMachine()
, GetOptimumHeat()
, etc. And then I created a CheapMachine
instance CP
, and called these methods easily, without knowing the internal functionality of these methods.
So, did I use abstraction principle by just creating a base class then?
I am confused like I feel I got the main idea but what would be the best description of this principle? For ex., How would you describe this principle in an interview?