Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 59

SIBUGAY TECHNICAL INSTITUTTE INCORPORATED

Lower Taway, Ipil, Zamboanga


Sibugay www.sibugaytech.edu.ph
sibugaytech07@gmail.com

School President: Academic Dean:


09171271826/09171271902 09064393454
Registrar: 09178967194 Guidance Coach:
DSA: 09351190287 09497510953

IT 12
INTEGRATIVE
PROGRAMMING AND
TECHNOLOGIES
LEARNER'S MODULE
UNIT-FINAL PERIOD

TEACHER/S CONTACT NO.


EARL VON V. 09364181623
DEIPARINE

Student's
Name

Contact
Number

1
UNIT COVERAGE

Chapter 1 Week 1-2 - Introduction to Integrative Programming and Technologies. . . . . . .


.3-15 Week 3 - UNIT EXAMINATION WEEK

PRELIM COVERAGE

Chapter 2Week 4-5 - Web Services and Middleware; Network programming;


Low level data communications Message and queuing
services. . . . . . . . . . . . . . . . . . . . . 16-25 Week 6 - PRELIM EXAMINATION WEEK

MIDTERM COVERAGE

Chapter 3Week 7-8 - Data Mapping and Exchange. . . . . . . . . . . . . . . . . . . . . . .


. . . . . . . .26-36 Week 9 - MIDTERM EXAMINATION WEEK

PRE-FINAL COVERAGE

Chapter 4Week 10 - XSL, XSLT and


XPATH. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .37-46 Week 11 - PRE-
FINAL EXAMINATION WEEK

FINAL COVERAGE

Chapter 5 Week 12 - Integrative Coding: Design Patterns;Interfaces; Inheritance.


Miscellaneous Issues: Adopt and Adapt vs. make;Versioning and version
control. . . . . . .47-55 Week 13 - FINAL EXAMINATION WEEK

2
Teacher: Earl Von V. Deiparine
Contact #: 09364181623
CHAPTER Facebook Account: Earl von Deiparine

1
Email Add.: deiparineefreak@gmail.com

Unit Period

Introduction to Integrative
Programming &
Technologies

Course Learning Outcome:

At the end of the semester, the students will be able to:

1. Discuss the Introduction to Integrative Programming and Technologies;


2. Explain integrative technologies or methods used in application integration; and
3. Evaluate the different types of middleware and how the middleware solves
problem of heterogeneity.

3
Definition:

Integration of software refers to techniques for combining existing software components to form
a complete system. However, the software integration includes at least one existing software
system, developed in the past with no plan for its symmetric integration with another component
in the future.

Integrative programming deals with an integration approaches and techniques that connect
different components of IT infrastructure- people, applications, platforms and databases to
enable a secure, intra and inter application collaboration. Integrative solutions enable an
organization to integrate business processes internally and externally with business partners to
create dynamic environments that supports current and evolving business requirements, thereby
creating a global organization.

Application integration assists in unlimited sharing of data and business processes among
any connected applications or data sources in without making major changes to the applications
or data structures. Hence, integration is the process of connecting multiple, independently
developed applications using incompatible technologies into a single organization wide system
with information flowing seamlessly among the integrated systems or components.

Most of the applications that run in organizations’ hardly live in isolation. Whether the
registrar application must interface with the finance application, the human resource
management application must connect to each other, it seems like any application can be
made better by integrating it with other applications.

Integration of multiple, independently developed, managed and maintained applications


components that may normally use incompatible technologies and heterogeneous platforms”
enables transmission of information between applications, automates flow of data between
applications that make up the business process flow. Integration is the process of combining
separate applications into cooperating collections of application.

Overview of inter system communication

Inter-system communication is the communication between a set of heterogeneous systems that


are integrated together. These integrated systems which put together many heterogeneous
set of subsystems and the produced objects are extremely different, yet should contribute to
the same process. Software integration includes one or more of the following.

System integration

Given two or more systems, subsystems or components, each of which function properly
(satisfying their requirement within their environment). The problem is to integrate them into one
larger system satisfying the combined requirements within the newly formed environment.
Functional integration or technology integration

Given a software system, this may have been functioning properly in the field for 4a
significant period. The problem is to integrate a new function or a new technology
within the system. The integrated
system should provide the new functionality or use the new technology, while preserving the
original system functionality.

Incremental engineering

A software system can be developed and delivered using available technologies and with
less functionality than it is intended to finally provide. New technologies and or more functions
then can be integrated within the system. The problem is to design the system with such future
integration in mind.

Modification

Sometimes an existing and properly functioning software system must be decomposed and
integrated to carry out modification.

The need for integration


Most of organizations consist of more than one department, running department specific
applications and those applications interact with each other to achieve the overall objective of the
organizations.
Information systems change overtime by growing in their size, incorporating functionality of the
existing
standalone systems. Applications originally intended to operate separately, later on are required
to interoperate with others. Some of the reasons for integration are the following;

 Technology change affects all layers; legacy does not go away so easily.
 The architecture of the organization information system depends on constraints related to
the technology but also to the organization.
 Within an enterprise, each department may have its own IT infrastructure, systems
and databases which are maintained independently. Integrating them may bring additional
value to the company.
 Integration assists in formation of Zero Latency organization - when all functions within
the organization work with the same up-to-date information, latency between
applications is eliminated/ reduced.
 Updating and integrating of applications is possible whenever required. New applications
can be created by integrating real time data from different parts of the enterprise

5
Integration models

Integration model defines how applications will be integrated by defining the nature of and
mechanisms for integration. Some of the methods used for application integration are discussed
in the following section. These models include;

 Presentation integration
 Data integration and
 Function integration

1. Presentation integration model allows the integration of new software through the
existing presentations of the legacy software. This is typically used to create a new user
interface but may be used to integrate with other applications.

2. Data integration model allows the integration of software through access to the data
that is created, managed and stored by the software typically for the purposes of
reusing or synchronizing data across applications.

3. Functional integration model allows the integration of software for the purpose of
invoking existing functionality from other new or existing applications. The integration is
done through interfaces to the software.

Fundamental Challenges of Integration


To support common business processes and data sharing across applications, these applications
need to be integrated. Application integration needs to provide efficient, reliable and secure data
exchange between multiple enterprises applications.

A lot of the problems to be addressed in Organizations Application Integration system


from having to integrate standalone applications which have been developed
independently, operate autonomously, and were not originally indented to be integrated with
one another.

Integration of applications, developed by different languages and running on


different computing platforms is not an easy task. By definition, integration has to deal
with multiple applications running on multiple platforms in different locations, making
the term ‘simple integration’ pretty much difficult. Software vendors offer application
integration suites that provide cross-platform, cross-language integration as well as
the ability to interface with many popular packaged business applications.
However, this technical infrastructure presents only a small portion of the integration
complexities. The true challenges of integration span far across business and technical
issues. All integration solutions have to deal with a few fundamental challenges: some of
the challenges of integration are;
6
 Network unreliability
 Distributed systems
 Slow networks and
 Heterogeneity
 Modification complexity

