Send Close Add comments: (status displays here)
Got it!  This site uses cookies. You consent to this by clicking on "Got it!" or by continuing to use this website.nbsp; Note: This appears on each machine/browser from which this site is accessed.
Modules and encapsulation


1. Modules and encapsulation

2. Modules and encapsulation
As programs became larger, it became more important to be able to share libraries of code.

There are various ways to share code.

Older languages such as Fortran had ways to create code libraries.

3. Modules and name spaces
A module or namespace is a way to encapsulate data and code.

4. API
An API (Application Program Interface) is a way to interact with code. In 2019, the United States Supreme Court agreed to hear a case of Google vs. Oracle whereby Oracle claims that the Java API is protected under copyright law - which to date has not been the case.

5. C
The C programming language introduced a simple way to share code.

6. Drawbacks
The drawbacks of this approach include the following.

7. Java
Java has no name spaces as such. Instead, classes are used to encapsulate namespaces.

This can make Java somewhat tedious to use as all classes need to be in a separate file.

Some languages, such as C#, have namespaces whereby multiple related classes can reside in the same file.

8. End of page

9. Acronyms and/or initialisms for this page