Solved

8. Explain encapsulation principle.

Posted on 2015-01-23
3
73 Views
Last Modified: 2015-01-25
Explain encapsulation principle.
Provide the best and comprehensive examples/analogues of encapsulation.
0
Comment
Question by:Nusrat Nuriyev
  • 2
3 Comments
 
LVL 86

Assisted Solution

by:jkr
jkr earned 500 total points
ID: 40567779
I am having a hard time doing that better than Wikipedia explains it at http://en.wikipedia.org/wiki/Encapsulation_%28object-oriented_programming%29

In a nutshell, it is the way of only providing necessary information of peering components in a component related or object oriented environment with the background of creating some sort of abstraction in between these components/objects/classes. The basic idea behind that is to allow code changes that don't affect other people's code in the 1st place, since code they wrote on behalf of the classes/objects provided by the author isn't accessible by language design in the 1st place.
0
 

Author Comment

by:Nusrat Nuriyev
ID: 40568110
Yeah, it's hard to explain. I've personally faced with this while trying to explain to my students.
Could you provide childlike explanation? :) Maybe, by providing some analogue from the life :)

>>> The basic idea behind that is to allow code changes that don't affect other people's code in the 1st place
on the 1-st place, you do mean by priority of importance of encapsulation language feature?

Could we say, that encapsulation is kind of language featured code protection mechanism, which defends code which should not be changed, unless you know what you are doing, it protects internal mechanisms of the entity which regular user (for example, another class, what else?) must not be aware of?
0
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
ID: 40568157
>> Could you provide childlike explanation? :)

Hmm, OK, let's think of it like a cople of companies that work together and also compete with each other. So it is necessary for them to offer some access to each other (placing an order or inquiring about one) yet at the same time keep things like balances and resources a secret.

Or, maybe a group of co-workers - while they need to interact, they are trying to keep their salaries a private thing so noone feels envious ;o)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now