Explaining OOP keywords to CSO
I was called into CSO (Chief Strategy Officer)'s office one day and out of nowhere to explain some C# keywords. I wasn't sure if he was asking me because he didn't know or to test me. far as I know, He had a technical background and was a programmer himself at one point in his career.
If you know OOP (Object Oriented Programming), you are bound to run into the keywords many times. But explaining WHY they are created was something totally different. Image - "WHY?" by Martin Deutsch, used under CC BY-NC-ND 2.0 / Dropped Quality to 60
He asked me, why they are used and create in the first place.
As a first attempt, I explained to him that the keywords were to encapsulate data and to prevent users from accessing functionalities in code. The response was that he didn't get it.
The second attempt was to be more specific by showing him that "internal" hides a class/method outside current DLL while "protected" hides data/methods from other classes not deriving from it, and "private" from any other classes.
But alas, he wanted a simpler answer. I was started to feel dejected.
Before my next attempt, I mulled over it while blankly staring at the whiteboard. After few minutes, a light bulb finally went off in my head.
Those keywords were created to do the same thing; they just work on different levels of abstractions. "Internal" is for package level, while "private" & "protected" for class levels.
He finally gave me an OK and let me go.
I've reached a deeper understanding of those keywords after a short meeting.
The CSO probably called to teach me how to think and reach to an understanding, not to learn about C# keywords.