Thursday 3 May 2018

What is encapsulation?

Purpose:
  • It is likely that interviewers will ask basic object orientation questions just to test whether someone has a solid grasps of the principles behind the the languages.
  • Not being able to answer these questions are massive red flags surrounding a developer's education and grasp of the programming domain.

Potential Answer:
Encapsulation is used to refer to one of two related but distinct notions, and sometimes to the combination thereof:
  • A language mechanism for restricting direct access to some of the object's components.
  • A language construct that facilitates the bundling of data with the methods (or other functions) operating on that data.
What would be good is to talk about keeping classes loosely coupled, and only expose things that you want to share with other classes. Bonus points if you talk about cohesion and keeping the purpose of class very specific. If you talk about Single Responsibility theory you will certainly inspire confidence in the heart of the interviewer.

No comments:

Post a Comment