$theTitle=wp_title(" - ", false); if($theTitle != "") { ?>
One Stop Computer Science
1 Jan // php the_time('Y') ?>
Concept of Abstraction
Encapsulation Construct
–Some means of organization, other than simply division into subprograms
–Some means of partial compilation (compilation units that are smaller than the whole program)
Nested Subprograms
Encapsulation in C
Encapsulation in C++
–The class is used as the interface (prototypes)
–The member definitions are defined in a separate file
The danger of C’s approach to encapsulation:
There are two problems with this approach. First, the documentation of the dependence of the client program on the library (and its header file) is lost. Second, the author of the library could change the header file and the implementation file, but the client could attempt to use the new implementation file (not realizing it had changed) but with the old header file, which the user had copied into his or her client program.
Naming Encapsulation
–Can place each library in its own namespace and qualify names used outside with the namespace
–C# also includes namespaces
–Packages can contain more than one class definition; classes in a package are partial friends
–Clients of a package can use fully qualified name or use the import declaration
Similarities between Java Packages dan C++ Namespace:
1) Java Packages are namespaces system while C++ also has namespace
2) Both are abstract containers for classes
3) Java Packages and namespaces provide breakup for class names
4) both make the code cleaner and less redundant, by enabling some
parts of the code.
Difference between Java Packages and C++ Namespace:
1) Java packages are about modules meanwhile, in C++ namespaces are just about partitioning the available names.
2) In Java language, namespaces are intended to avoid conflicts between names in different parts of class libraries.
3) C++ namespaces have an extra way to encapsulate stuff within an already existing system.
Access to the contents of a module is requested with the require method.
Leave a reply