What is Encapsulation?
In the realm of computer networking, the term encapsulation is utilized to include data from an upper layer protocol in to a protocol on a lower layer. Such a method of abstraction through networking allows many different layers to add on functionality and features.
The World Wide Web, for instance, is based on the Internet Protocol. The vast majority of applications utilize either the Transmission Control Protocol or the User Datagram Protocol. Thus, a lot of user data is then encapsulated in to the form of a UDP datagram, which is subsequently encapsulated in to the form of an Internet Protocol packet. The packet is then transmitted over a data link layer protocol, such as Ethernet.
The data link layer takes care of the physical transmission of the data. The Internet Protocol adds the addresses of individual computers and the UDP adds on “application addressing,” which is the port that specifies the service, like a TFTP or web server.
Encapsulation is utilized both by the Internet protocol suite and the OSI model. In the process of encapsulation, the more abstract layer is referred to as the upper layer protocol. The more specific layer is known as the lower layer protocol.
Service Encapsulation & Loose Coupling
Loosely coupled application parts should be able to readily put the scissors right in to the structure of the Business without disrupting supporting Information Technology systems. At the same time, the synchronous command and control nature of Service Oriented Architecture is one method of tightly coupling application components that do not allow for such a wide degree of flexibility. Service Oriented Architecture can be loosely coupled in the technical domain, where common web services technology is utilized, but it is not really in the functional domain where Service Oriented Architecture may be associate with calling foreign services and thus eliminating the redundancies of data.
The availability of stored data and services might be made to disappear after an act of outsourcing, which might lead to costly consequences and major risks. All this has to do with the creation of dependencies via Service Oriented Architecture. So in a way, Service Oriented Architecture’s promise of delivering loose coupling, which tends to be asynchronous, can at the functional level be regarded as hype.
Encapsulation in Object Oriented Programming
Object Oriented Programming can be viewed as a programming paradigm that utilizes objects in order to design computer programs and design applications. Several techniques are employed from an array of previously established paradigms, including encapsulation, inheritance, polymorphism, and modularity. It was not commonly employed in mainstream software application development until the last decade, although a lot of modern programming languages are capable of supporting Object Oriented Programming.
The roots of Object Oriented Programming extend back to the ‘60s, during which time the nascent field of software engineering had begun to play around with the idea of a software crisis. As hardware and software both continued to develop and grow in complexity, how could the quality of software be maintained? Object oriented programming thus addresses this problem through a strong emphasis of modularity in software.
Object Oriented Programming is frequently viewed as a collection of objects that cooperate. This is different than the popular view of a program as a list of instructions to a computational device. When it comes to Object Oriented Programming, each object is able to receive messages, send messages, and process to data. Every object is capable of being viewed as an independent tiny machine that plays a specific role or has a particular responsibility.
Encapsulation works to hide the details of how a specific class functions from objects that utilize its code or might send messages to it. So the Dog class, to use our previous example, has a bark () method. The code for this bark () method defines exactly how the bark comes about (i.e. through inhale () and exhale () at a specific volume and pitch.) Timmy, Lassie’s friend, does not need to know exactly how Lassie barks, though. Encapsulation is thus attained by spelling out which classes may utilize the members of an object. The result is that each object exposes to a class a specific interface – which can be those members that are accessible to a particular class.
The purpose of encapsulation is the prevention of interface clients from depending on those bits of an implementation that may change in the future, thus allowing such changes to be made in a simpler fashion, without making any changes to the clients.