1. Network is unreliable. Integration solutions have to transport data from one


computer to another across networks. Compared to a process running on a
single computer, distributed computing has to be prepared to deal with a much
larger set of possible problems. Often times, two systems to be integrated are
separated by continents and data between them has to travel through phone-lines,
LAN segments, routers, switches, public networks, and satellite links. Each of
these steps can cause delays or interruptions.

2. Distributed– in the worst case, every application runs on a completely separate


environment, e.g., database storage is not shared among applications. Message-
based communication is the only possibility to exchange information.

3. Networks are slow. Sending data across a network is multiple orders of


magnitude slower than making a local method call. Designing a widely distributed
solution the same way you would approach a single application could have
disastrous performance implications.

4. Any two applications are different. Integration solutions need to transmit information
between systems that use different programming languages, operating platforms, and data
formats. An integration solution needs to be able to interface with all these different
technologies. Heterogeneous– each application implements its own data model. Concepts
may be shared, but representation mismatches are to be expected. Mappings and
transformations are required.

5. Change is inevitable. Applications change over time. An integration solution has to keep
pace with changes in the applications it connects. Integration solutions can easily get
caught in an avalanche effect of changes – if one system changes, all other systems
may be affected. An integration solution needs to minimize the dependencies from one
system to another by using loose coupling between applications. Autonomous –
applications update their state independently without coordinating with each other.
The systems to be integrated are maintained independently and upgraded at different
times.

7
Integrative Technologies/methods for integration
Application integration is an integration framework composed of a collection of technologies
and services which form a middleware or "middleware framework" to enable integration of
systems and applications across organizations. There are four methods used in application
integration, which are discussed in the section below:

1. File Transfer- one application writes a file that another later reads. The applications
need to agree on the filename and location, the format of the file, the timing of when it will
be written and read, and who will delete the file.

2. Shared Database- multiple applications share the same database schema, located
in a single physical database. Because there is no duplicate data storage, no
data has to be transferred from one application to the other.

3. Remote Procedure Invocation - one application exposes some of its functionality


so that it can be accessed remotely by other applications as a remote procedure.
The communication occurs real-time and synchronously.

4. Messaging - one application publishes a message to a common message


channel. Other applications can read the message from the channel at a later
time. The applications must agree on a channel as well as the format of the
message. The communication is asynchronous. All of the four approaches solve
essentially the same problem in integration; each style has its distinct advantages
and disadvantages. In fact, applications may integrate using multiple styles such
that each point of integration takes advantage of the style that suits it best.

File transfer

An organization naturally, runs multiple applications that are being built independently, with
different languages and platforms. How can we integrate multiple applications so that they work
together and can exchange information and interact with each other? The answer for this
question is given below;

One of the possible solutions to allow these applications to be integrated is allowing each
application produce files containing information that other applications need to consume.
Integrators take the responsibility of transforming files into different formats. Produce the files at
regular intervals according to the nature of the business, which can be consumed or read by
another file.

An important decision with files is what format to use. Very rarely will the output of one
application be exactly what's needed for another, so you'll have to do a fair bit of
processing of files along the way. Not just do all the applications that use a file
have to read it, you also have to be able to use processing tools on it.
8
Shared Database
A common data base can be used for integrating applications. A single physical data base can
be shared by different applications running on different platforms. This method integrates
applications by having them store their data in a single shared database.

If a family of integrated applications all rely on the same database, then we can be pretty
sure that they are always consistent all of the time. If we do get simultaneous updates to
a single piece of data from different sources, then we have transaction management
systems that handle that about as gracefully as it ever can be managed.

9
Remote procedure calls
This method develops each application which is required to be integrated as a large-scale
object or component with encapsulated data. And it provides an interface to allow other
applications to interact with the running application.

Remote Procedure Invocation applies the principle of encapsulation to integrating


applications. If an application needs some information that is owned by another
application, it asks that application directly. If one application needs to modify the data
of another, then it does so by making a call to the other application. Each application can
maintain the integrity of the data it owns. Furthermore, each application can alter its
internal data without having every other application be affected.

10
Messaging

Messaging allows interaction between applications possible. Message passing can be used to
transfer packets of data frequently, immediately, reliably, and asynchronously, or
synchronously using customizable formats.

Asynchronous messaging is fundamentally a practical reaction to the problems of


distributed systems. Sending a message does not require both systems to be up and
ready at the same time. Furthermore, thinking about the communication in an
asynchronous manner forces developers to recognize that working with a remote
application is slower, which encourages design of components with high cohesion
(lots of work locally) and low adhesion (selective work remotely).

The reason a messaging system is needed to move messages from one computer to
another is that computers and the networks that connect them are inherently unreliable.
Just because one application is ready to send a communication does not mean that the
other application is ready to receive it. Even if both applications are ready, the
network may not be working, or may fail to transmit the data properly. A
messaging system overcomes these limitations by repeatedly trying to transmit the
message until it succeeds. Under ideal circumstances, the message is transmitted
successfully on the first try, but circumstances are often not ideal.

In essence, a message is transmitted in five steps:

1. Create - the sender creates the message and populates it with data.
2. Send - the sender adds the message to a channel.
3. Deliver - the messaging system moves the message from the sender’s computer to
the receiver’s computer, making it available to the receiver.
4. Receive - the receiver reads the message from the channel.
5. Process - the receiver extracts the data from the message.

11
This diagram illustrates these five transmission steps, which computer performs each, and which
steps involve the messaging system:

This diagram also illustrates two important messaging concepts:

1. Send and forget - in step 2, the sending application sends the message to the
message channel. Once that send is complete, the sender can go on to other work while
the messaging system transmits the message in the background. The sender can be
confident that the receiver will eventually receive the message and does not have to wait
until that happens.

2. Store and forward - in step 2, when the sending application sends the message to
the message channel, the messaging system stores the message on the
sender’s computer, either in memory or on disk. In step 3, the messaging system
delivers the message by forwarding it from the sender’s computer to the receiver’s
computer, and then stores the message once again on the receiver’s computer.
This store-and-forward process may be repeated many times, as the message is
moved from one computer to another, until it reaches the receiver’s computer.

12
Middleware and Integrative architectures
Middleware is a software programming running at the top of operating system and below
the applications. It connects applications or software components. Middleware provides a
standard high level interface to the application developers and integrators, so that application can
easily interoperate. Interoperability is the ability of two or more components or systems to
exchange information.

There are three types of middleware. These are, transaction-oriented, object-oriented and
message oriented middleware.

1. Transaction-oriented middleware: supports distributed computing involving


database applications.

2. Message-oriented middleware: supports reliable, asynchronous communications


between distributed components or applications.

3. Object-oriented middleware: systems are based on object-oriented paradigm, and


primarily support synchronous communications between distributed objects or software
components. Examples are CORBA, DCOM and RMI.

13
Integrative architectures
Integrative architectures are the standard methodologies for application integration.
These architectures include, CORBA, DCOM and RPC. The architectures act as a middleware,
a software application that mediates between different applications.

Common Object Request Broker Architecture

