Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2
Abstraction means hiding how something actually works so you can work with multiple implementations. An example in the C# framework is database connections. You can have a variable of IDbDataConnection (interface) or DbDataConnection (abstract class) that can have any connection type assigned to it. (Assuming they inherit/implement the above types). The main 2 I'm familiar with is Microsoft SQL and Oracle connections, but there are others. Once it's created you don't care what kind of connection it is, as long as it has the Connect, CreateCommand, and whatever other functions there are. Abstraction is also good for Unit Testing. You can abstract away anything that takes outside input from databases or files and swap it with objects that return hardcoded values for testing purposes.
5th Mar 2018, 1:33 AM
Jesse Bayliss
Jesse Bayliss - avatar