Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

8. Explain encapsulation principle.

Posted on 2015-01-23
3
Medium Priority
?
94 Views
Last Modified: 2015-01-25
Explain encapsulation principle.
Provide the best and comprehensive examples/analogues of encapsulation.
0
Comment
Question by:Nusrat Nuriyev
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 86

Assisted Solution

by:jkr
jkr earned 2000 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 2000 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

688 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