CORBA is a software standard that is defined and maintained by the Object Management
Group (OMG). The Common Object Request Broker Architecture (CORBA) is a standard
architecture for a distributed objects system. CORBA is designed to allow distributed objects
to interoperate in a heterogeneous environment, where objects can be implemented in different
programming language and/or deployed on different platforms.

DCOM

Distributed component object model- extends the COM to support communication between
objects. DCOM is a software architecture or remote protocol that defines a binary standard for
component interoperability.

DCOM is a software architecture that allows applications to be built from binary software
components. Is binary interface standard for software components, that allows inter-
process communication. Binary interface is a program interface between binary program
modules often one of the module is library or operating system and the other is user
program module. Defines how computational routines are called in machine code or low-
level which is hardware independent.

14
Review Questions

1. Define integrative programming?

2. Explain the architectures used in application integration?

3. Describe interoperability?

4. What are the challenges in application integration describe the solutions to overcome
the challenges?

5. Describe the difference between CORBA and RMI or remote method invocation?

6. Explain integrative technologies or methods used in application integration?

7. What is the difference between data level and function level integration model? Which
model is more complex and why?

8. What is heterogeneity?

9. Describe different types of middleware and describe how the middleware solves problem
of heterogeneity?

15
Teacher: Earl Von V. Deiparine
Contact #: 09364181623
CHAPTER Facebook Account: Earl von Deiparine

2
Email Add.: deiparineefreak@gmail.com

Prelim Period

Web Services and Middleware; Network


programming;
Low level data communications
Message and queuing services

Course Learning Outcome:

At the end of the semester, the students will be able to:

1. Describe the Web Services and Middleware;


2. Identify the parts of Network Programming; and
3. Modify a low level data communications message and queuing
services.

16
Web Services and Middleware
 application integration technology
 Allows applications to be integrated more rapidly, easily and less
 expensively
 program-to- program interactions whereas web for program-to-
user
 interactions
 allow companies to reduce the cost of doing e-business, to
deploy
 solutions faster and to open up new opportunities
 Web services model built on emerging standards such as
 HTTP
 XML
 Simple Object Access Protocol (SOAP)
 Web Services Description Language (WSDL)
 Universal Description, Discovery and Integration (UDDI)
 developed in order to distribute an object and serve it to various
users
 in the web environments
 used in the server situations while solving the web-scalability
problem
 of the other distributed object technologies
 WSDL, and SOAP exploit XML.
 WSDL is an XML describing the web service.
 SOAP is an XML describing the called method, its parameters,
and its
 return value, can be delivered over the HTTP

17
Web Services and
Middleware

1. A client that wants to be serviced should first find the supported services from the pre-
existing
registry before compiling a code.

2. After finding its services through searching, the client gains the WebService
Description Language (WSDL) that a server previously registers. From the WSDL, the
client knows the service provider location and the parameters to the found method.

3. After the client binds the described service during the compile time, it calls the
local agent whenever the client invokes a method call, and the local agent
delivers it to the server side agent through Simple ObjectAccess Protocol (SOAP)
over HTTP, FTP, SMTP, and TCP during the runtime.

4. The server side agent activates the appropriate object, and deliversthe calls to the
object.

18
Network Programming
Network:
 A network is a collection of computers and other devices that can send data to and
receive data from each other.
 A network is often connected by wires.
 However, wireless networks transmit data through infrared light and microwaves.

Node:
 Each machine on a network is called a node.
 Most nodes are computers, but printers, routers, bridges, gateways etc..can also be
nodes.
 Nodes that are fully functional computers are also called hosts.

Packet:
 All modern computer networks are packet-switched networks: data traveling on the
network is
broken into chunks called packets and each packet is handled separately.
 Each packet contains information about who sent it and where it's
going.

Protocol:
 A protocol is a precise set of rules defining how computers
communicate: the format of
 addresses, how data is split into packets.

IP:
 IP was designed to allow multiple routes between any two points andto route packets
of data around damaged routers.

TCP:
 Since there are multiple routes between two points, and the packetsthat make up
a particular data stream.
 Furthermore, they may not arrive in the order they were sent, if theyeven arrive at all.

UDP:
 UDP is an unreliable protocol that does not guarantee that packets willarrive at
their destination or that they will arrive in the same orderthey were sent.

Ports:
 Each computer with an IP address has several thousand logical ports.
 Each port is identified by a number between 1 and 65,535. Each port canbe allocated
to a particular service.
 Port numbers 1 through 255 are reserved by IP for well-known servicesIf you
connect to
port 80 of a host, for instance, you may expect to findan HTTP server. 19
Internet:
 largest IP-based network for connecting machines together.
 Java: easy-to-use, cross-platform model for network communications.

What is a Socket?
 Sockets are a means of using IP to communicate between machines, so
socketsallow Java to interoperate with legacy systems by simply talking to
existingservers using their pre-defined protocol.
 Internet protocol: User Datagram Protocol (UDP) and Transmission
Control Protocol (TCP).

Internet Addresses or IP Addresses


 Every network node has an address, a series of bytes that uniquely
identify it.
 Internet addresses are manipulated in Java by the use of the InetAddress
class.InetAddress takes care of the Domain Name System (DNS) look-up and
reverselook-up;
 IP addresses can be specified by either the host name or the raw IP address.
InetAddress provides methods to getByName(), getAllByName(),getLocalHost(),
getAddress(), etc.
 IP addresses are a 32-bit number, often represented as a "quad" of four 8-bit
numbers separated by periods.
 They are organized into classes (A, B, C, D, and E). For example
126.255.255.255
Client/Server Computing- Java language communicate with remote file system.

How UDPclients and UDPservers communicate over


sockets Creating UDP Servers:

To create a server with UDP, do the following:

1. Create a DatagramSocket attached to a port.


int port = 1234;
DatagramSocket socket = new
DatagramSocket(port);

2. Allocate space to hold the incoming packet, and create an instance of DatagramPacket to
hold theincoming data.
byte[] buffer = new byte[1024];
DatagramPacket packet = new DatagramPacket(buffer, buffer.length);

3. Block until a packet is received, then extract the information you need from the packet.
// Block on receive()
socket.receive(packet);
// Extract the packet data
byte[] data = packet.getData(); 20
// Find out where packet came from
// so we can reply to the same host/port
InetAddressremoteHost =
Creating UDP Clients

1. First allocate space to hold the data we are sending and create an instanceof
DatagramPacket to hold the data.
byte[] buffer = new byte[1024];
int port = 1234;
InetAddress host =
InetAddress.getByName("magelang.com"); DatagramPacket
packet = new DatagramPacket(buffer, buffer.length, host,
port);

2. Create a DatagramSocket and send the packet using this socket.


DatagramSocket socket = new DatagramSocket();//free local port
touse socket.send(packet);
// Find out where we are sending from
InetAddresslocalHostname =
socket.getLocalAddress(); int localPort =
socket.getLocalPort();

How TCPclients and TCPservers communicate over


socketsCreating TCP Servers:

To create a TCP server, do the following:

