< Day Day Up > |
Now that we have a general understanding about some of the differences about procedural and object-oriented technologies, let's delve a bit deeper into both. Procedural ProgrammingProcedural programming separates the data of the program from the operations that manipulate the data. For example, if you want to send information across a network, only the relevant data is sent (see Figure 1.4), with the expectation that the program at the other end of the network pipe knows what to do with it. In other words, some sort of handshaking agreement must be in place between the client and server to transmit the data. In this model, no code is actually sent over the wire. Figure 1.4. Data transmitted over a wire.
OO ProgrammingThe fundamental advantage of OO programming is that the data and the operations that manipulate the data (the code) are both encapsulated in the object. For example, when an object is transported across a network, the entire object, including the data and behavior, goes with it. In Figure 1.5, the Employee object is sent over the network. Figure 1.5. Objects transmitted over a wire.
Proper Design A good example of this concept is a Web object, such as a Java applet. The browser has no idea of what the Web object will do. When the object is loaded, the browser executes the code within the object and uses the data contained within the object. |
< Day Day Up > |