Answer Posted / abalonesoft
Preventing unauthorized access to some piece of information
or functionality.
The key money-saving insight is to separate the volatile
part of some chunk of software from the stable part.
Encapsulation puts a firewall around the chunk, which
prevents other chunks from accessing the volatile parts;
other chunks can only access the stable parts. This prevents
the other chunks from breaking if (when!) the volatile parts
are changed. In context of OO software, a "chunk" is
normally a class or a tight group of classes.
The "volatile parts" are the implementation details. If the
chunk is a single class, the volatile part is normally
encapsulated using the private and/or protected keywords. If
the chunk is a tight group of classes, encapsulation can be
used to deny access to entire classes in that group.
Inheritance can also be used as a form of encapsulation.
The "stable parts" are the interfaces. A good interface
provides a simplified view in the vocabulary of a user, and
is designed from the outside-in (here a "user" means another
developer, not the end-user who buys the completed
application). If the chunk is a single class, the interface
is simply the class's public member functions and friend
functions. If the chunk is a tight group of classes, the
interface can include several of the classes in the chunk.
Designing a clean interface and separating that interface
from its implementation merely allows users to use the
interface. But encapsulating (putting "in a capsule") the
implementation forces users to use the interface.
| Is This Answer Correct ? | 2 Yes | 0 No |
Post New Answer View All Answers
Tell us two differences between new () and malloc ()?
How can you invoke another program from within a C program?
What does nil mean in c?
What are shell structures used for?
design and implement a data structure and performs the following operation with the help of file (included 1000 student marks in 5 sub. and %also) 1.how many students are fail in all 5 subjects (if >35) 2. delete all student data those are fail in all 5 subjects. 3. update the grace marks (5 no. if exam paper is 100 marks) 4. arrange the student data in ascending order basis of marks. 5.insert double of deleted students with marks in the list.
What does %d do?
Explain what is the benefit of using an enum rather than a #define constant?
What does it mean when a pointer is used in an if statement?
Write a program to print all permutations of a given string.
How can I remove the trailing spaces from a string?
What is spark map function?
Why is a semicolon (;) put at the end of every program statement?
What is strcmp in c?
What does c mean?
What is structure of c program?