3. Create a ServerSocket attached to a port


number.
ServerSocket server = new ServerSocket(port);

2. Wait for connections from clients requesting


connections to that port.
// Block on accept()
Socket channel = server.accept();
You'll get a Socket object as a result of the
connection.

3. Get input and output streams associated with the


socket. out = new PrintWriter
(channel.getOutputStream()); out.println("Hey! I
heard you over this socket!");
reader = new InputStreamReader
(channel.getInputStream());
in = new BufferedReader (reader);
Now you can read and write to the socket, thus,
communicating with the client.
String data = in.readLine();
21
Creating TCP Clients:

To create a TCP client, do the following:

1. Create a Socket object attached to a remote host, port.


Socket client = new Socket(host, port);
When the constructor returns, you have a connection.

2. Get input and output streams associated with the


socket. out = new PrintWriter
(client.getOutputStream()); out.println("Watson!" +
"Come here...I need you!");
reader = new InputStreamReader
(client.getInputStream());
in = new BufferedReader (reader);
Now you can read and write to the socket, thus,
communicating with theserver.
String data = in.readLine();
Low Level Data Communication
TCP/IP(Transmission Control Protocol/Internet Protocol)
 The Protocol upon which the whole Internet is based
 Each node must be configured for TCP/IP to function properly.
 A software-based protocol
 TCP/IP is basically the binding together of Internet Protocols used toconnect hosts on
the internet- Main ones are IP and TCP
 TCP and IP have special packet structure
 IP (Internet Protocol) is responsible for delivering packets of databetween systems on
the internet and specifies their format. Packetsforwarded based on a four byte
destination IP address (IP number)IP DOES NOT MAKE GUARANTEES! It is
very simple - essentially:sendand forget.
 TCP (Transmission Control Protocol) is responsible for verifying the correct delivery
of data/packets from client to server. Data can be lost. So TCP also adds support to
detect errors and retransmit data untilcompletely received.

22
IP Packet
Structure

 Version - Indicates the version of IP currently used.


 IP Header Length (IHL) - Indicates the datagram header length in 32-bit words.
 Type-of-Service - Specifies how an upper-layer protocol would like a current datagram
tobe handled, and assigns datagram various levels of importance.
 Total Length - Specifies the length, in bytes, of the entire IP packet, including the
dataand header.
 Identification - Contains an integer that identifies the current datagram. This field is
usedto help piece together datagram fragments.
 Flags - Consists of a 3-bit field of which the two low-order (least-significant)
bits controlfragmentation. The low-order bit specifies whether the packet can be
fragmented. Themiddle bit specifies whether the packet is the last fragment in a series
of fragmented packets. The third or high-order bit is not used.
 Fragment Offset - Indicates the position of the fragment’s data relative to the beginningof
the data in the original datagram, which allows the destination IP process to
properlyreconstruct the original datagram.
 Time-to-Live - Maintains a counter that gradually decrements down to zero, at whichpoint
the datagram is discarded.
 Protocol - Indicates which upper-layer protocol receives incoming packets after
IPprocessing is complete.
 Header Checksum - Helps ensure IP header integrity.
 Source Address - Specifies the sending node.

23
 Destination Address - Specifies the receiving node.
 Options - Allows IP to support various options, such as
security.
 Data - Contains upper-layer sent in packet.

TCP Packet Structure

There are 12 fields in TCP Packet:

 Source Port and Destination Port - Identifies points at which upper layer source
and destination processes receive TCP services.
 Sequence Number In the connection-establishment phase, this field also can be used
to identify an initial sequence number to be used in an upcoming transmission.
 Acknowledgment Number - Contains the sequence number of the next byte of data
the sender of the packet expects to receive.
 Data Offset - Indicates the number of 32-bit words in the TCP header.
 Reserved - Remains reserved for future use.
 Flags - Carries a variety of control information, including the SYN and ACK bits used
for connection establishment, and the FIN bit used for connection termination.
 Window - Specifies the size of the sender’s receive window (that is, the buffer space
available
for incoming data).

24
 Checksum - Indicates whether the header was damaged in
transit.
 Urgent Pointer - Points to the first urgent data byte in the
packet.
 Options - Specifies various TCP options.
 Data - Contains upper-layer sent in packet.

25
Teacher: Earl Von V. Deiparine
Contact #: 09364181623
CHAPTER Facebook Account: Earl von Deiparine

3
Email Add.: deiparineefreak@gmail.com

Midterm Period

Data Mapping and


Exchange

Course Learning Outcome:

At the end of the semester, the students will be able to:

1. Discuss Data Mapping and Exchange;


2. Define a Complex Element using XML Scheme; and
3. Create XML Schemas by Using XML Schema-Creation
Tools.

26
XML DTD and XML Schema
How does an XML processor check your xml document?

There are twomain checks that XML processorsmake:

1. Checking that your document is well-formed (Syntax rule)


2. Checking that it's valid (syntax-check your XML either in XML DTD orXSD)
DTD- DocumentType
Definition XSD-XMLSchema
Definition

Why needXMLValidator
 Use our XML validator to
syntax-check your XML.
 Errors in XML documents will
stop your XML applications
unlike HTMLbrowser

XML DTD
 An XML document with correct
syntax is called "Well
Formed".
 An XML document validated
against a DTD is "Well
Formed" and "Valid".
 The purpose of a DTD is to define the structure of an XML document anda list
of legal elements.

How you add a DTD to our XML document


1. DTDs can be separate documents (or )
2. They can be built into anXML documentusing a special element named <!
DOCTYPE>.

An XML Document with a DTD (example4.xml)


<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="css1.css"?>
<!DOCTYPE document
[ <!ELEMENT document (heading, message)><!
ELEMENT heading (#PCDATA)><!ELEMENT message
(#PCDATA)>
]>
<document>
<heading> Hello From XML </heading><message> This is
27
an XML document! </message>
</document>
Valid XML Document with DTD (example.5.xml)

The DOCTYPE declaration is a reference to an external DTD file "Note.dtd“


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE note SYSTEM "Note.dtd">
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>

Note.dtd
<!DOCTYPE
note [
<!ELEMENT
note
(to,from,heading
,body)>
<!ELEMENT to
(#PCDATA)>
<!ELEMENT
from
(#PCDATA)>
<!ELEMENT
heading
(#PCDATA)>
<!ELEMENT
body
(#PCDATA)>
]>

The DTD above


is interpreted
like this:

 !
DOCTYP
E note
defines
that the
root
element
of the
document
is note
 !ELEMENT note defines that the note element contains four elements:"to, from, 28
heading, body"
 !ELEMENT to defines the two element to be of type "#PCDATA"
XML Schema
 Another way of validating XML documents: using XML schemas.
 The XML Schema language is also referred to as XML Schema Definition(XSD),
describes the structure of an XML document.
 defines the legal building blocks (elements and attributes) of an XML document like DTD.
 defines which elements are child elements
 defines the number and order of child elements
 defines whether an element is empty or can include text
 defines data types for elements and attributes
 defines default and fixed values for elements and attributes

XML Schemas will be used in most Web applications as a replacement

forDTDs. Here are some reasons:


 XML Schemas are extensible to future additions
 XML Schemas are richer and more powerful than DTDs
 XML Schemas are written in XML
 XML Schemas support data types and namespaces

Creating XML Schemas by Using XML Schema-Creation Tools


 HiT Software
 xmlArchitect
 XMLspy
 XML Ray
 Microsoft Visual Studio .NET

XSD Simple Element


 The syntax for defining a simple element
 Default and Fixed Values for Simple Elements

XSD Attributes
 The syntax for defining an attribute
 Default and Fixed Values for Attributes
 Optional and Required Attributes

XSD Complex Elements


 How to Define a Complex Element using XML Scheme
 XSD Empty Elements

29
XSD Indicators
Order indicators are:
 All
 Choice
 Sequence

XSD Simple Element


 A simple element is an XML element that can contain only text.
 It cannot contain any other elements or attributes.
 XML Schema has a lot of built-in data types. The most common types are:
1. xs:string
2. xs:decimal
3. xs:integer
4. xs:boolean
5. xs:date
6. xs:time

The syntax for defining a simple element is:


<xs:element name="xxx" type="yyy"/>
Example
<lastname>Refsnes</lastname>
<age>36</age>
<dateborn>1970-03-27</dateborn>
<xs:element name="lastname" type="xs:string"/>
<xs:element name="age" type="xs:integer"/>
<xs:element name="dateborn" type="xs:date"/>

Default and Fixed Values for Simple Elements

Simple elements may have a default value or a fixed value specified.


1. A default value is automatically assigned to the element when no other value is specified.
<xs:element name="color" type="xs:string" default="red"/>
2. A fixed value is also automatically assigned to the element, andyou cannot specify
another value.
<xs:element name="color" type="xs:string" fixed="red"/>

30
XSD Attributes
 Simple elements cannot have attributes.
 If an element has attributes, it is considered to be of a complex type. But theattribute
itself is always declared as a simple type.

The syntax for defining an attribute is:


<xs : attribute name="xxx" type="yyy"/>

Example
<lastnamelang="EN">Smith</lastname>
<xs:attribute name="lang" type="xs:string"/>

Default and Fixed Values for Attributes


Attributes may have a default value or a fixed value specified.
<xs:attribute name="lang" type="xs:string" default="EN"/>
<xs:attribute name="lang" type="xs:string" fixed="EN"/>

Optional and Required Attributes


Attributes are optional by default. To specify that the attribute is required, usethe "use"
attribute:
<xs:attribute name="lang" type="xs:string" use="required"/>

XSD Complex Elements


 A complex element is an XML element that contains other elements and/or attributes.
 There are four kinds of complex elements:

Example:
1. A complex XML element, "product", which is empty: <product pid="1345"/>
2. A complex XML element, "employee", which contains only other elements:
<employee>
<firstname>John</firstname>
<lastname>Smith</lastname>
</employee>
3. A complex XML element, "food", which contains only text:
<food type="dessert">Ice cream</food>
4. A complex XML element, "description", which contains both elements and text:
<description>
It happened on <date lang=“EN">03.03.99</date>
</description>

31
How to Define a Complex Element using XML Scheme

 Complex XML element, "employee", which contains only other elements:


<employee>
<firstname>John</firstname>
<lastname>Smith</lastname>
</employee>
 The "employee" element can be declared directly by naming the element:
<xs:element name="employee">
<xs:complexType>
<xs:sequence>
<xs:element name="firstname" type="xs:string"/>
<xs:element name="lastname" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
 An empty complex element cannot have contents, only attributes.
<product prodid="1345" />
 It is possible to declare the "product" element more compactly:
<xs:element name="product">
<xs:complexType>
<xs:attribute name="prodid" type="xs:positiveInteger"/>
</xs:complexType>
</xs:element>
 XSD Indicators
 How elements are to be used in documents with indicators.
 Order indicators are used to define the order of the elements.They are:
1. All
2. Choice
3. Sequence

All Indicator:
 The <all> indicator specifies that the child elements can appear in any order, and that
each childelement must occur only once:
<xs:element name="person">
<xs:complexType>
<xs:all>
<xs:element name="firstname" type="xs:string"/>
<xs:element name="lastname" type="xs:string"/>
</xs:all>
</xs:complexType>
</xs:element>

32
Choice Indicator:
 The <choice> indicator specifies that either one child element or another can occur:
<xs:element name="person">
<xs:complexType>
<xs:choice>
<xs:element name="employee" type="employee"/>
<xs:element name="member" type="member"/>
</xs:choice>
</xs:complexType>
</xs:element>

Sequence Indicator:
 The <sequence> indicator specifies that the child elements must appear in a specific
order:
<xs:element name="person">
<xs:complexType>
<xs:sequence>
<xs:element name="firstname" type="xs:string"/>
<xs:element name="lastname" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>

XML Example (“note.xml”)


<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>

XSD Example (“note.xsd”)


<xs:element name="note">
<xs:complexType>

<xs:sequence>
<xs:element name="to" type="xs:string"/>
<xs:element name="from" type="xs:string"/>
<xs:element name="heading" type="xs:string"/>
<xs:element name="body" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>

33
Example (shiporder.xml):
<?xml version="1.0" encoding="ISO-8859-1"?>
<shiporderorderid="889923">
<orderperson>John Smith</orderperson>
<shipto>
<name>Ola Nordmann</name>
<address>Langgt 23</address>
<city>4000 Stavanger</city>
<country>Norway</country>
</shipto>
</shiporder>

Example "shiporder.xsd":
<?xml version="1.0" encoding="ISO-8859-1" ?>
<xs:schemaxmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="shiporder">
<xs:complexType>
<xs:sequence>
<xs:element name="orderperson" type="xs:string"/>
<xs:element name="shipto">
<xs:complexType>
<xs:sequence>
<xs:element name="name" type="xs:string"/>
<xs:element name="address" type="xs:string"/>
<xs:element name="city" type="xs:string"/>
<xs:element name="country" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="orderid" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
</xs:schema>

XML Parser (Parsing XML documents)


 All modern browsers have a built-in XML parser.
 An XML parser converts an XML document into an XML DOM object which can
then be manipulated with JavaScript.

34
Parse an XML Document
The following code fragment parses an XML document into an XML
DOMobject: if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET","books.xml",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;

XML DOM
 The XML DOM defines a standard
way for accessing and
manipulatingXML documents.
 The XML DOM views an XML
document as a tree-structure.
 All elements can be accessed
through the DOM tree.
 Their content (text and attributes) can be modified or deleted, andnew elements can
be created.
 The elements, their text, and their attributes are all known as nodes.

The HTML DOM


 The HTML DOM defines a standard way for accessing and manipulatingHTML
documents.
 All HTML elements can be accessed through the HTML DOM.

Load an XML File - Cross-browser


 parses an XML document ("note.xml") into an XML DOM object and then extracts
some information from it with a JavaScript:

Example
<html>
<body>
<span id="to"></span>
<span id="from"></span>
<span id="message"></span>
<script>
if (window.XMLHttpRequest)
{ // code for IE7+, Firefox, Chrome, Opera, 35
Safari xmlhttp=new XMLHttpRequest();
}
else
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET","note.xml",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;
document.getElementById("to").innerHTML=
xmlDoc.getElementsByTagName("to")[0].childNodes[0].nodeValue;
document.getElementById("from").innerHTML=
xmlDoc.getElementsByTagName("from")[0].childNodes[0].nodeValue;
document.getElementById("message").innerHTML=
xmlDoc.getElementsByTagName("message")[0].childNodes[0].nodeValue;
</script>
</body>
</html>

36
Teacher: Earl Von V. Deiparine
Contact #: 09364181623
CHAPTER Facebook Account: Earl von Deiparine

4
Email Add.: deiparineefreak@gmail.com

Prefinal Period

XSL, XSLT and XPATH

Course Learning Outcome:

At the end of the semester, the students will be able to:

1. DefineXSL, XSLT and XPATH;


2. Explain XSL, XSLT and XPATH and how does it work;
and
3. Create XPATH Expression with result.

37
XSL
 XSL stands for EXtensibleStylesheet Language.
 It is anXML-based Stylesheet Language.
 XSL describes how the XML document should be displayed
 XSL consists of three parts:
 XSLT - a language for transformingXML documents
 XPath - a language for navigating inXML documents
 XSL-FO - a language for formatting XML documents

XSLT
 XSLT stands for XSLTransformations,
 XSLT transforms an XML source-tree into an XML result-tree.
 XSLT transforms an XML document into another XML document, recognized by a browser,
like HTML and XHTML.
 Add/remove elements and attributes to or from the output file.
 Rearrange and sort elements, perform tests and make decisions about which elements to
hide and display, and a lot more.
 XSLT uses XPath to find information in an XML document.
 XPath is used to navigate through elements and attributes in XML documents.

How Does it Work?


 In the transformation process, XSLT uses XPath to define parts of thesource document
that should match one or more predefinedtemplates.
 When a match is found, XSLT will transform the matching part of the source document into
the result document.
All major browsers such as Internet Explorer,Chrome, Firefox, Safari andOpera supports XML,
XSLT,
and XPath

The XML File


<?xml version="1.0" encoding="UTF-8"?>
<catalog>
<cd>
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<country>USA</country>
<company>Columbia</company>
<price>10.90</price>
<year>1985</year>
</cd>
.
.
</catalog>
38
XSLT <xsl:stylesheet> Element
 defines that this document is an XSLT style sheet document (along withthe version number
and XSLT namespace attributes).

XSLT <xsl:template> Element


 An XSL style sheet consists of one or more set of rules that are calledtemplates.
 A template contains rules to apply when a specified node is matched.
 The <xsl:template> element is used to build templates.

XSLT match attribute


 The match attribute is used to associate a template with an XMLelement.
 The match attribute can also be used to define a template for the entireXML document.
 The value of the match attribute is an XPath expression (i.e. match="/"defines the
whole document).

<xsl:stylesheet version="1.0" xmlns:xsl="


http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
// some output
</xsl:template>
</xs:stylesheet>
XSLT <xsl:value-of> Element
 used to extract the value of an XML element and add it to the outputstream of
the transformation

XSLT select attribute


 contains an XPath expression. An XPath expression works like navigating a file
system; a forward slash (/) selects subdirectories.

XSLT <xsl:for-each> and <xsl:sort> Element


 <xsl:for-each>element to loop through the XML elements, and displayall of the records.
 The <xsl:sort>element is used to sort the output.
 To sort the output, simply add an <xsl:sort> element inside the <xsl:foreach>element in the
XSL file:
<xsl:for-each select="catalog/cd">
<xsl:sort select="artist"/>
<xsl:value-of select="title"/>
<xsl:value-of select="artist"/>
</xsl:for-each>

39
The XML File
<?xml version="1.0" encoding="UTF-8"?>
<catalog>
<cd>
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<country>USA</country>
<company>Columbia</company>
<price>10.90</price>
<year>1985</year>
</cd>
.
.
</catalog>

<?xml version="1.0" encoding="UTF-8"?>


<xsl:stylesheet version="1.0" xmlns:xsl="
http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>My CD Collection</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th>Title</th>
<th>Artist</th>
</tr>
<xsl:for-each select="catalog/cd">
<xsl:sort select="artist"/>
<tr>
<td><xsl:value-of select="title"/></td>
<td><xsl:value-of select="artist"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

40
XSLT <xsl:if> Element
 The <xsl:if> element is used to put a conditional test against the content ofthe XML file.
 Syntax
<xsl:if test="expression">
...some output if the expression is true...
</xsl:if>
 To add a conditional test, add the <xsl:if> element inside the <xsl:for-each> element in the
XSL file.
 The value of the required test attribute contains the expression to be evaluated.

<?xml version="1.0" encoding="UTF-8"?>


<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>My CD Collection</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th>Title</th>
<th>Artist</th>
</tr>
<xsl:for-each select="catalog/cd">
<xsl:if test="price &gt; 10">
<tr>
<td><xsl:value-of select="title"/></td>
<td><xsl:value-of select="artist"/></td>
<td><xsl:value-of select="price"/></td>
</tr>
</xsl:if>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

41
XSLT <xsl:choose> Element
 The <xsl:choose> element is used in conjunction with <xsl:when> and<xsl:otherwise>
to express multiple conditional tests.
 Syntax
<xsl:choose>
<xsl:when test="expression">
... some output ...
</xsl:when>
<xsl:otherwise>
... some output ....
</xsl:otherwise>
</xsl:choose>
To insert a multiple conditional test against the XML file, add the<xsl:choose>, <xsl:when>,
and
<xsl:otherwise> elements to the XSL file:

<?xml version="1.0" encoding="UTF-8"?>


<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>My CD Collection</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th>Title</th>
<th>Artist</th>
</tr>
<xsl:for-each select="catalog/cd">
<tr>
<td><xsl:value-of select="title"/></td>
<xsl:choose>
<xsl:when test="price &gt; 10">
<td bgcolor="#ff00ff">
<xsl:value-of select="artist"/></td>
</xsl:when>
<xsl:otherwise>
<td><xsl:value-of select="artist"/></td>
</xsl:otherwise>
</xsl:choose>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
42
XSLT <xsl:apply-templates> Element

 The <xsl:apply-templates> element applies a template to the currentelement or it's


child nodes.
 If we add a select attribute to the <xsl:apply-templates> element it will process only
the child element that matches the value of the selectattribute.
 We can use the select attribute to specify the order in which the childnodes are
processed.
 Sometime XSL Style Sheet may have multiple matches
<xsl:template match="cd">
<p>
<xsl:apply-templates select="title"/>
<xsl:apply-templates select="artist"/>
</p>
</xsl:template>

XSLT <xsl:apply-templates> Element Con…


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>My CD Collection</h2>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>
<xsl:template match="cd">
<p>
<xsl:apply-templates select="title"/>
<xsl:apply-templates select="artist"/>
</p>
</xsl:template>
<xsl:template match="title">
Title: <span style="color:#ff0000">
<xsl:value-of select="."/></span> // attribute to specify the current node
<br />
</xsl:template>
</xsl:stylesheet>

43
XML and XPath

 XPath is a syntax for defining parts of an XML document


 XPath uses path expressions to navigate in XML documents
 XPath contains a library of standard functions
 XPath is also used in XSLT, XQuery, XPointer and XLink
 Without XPath knowledge you will not be able to create XSLTdocuments.
 XPath is a W3C recommendation
 there are various types of legal XPath expressions:
 Node sets-indicates what type of node you want to match
 Booleans-use the built-in XPath logical operators to produce
Booleanresults.
Besides Boolean values, XPath can also work with node sets.
<xsl:template match="state[position() > 3]">
<xsl:value-of select="."/>
</xsl:template>
 Numbers- use numbers in expressions
<xsl:apply-templates select="state[population div area > 200]"/>
 Strings-XPath functions are specially designed to work on strings
 Wildcard -to select element nodes
 *-Matches any element node
 @*-Matches any attribute node
 node() -Matches any node of any kind

44
Path Resul
Expression t
//book/title | //book/price document
Selects all the title AND price elements of /bookstore/book/title | //price
all book Selects all the title elements of the
elements book element of the
//title | //price bookstore element AND all the price
Selects all the title AND price elements in elements
the in the
documen
t
Path Resul
Expression t
/bookstore/* Selects all the child nodes of //* Selects all elements in the document
the bookstore element //title[@*] Selects all title elements which
have
any attribute

Exampl Resul
e t
child::book Selects all book nodes that descendant::book Selects all book
are children of the current node descendants of the current node
attribute::lang Selects the lang attribute of ancestor::book Selects all book ancestors
the of
current node the current node
child::* Selects all element children of ancestor-or-
the current node self::book
attribute::* Selects all attributes of the Selects all book ancestors of the current
current node - and the current as
node well if it is a book node
child::text() Selects all text node children of child::*/child::price Selects all
the current node price
child::node() Selects all children of the grandchildren of the current node
current
node

45
XPath Axes

 defines a node-set relative to the current node.


 XPath supports many different axes listed:
 ancestor - contains the ancestors of the context node. Anancestor node is the
parent of the context node,the parent of the parent, and so forth, back to
(andincluding) the root node.
 ancestor-or-self - contains the context node and the ancestorsof the context node.
 Attribute - contains the attributes of the context node.
 Child - contains the children of the context node.
 Descendant - contains the descendants of the context node. Adescendant is
a child or a child of a child and so on.
 descendant-or-self - contains the context node and the descendants ofthe context
node.

XPath Axes Con…

 following - contains all nodes that come after the contextnode.


 following-sibling - contains all the following siblings of the contextnode.
 namespace - the namespace nodes of thecontext node.
 parent - contains the parent of the context node.
 preceding - contains all nodes that come before the contextnode.
 preceding-sibling - contains all the preceding siblings of the contextnode.
 self - contains the context node.

Node Sets

 By collecting nodes into a set, XPath lets you work with multiple nodes at once.
 Node set functions:
 last() - Returns the number of nodes in the node set.
 position() - Returns the position of the context node in thenode set. (The first
node is Node 1.)
 count(node-set) - Returns the number of nodes in node-set.
 id(ID) - Returns a node set that contains the elementwhose ID value matches ID.
 local-name(node-set) - Returns the name of the first node in node-set.
 namespace-uri (node-set) - Returns the URI of the namespace of the firstnode in
node set.
 name(node-set) - Returns thequalified name of the first node innode-set.

46
Teacher: Earl Von V. Deiparine
Contact #: 09364181623
CHAPTER Facebook Account: Earl von Deiparine

5
Email Add.: deiparineefreak@gmail.com

Final Period

Integrative Coding: Design Patterns;


Interfaces;Inheritance.
Miscellaneous Issues:
Adopt and Adapt vs. make;
Versioning and version
control
Course Learning Outcome:

At the end of the semester, the students will be able to:

1. Describe Integrative Coding and Miscellaneous Issues;


2. Explain the different parts of Integrative Coding and Miscellaneous Issues;
and
3. Integrate Coding with Abstract Class and Inheritance in Java.

47
Design Patterns
 Design pattern:
 A Lower level framework for structuring an application than architectures
(Sometimes, called micro-architecture).
 Reusable collaborations that solve sub problems within an application.
 Why Design Patterns?
 Design patterns support object-oriented reuse at a high level of abstraction
 Design patterns provide a “framework” that guides and constrains object-
oriented implementation

Design Patterns Description


Template

48
Organizing Design Patterns
The Gang of Four (GoF) Design Patterns book describes twenty-threepatterns arranged into
three groups.
 The groups help classify how the patterns are used.

1. Creational patterns : used to help make a system independent of how itsobjects


are created, composed and represented.

2. Structural patterns are concerned with how classes and objects areorganized
and composed to build larger structures.

3. Behavioral patternsare used to deal with assignment of responsibilities to objects


and communication between objects.

Example for Design Patterns


Creational Patterns
 Abstract Factory- create instances of other
objects Eg:-creating GUI components for different
GUI toolkits
 Factory Method- common interface for creating
subclasses
 Singleton- create only one instance of a class

Structural Patterns
 Decorator- add more responsibilities to an object
dynamically Eg:- adding scrolling to a text view
 Facade- higher level unified interface to a set of objects
in a subsystem
 Proxy- interface layer between objects

Behavioral Patterns
 Iterator- a means to access all the elements of objects
sequentially
 Momento- capture and save the current state of an
object
 Observer- when any numbers of objects (the Observers)
need to benotified automatically

49
Interfaces
Application Programming Interfaces
 Are sets of requirements that govern how one application can talk toanother
 applications to share data and take actions on one another's behalfwithout requiring
developers to share all of their software's code
 define exactly how a program will interact with the rest of the softwareworld—saving
time, resources
 Eg:-System-level APIs- cut and paste LibreOffice document into anExcel spreadsheet
 Eg:-FacebookAPIs - Facebook users sign into many apps and Web sitesusing their
Facebook ID
 Eg:-Web APIs - games let players chat, post high scores and invitefriends to play via
Face book, right there in the middle of a game

Inheritance
Inheritance
 derive a new class based on an existing class, with modifications orextensions
 A subclass inherits all the variables and methods from its super classes,including its
immediate parent as well as all the ancestorsavoid duplication and reduce redundancy

Types of Inheritance
 Simple , Multilevel, Multiple, hierarchical and Hybrid

Inheritance and Abstract class


 Abstract Method:-a method with only signature (i.e., the method name,the list of
arguments
and the return type) without implementation (i.e.,the method’s body).
 use the keyword abstract to declare an abstract method

Abstract Class
 A class containing one or more abstract methods is called an abstractclass.
 must be declared with a class-modifier abstract
 provides a template for further development

50
Notes:
 An abstract method cannot be declared final, as final method cannot be overridden.
 An abstract method must be overridden in a descendent before it can be used.
 An abstract method cannot be private (which generates a compilation error, because
private method is not visible to the subclass and thuscannot be overridden.
 In Java, define a subclass using the keyword "extends", e.g.,
class MyAppletextends java.applet.Applet
{.....} class Cylinder extends Circle {......}
Example for Inheritance

51
Example for Abstract class and
Inheritance

Abstract Class and Inheritance in Java

Shape.java
abstract public class Shape
{
private String color; // Private member
variable public Shape (String color) //
Constructor
{ this.color = color;
}
public String toString()
{
return "Shape of color=\"" + color + "\"";
}
// All Shape subclasses must implement a
method called getArea()
abstract public double getArea();
}

52
53
54
Versioning and Version Control

 Version control enables multiple people to simultaneously work on asingle project.


 Each person edits his or her own copy of the files and chooses when toshare those
changes
with the rest of the team.
 temporary or partial edits by one person do not interfere with another person's work.
 enables one person to use multiple computers to work on a project
 integrates work done simultaneously by different team members
 In rare cases, when two people make conflicting edits to the same line of
a file, then the version control system requests human assistance in deciding what to
do
 Version control gives access to historical versions of the project
 If make a mistake, roll back to a previous version. reproduce andunderstand a bug
report
on a past version of your software.
 undo specific edits without losing all the work that was done in themeanwhile.
 For any part of a file, determine when, why, and by whom it was everedited.
 Version control uses a repository (a database of changes) and a workingcopy
(checkout)
where you do your work
 working copy is your personal copy of all the files in the project.edits to this copy,
without affecting your teammates. commit yourchanges to a repository
 repository is database of all the edits to, and/or historical versions(snapshots) of,
your projectupdate your working copy to incorporate any new edits or versions
 Two varieties of version control: centralized(one repository)anddistributed
(multiple repositories)
 Some popular version control systems are Mercurial (distributed), Git(distributed),
and Subversion (centralized).
 The main difference between centralized and distributed version controlis the number
of repositories.
 In centralized version control, there is just one repository, and indistributed version
control, there are multiple repositories.

55
REFERENCES

Websites:

https://www.scribd.com
https:////www.slideshare.com

Republic Act 8293, section 176 states that: No copyright shall subsist in any work of the
Government of the Philippines. However, prior approval of the government agency or
office wherein the work is created shall be necessary to exploitation of such work for
profit. Such agency or office may, among other things, impose as a condition the
payment of royalties. Borrowed materials (i.e., songs, stories, poems, pictures, photos,
brand names, trademarks, etc.) included in this book are owned by their respective
copyright holders. Every effort has been exerted to locate and seek permission to use
these materials from their respective copyright owners. The publisher and authors do not
represent nor claim ownership over them.

Prepared Attested
by: by:

Earl Von V.
Deiparine
Instructor

Noted
by:

56
SIBUGAY TECHNICAL INSTITUTE INC.
Lower Taway, Ipil, Zamboanga
Sibugay www.sibugaytech.edu.ph
sibugaytech07@gmail.com
Telefax: (062)222-2469, Mobile No.:
09171271826/0917127190

57
SIBUGAY TECHNICAL INSTITUTE INC.
Lower Taway, Ipil, Zamboanga
Sibugay www.sibugaytech.edu.ph
sibugaytech07@gmail.com
Telefax: (062)222-2469, Mobile No.:
09171271826/0917127190

STII TRAINING CENTER

 AGRICULTURAL CROPS PRODUCTION NC II


 ANIMAL PRODUCTION (POUTRY CHICKEN)
NCII
 ANIMAL PRODUCTION (RUMINANTS) NC II
 ANIMAL PRODUCTION (SWINE) NCII
 BARTENDING NCII
 BOOKKEEPING NC III
 BREAD & PASTRY PRODUCTION NCII
 CAREGIVING NCII
 DRIVING NCII
 ELECTRONIC PRODUCTS ASSEMBLY
SERVICING NCII
 EVENTS MANAGEMENT SERVICES NCIII
 FOOD AND BEVERAGE SERVICES NCII
 FRONT OFFICE SERVICES NCII
 HEAVY EQUIPMENT OPERATOR (HYDRAULIC
EXCAVATOR) NCII
 HOUSEKEEPINGNCII
 MOTORCYCLE/SMALL ENGINE SERVICING NCII
 ORGANIC AGRICULTURE PRODUCTION NCII
 PHARMACY SERVICES NCIII
 RUBBER PRODUCTION NCII
 SHIELDED METAL ARC WELDING NCI
 SHIELDED METAL ARC WELDING NCII
 TRAINERS METHODOLOGY COURSE
 SHIELDED METAL ARC WELDING NCII
 AUTOMOTIVE SERVICING NCI
 AUTOMOTIVE SERVICING NCII
 HEALTH CARE SERVICES NCII
 HEAVY EQUIPMENT OPERATOR (BACKHOE
LOADER) NCII
 MOTORCYCLE/SMALL ENGINE SERVICING NCII
 CAREGIVING NCII
 BARTENDING NCII

58
SIBUGAY TECHNICAL INSTITUTE INC.
Lower Taway, Ipil, Zamboanga
Sibugay www.sibugaytech.edu.ph
sibugaytech07@gmail.com
Telefax: (062)222-2469, Mobile No.:
09171271826/0917127190

SENIOR HIGH SCHOOL

INDUSTRIAL ARTS
 DRIVING NCII
 SHIELDED METAL ARC WELDING NCII
 AUTOMOTIVE SERVICING NCI
AUTOMOTIVE SERVICING
NCII HOME ECONOMICS
 FRONT OFFICE SERVICES
NCII
 HOUSEKEEPING NCII
 FOOD AND BEVERAGES
SERVICES NCII
BREAD AND PASTRY PRODUCTION NC II
INFORMATION AND
COMMUNICATIONTECHNOLOGY
 2D ANIMATION NCIII
 COMPUTER SYSTEM SERVICING NCII
ELECTRONIC PRODUCTS ASSEMBLY SERVICES
NCII AGRICULTURAL TECHNOLOGY STRAND
 ANIMAL PRODUCTION (POULTRY CHICKEN)
NCII
 ANIMAL PRODUCTION (RUMINANTS) NCII
 ANIMAL PRODUCTION (SWINE) NCII
 RUBBER PRODUCTION NCII
 ORGANIC AGRICULTURAL PRODUCTION NCII
ACADEMIC
TRACKHUMANITIES AND SOCIAL
SCIENCES
 FRONT OFFICE SERVICES
NCII
EVENTS MANAGEMENT NC III
ACCOUNTANCY BUSINESS
ANDMANAGEMENT
 BOOKKEEPING NCIII
SCIENCE, TECHNOLOGY,
ENGINEERING ANDMATHEMATICS
59
 ELECTRONIC PRODUCTS
ASSEMBLY SERVICING NCII

You might also like