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

SCHOOL OF INFORMATICS

DEPARTMENT OF IT

Integrative Programming
Technologies(IPT)
Desta D.
Ast. Professor in IT
School of Informatics, WSU
INTRODUCTION TO INTEGRETIVE PROGRAMMING AND
TECHNOLOGY

 Integration (from the Latin integer, meaning whole or entire) generally means
combining parts so that they work together or form a whole. In information
technology, there are several common usages:
1) Integration during product development is a process in which separately produced
components or subsystems are combined and problems in their interactions are
addressed
2) Integration is an activity by companies that specialize in bringing different
manufacturers' products together into a smoothly working system.
 3) In marketing usage, products or components said to be integrated appear to meet
one or more of the following conditions:
A/ They share a common purpose or set of objectives.
B/ They all observe the same standard or set of standard protocol or they share a
mediating capability, such the Object Request Broker (ORB) in the Common Object
Request Broker Architecture (CORBA).
Continued..

 C) They were all designed together at the same time with a


unifying purpose and/or architecture. (They may be sold as
piece-parts but they were designed with the same larger
objectives and/or architecture.)
 D) They share some of the same programming code.
 E) They share some special knowledge of code (such as a
lower-level program interface) that may or may not be publicly
available. (If not publicly available, companies have been
known to sue to make it available in order to make competition
fair.)
Review on Data integration
Technology
What is .NET Framework Technologies?
 We just thought we should first start with the most asked question, differences between
all framework versions. Below figure '.NET growth' shows how the framework has
evolved. In .NET 1.1 we had the basic framework, web services, CLR, ADO etc...NET
2.0 paid more attention on increasing the productivity of the developer. They had
modules like MARS, Generics, Partial classes, DPAPI etc...NET 3.0 was more about
fulfilling the SOA dreams. They had modules like WCF, WPF and WWF. We have
complete chapter on 3.0 please read it to understand the Fundamentals. .NET 3.5 has
new query capabilities like LINQ, AJAX which is now an integral part of 3.5 setup and
new protocol support for WS-* specifications
IL, CLR and JiT

 IL (Intermediate Language)
 Twist: - What is MSIL or CIL, What is JIT?
 (IL)Intermediate Language is also known as MSIL (Microsoft
Intermediate Language) or CIL (Common Intermediate
Language). All .NET source code is compiled to IL. IL is then
converted to machine code at the point where the software is
installed, or at run-time by a Just-In-Time (JIT) compiler
CTS

 CTS
 In order that two language communicate smoothly CLR has CTS
(Common Type System).Example in VB you have “Integer” and
in C++ you have “long” these data types are not compatible so
the interfacing between them is very complicated. In order that
these two different languages communicate Microsoft introduced
Common Type System. So “Integer” data type in VB6 and “int”
data type in C++ will convert it to System.int32, which is data
type of CTS. CLS is subset of CTS.
 Note: If you have undergone COM programming period
interfacing VB6 application with VC++ application was a real pain
as the data type of both languages did not have a common
ground where they can come and Interface, by having CTS
interfacing is smooth.
CLS

 CLS (Common Language Specification)


 This is a subset of the CTS, which all .NET languages
are expected to support. It was always a dream of
Microsoft to unite all different languages in to one
umbrella and CLS is one-step towards that. Microsoft
has defined CLS, which are nothing but guidelines that
language should follow so that it can communicate with
other .NET languages in a seamless manner
Assembly
Assembly
 • Assembly is unit of deployment like EXE or a DLL.
 • An assembly consists of one or more files (dlls, exe’s, html files etc.), and
represents a group of resources, type definitions, and implementations of those
types. An assembly may also contain references to other assemblies. These
resources, types and references are described in a block of data called a manifest.
The manifest is part of the assembly, thus making the assembly self-describing.
 DLL mean Dynamic Link Library
Continued….

 What are the different types of Assembly


 There are two types of assembly Private and Public
assembly. A private assembly is normally used by a single
application, and is stored in the application's directory, or a
sub-directory beneath. A shared assembly is normally
stored in the global assembly cache, which is a repository of
assemblies maintained by the .NET runtime. Shared
assemblies are usually libraries of code, which many
applications will find useful, e.g. Crystal report classes that
will be used by all application for Reports.
JIT

 JIT compiler is a part of the runtime execution environment.


 In Microsoft .NET there are three types of JIT compilers:
 • Pre-JIT: - Pre-JIT compiles complete source code into native
code in a single compilation cycle. This is done at the time of
deployment of the application.
 • Econo-JIT: - Econo-JIT compiles only those methods that are
called at runtime. However, these compiled methods are removed
when they are not required.
 • Normal-JIT: - Normal-JIT compiles only those methods that
are called at runtime. These methods are compiled the first time
they are called, and then they are stored in cache. When the same
methods are called again, the compiled code from cache is used for
execution.
Chapter 2
Intersystem communication
 Intersystem communication is called distributed system.
 What does mean distributed system?
 a distributed system is:
a collection of independent computers that appears to its users as a single coherent
system – computer
 this definition has two aspects:
1. hardware: autonomous machines
2. software: a single system view for the users
Definition continued..

 distributed system is a system designed to support the


development of applications and services which can exploit a
physical architecture consisting of multiple, autonomous
processing elements that do not share primary memory but
cooperate by sending asynchronous messages over a
communication network.
 distributed system is one that stops you getting any work
done when a machine you’ve never even heard of crashes
Examples..

 The Web over the Internet.


 Mobile telephony over cellular networks.
 Electronic funds transfer systems over
special
purpose networks
 For example, between bank accounts, on credit card purchases, via cash

machines.
 The Web was conceived of as, primarily, a means to share linked collections of
documents.
  Mobile phone networks have been able to scale up and out in response to
increase in demand (e.g., some three million net additions between 2006 and
2007, and again between 2007 and 2008).
 Electronic funds transfer networks have many member organizations and can be
quite large (e.g., in 2008, LINK had 51, with 60,000 ATMs), still they are highly
reliable and highly available.
Other Examples..

 Other examples abound:


  Email,
 Instant messaging,
  Videoconferencing,
 Multiuser gaming,
  Home entertainment systems,
  Global positioning systems,
  etc..
Advantages of DS

 Ultimately, more is more.


 Interconnecting many systems has increased our ability to
tackle problems that centralized systems in sequential mode
cannot solve efficiently.
 More users can do more work of a more valuable nature more
effectively and more efficiently with distributed systems than
with centralized ones.
Why distributed system?

 A distributed system is one which is


–   independent, selfsufficient,
–   often heterogeneous and autonomous,
–   spatially separated
–   components must use a common interconnection   to
exchange information   in order to

•  coordinate their actions and

•  allow the whole to appear to its users as

a single coherent system.


Continued..

 Resource and Data Sharing


 printers, databases, multimedia servers, ...
 Availability, Reliability
 the loss of some instances can be hidden
 Scalability, Extensibility
 the system grows with demand (e.g., extra servers)
 Performance
 huge power (CPU, memory, ...) available
 Inherent distribution, communication
 organizational distribution, e-mail, video
Middleware

 to support heterogeneous computers and networks and to


provide a single-system view, a distributed system is often
organized by means of a layer of software called middleware
that extends over multiple machines
Continued..

 Middleware Protocols
 a middleware is an application that contains general-
purpose protocols to provide services
 example of middleware services
 authentication and authorization services
 distributed transactions (commit protocols; locking
mechanisms)
 middleware communication protocols (calling a
procedure or invoking an object remotely,
synchronizing streams for real-time data, multicast
services)
 hence an adapted reference model for networked
communications is required
Architecture of IS
• the general organization of an Internet search engine into three
different layers

 Client-Server Architectures
 how to physically distribute a client-server application across
several machines
 Multitiered Architectures 25
Two-tiered architecture: alternative client-server organizations
a) put only terminal-dependent part of the user interface on the client
machine and let the applications remotely control the presentation
b) put the entire user-interface software on the client side
c) move part of the application to the client, e.g. checking
correctness in filling forms
d) and e) are for powerful client machines
26
Web services…in n-tier architecture

three tiered architecture: an example of a server acting as a client


 Modern Architectures
 vertical distribution: when the different tiers correspond directly
with the logical organization of applications
 horizontal distribution: physically split up the client or the server
into logically equivalent parts. e.g. Web server

an example of horizontal distribution of a Web service


What is RMI and RPC?

 RMI= Remote Method Invocation


 RPC= Remote Procedure calling
Remote Object (Method) Invocation (RMI)
 resulted from object-based technology that has proven its value in
developing nondistributed applications
 it is an expansion of the RPC mechanisms
 it enhances distribution transparency as a consequence of an object
that hides its internal from the outside world by means of a well-
defined interface
 Distributed Objects
 an object encapsulates data, called the state, and the operations on
those data, called methods
 methods are made available through interfaces
 the state of an object can be manipulated only by invoking methods
 this allows an interface to be placed on one machine while the object
itself resides on another machine; such an organization is referred
to as a distributed object
 the state of an object is not distributed, only the interfaces are; such
30
objects are also referred to as remote objects
 RPC would like to make a remote procedure call look the
same as a local one; it should be transparent, i.e., the calling
procedure should not know that the called procedure is
executing on a different machine or vice versa
 when a program is compiled, it uses different versions of
library functions called client stubs
 a server stub is the server-side equivalent of a client stub

31

principle of RPC between a client and server program


Web service

 AppSetting Section in “Web.Config” file:


 Web.config file defines configuration for a web project.
Using “AppSetting” section, we can define user-defined
values. Example below defined is “Connection String”
section, which will be used throughout the project for
database connection.
Web service….
 Web Control:
 A Data grid, Datalist and Repeater are all ASP.NET data Web controls.
 They have many things in common like Data Source Property, Data Bind Method
ItemDataBound, and Item Created.
Terms:
 ASP= Active server Page
 ADO=Activex Data objects
 COM= Component Object Modeling, is not shared/distributed
 COM+
 DCOM=Distributed Component Modeling; shared / distributed
 ADO uses COM but ADO.NET uses DCOM
 Reading/assignment/ ASP.NET, JSP.NET and ADO.NET
Web. config

Web.config is automatically created when you create an


asp.net web application project.
 This is also called application level configuration file.
 This file inherits setting from the machine config.
 Use for particular application
Machine.Config
 Machine.Config:
 This is automatically installed when you install visual studio.net.
 Only one machine.config file exists on a server.
 This file is at the highest level in the configuration hierarchy.
 Also called machine level configuration file.
 Machine. Config will be for the whole machine.
 Found-Microsoft.net\framework\v1.1.4322\config folder which contains
specification and setting at a system level.
What is difference b/n two?..

 Difference between “Web.config” and“Machine.Config”.


 “Web.config” files apply settings to each web application,
while “Machine.config” file apply settings to all ASP.NET
applications.
Web farms
 “Web farms” are used to have some redundancy to minimize failures.
 It consists of two or more web server of the same configuration and they stream
the same kind of contents.
 When any request comes there is switching / routing logic, which decides which
web server from the farm, handles the request. For instance, we have two
servers “Server1” and “Server2” which have the same configuration and content.
Therefore, there is a special switch, which stands in between these two servers and
the users and routes the request accordingly.
Web farm in figures..
Web garden

 However, when we enable web garden for a web server it


creates different instances of the worker process and each
of these worker process runs on different CPU.
 You can see in the below diagram we have different worker
process instances created which run on different CPU’s.
Web garden figure
CORBA(Common Object
Request Broker)
 The Object Management Group (OMG) was formed in 1989. Its aims were:
 to make better use of distributed systems
 to use object-oriented programming
 to allow objects in different programming languages to communicate with
one another
 The object request broker (ORB) enables clients to invoke methods in a
remote object
 CORBA is a specification of an architecture supporting in intersystem
communications
 CORBA 1 in 1990 and CORBA 2 in 1996.

41


Chapter 3
Network Programming
 Based on Classes in the java.net package

 Lecture focuses on:


 TCP and UDP
 Network programming basics
 Identifying a machine
 Servers and Clients
 Ports and sockets
 Data transfer using sockets

42
TCP and UDP

 Lots of java programs use Transmission Control


Protocol (TCP)
 Connection-based (where java stream sockets
provides continuous data stream), reliable, data
streams will always get there. Also high
overhead. We will focus on TCP/IP sockets.
 User Datagram Protocol (UDP) is not connection-
based (connectionless service with datagram
sockets allowing one message, an unreliable
protocol which is much faster, but the message
won’t always get there
Network Programming Basics
•The classes in java.net: Java
programs can use TCP or UDP
to communicate over the
Internet. The URL,
URLConnection (for Web
applications), Socket, and
ServerSocket (client-server
applications) classes all use
TCP to communicate over the
network.
•The DatagramPacket,
DatagramSocket, and
Network Programming Basics

 Historically error-prone, difficult, complex


 JAVA has complete network package, java.net
 I/O stream library works quite well for TCP/IP
 Threading is also very useful and relatively easy here
Identifying a Machine

 Uniquely identify a machine from all the others in the world


 IP (Internet Protocol) address that can exist in two forms:
Identify a Machine
(Continue)
 DNS(Domain Name Service) form

java.sun.com
 “Dotted quad” form:

123.255.28.120

 static InetAddress.getByName()
produces java object containing
address
Servers and Clients

 Two machines must connect


 Server waits for connection
 Client initiates connection (create socket)
 Once the connection is made, server & client look identical
Testing w/o a network

 For testing your program, you can do it without network. (server & client
on same machine)
 Localhost: the IP address for testing without a network
 Three ways to identify:
Test w/o networking
(Continue)
 InetAddress
 addr=InetAddress.getByName(null);
 Equivalently:
 InetAddress.getByName(“localhost”);
 Or using the reserved IP number for the loopback:
 InetAddress.getByName(“127.0.0.1”);
Port number

 IP address isn’t enough to identify a unique server


 many servers can exist on one machine
 port number: Unique in a Machine
 Not a physical location, but a software abstraction to represent a service
Port number (Continue)

 When set up client and server, you must specify IP address and port.
 Port number range: 0 to 65,535
 1-1024 are reserved, others may be used.
Sockets

 Software abstraction
used to represent the
connection between
two machines
 Socketis the actual
2-way connector.
Sockets

 The following sequence establishes a socket from the client class


InetAddress addr =
InetAddress.getByName(null);
Socket socket =
new Socket(addr, 8080);
Sockets

 At the server class, the following establishes the server port, and waits
for a client request to establish a socket
ServerSocket s =
new ServerSocket(8080);
Socket socket = s.accept();
Data transfer using sockets

 Once you have a Socket, you call getInputStream() and


getOutputStream() to produce the corresponding InputStream and
OutputStream objects
 You can convert these to readers and writers, wrap them in a
BufferedReader or BufferedWriter and PrintWriter
Tea Break
10 minutes
Socket
Programming on
Java
Practical Session
Running JDK1.3 and its environment

 Install Jdk1.3
 Setting environment jdk.
Go to Windows -> Search on Advanced system setting -> go
to Environmental setting-> Write new-> Name: Path,
Value: c:\jdk1.3\bin
Click on Ok.
Socket Programming Designs
Server Socket

import java.io.*;
import java.net.*;
public class myServer{
public static void main(String[]args){
try{
ServerSocket ss=new ServerSocket(6666);
Socket s=ss.accept();
DataInputStream dis = new DataInputStream(s.getInputStream());
String str=(String)dis.readUTF();
System.out.println("Message from Clients="+str);
ss.close();
}catch(Exception e){
System.out.println(e);} }}
Client side Programs

import java.io.*;
import java.net.*;
public class myClient{
public static void main(String[]args){
try{
Socket s=new Socket("localhost",6666);
DataOutputStream dout = new
DataOutputStream(s.getOutputStream());
dout.writeUTF("Hello Server this is from maja kero...");
dout.flush();
dout.close();
s.close();
}catch(Exception e){
System.out.println(e);}
}}
To Run Socket programs java

 Open tow CMD windows.


 Find the Folder places.. Cd...
 Dir
 To Run and compile server
Javac myServer.java…….. This used to compile java programs
Java myServer …….. This used to run java programs.
To Run and compile client
Javac myClient.java…….. This used to compile java programs
Java myClient …….. This used to run java programs.
RMI Demo

Interface Code Save on Hello.java

import java.rmi.Remote;
import java.rmi.RemoteException;
// Creating Remote interface for our application
public interface Hello extends Remote {
void printMsg() throws RemoteException;
}
Implementation save on
ImplExample.java
public class ImplExample implements Hello
{

// Implementing the interface method


public void printMsg() {
System.out.println("This is an example
RMI program");
}
}
Server Program save on Server.java

import java.rmi.registry.Registry;
import java.rmi.registry.LocateRegistry;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
public class Server extends ImplExample {
public Server() {}
public static void main(String args[]) {
try {
ImplExample obj = new ImplExample();
Hello stub = (Hello) UnicastRemoteObject.exportObject(obj, 0);
Registry registry = LocateRegistry.getRegistry();

registry.bind("Hello", stub);
System.err.println("Server ready");
} catch (Exception e) {
System.err.println("Server exception: " + e.toString());
e.printStackTrace();
} }}
Client Program Save on Client.java

import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
public class Client {
private Client() {}
public static void main(String[] args) {
try {
Registry registry = LocateRegistry.getRegistry(null);
Hello stub = (Hello) registry.lookup("Hello");
stub.printMsg();

} catch (Exception e) {
System.err.println("Client exception: " + e.toString());
e.printStackTrace();
}}}
Compiling and Running
 Open 3- CMD windows.
 Go to the folder directory(by using cd..)
 Compile all Programs by One(javac *.java)
 Run Implementation on the same CMD windows (rmic ImplExample)
 Run RMI registry on the same CMD windows (start rmiregistry)
 Run the server on the second CMD windows(java Server)
 Run the Client on the Third CMD windows(java Client)
Chapter 4

XML
History

SGML Standardized General Markup Language

HTML HyperText Markup Language

1995/98
1985 1990

XML
eXtensible Markup Language
Slide
70
Why do we need XML (1) ?
Data-exchange
 XML is used to aid the exchange of data. It
makes it possible to define data in a clear
way.
 Both the sending and the receiving party will
use XML to understand the kind of data that's
been sent.
 By using XML everybody knows
that the same interpretation of
Slide

the data is used


71
Why do we need XML (1) ?
 Electronic data interchange ( EDI ) is critical in
today’s networked world and expensive
 Examples:
 Banking: funds transfer
 Education: e-learning contents
 Scientific data
 Genetics: BSML (Bio-Sequence
Markup Language), …
 XML is a good replacement for EDI. It uses the
Internet for the data exchange. And it's very
flexible.
 XML has become the basis for all new Slide
72

generation data interchange formats


What is XML
 XML stands for eXtensible Markup
Language.
 A markup language is used to provide
information about a document.
 XML is a meta-language.
 A meta-language is a language that's used
to define other languages. You can use XML
for instance to define a language like WML.
 XML is a smaller version of SGML
XML is not…
A replacement for HTML
(but HTML can be generated from XML)
A presentation format
(but XML can be converted into one)
A programming language
(but it can be used with almost any language)
A network transfer protocol
(but XML may be transferred over a network)
A database
(but XML may be stored into a database)
74
But then – what is it?
XML is a meta markup language
for text documents / textual
data

XML allows to define languages


(“applications“) to represent
text documents / textual data

75
What is XML Used For?
 XML documents are used to transfer data from one
place to another often over the Internet.
 XML subsets are designed for particular
applications.
 One is RSS (Rich Site Summary or Really Simple
Syndication ). It is used to send breaking news
bulletins from one web site to another.
 A number of fields have their own subsets. These
include chemistry, mathematics, and books
publishing.
 Most of these subsets are registered with the
W3Consortium and are available for anyone’s use.
Design rationale for XML (1)
1. XML must be easily usable over the Internet

2. XML must support a wide variety of


applications
3. XML must be compatible with SGML

4. It must be easy to write programs that


process XML documents

5. The number of optional features in XML


Slide

must be kept small


77
Design rationale for XML
(2)
6. XML documents should be clear and easily
understood
7. The XML design should be prepared
quickly
8. The design of XML must be exact and
concise
9. XML documents must be easy to create
10. Keeping an XML document size small is of
minimal importance Slide
78
XML vs. HTML
<name>
<first> abc </first>
 XML was designed to describe data. <middle> xyz </middle>
HTML was designed to display data. <last> def </last>
. </name>
• HTML tags are designed for the
interaction between humans and
computers, while XML tags are designed
for the interactions between two <html>
computers. <head>
<title>Title of page</title>
 XML was designed to describe data, with
</head>
focus on what data is
<body>
 HTML was designed to display data, with abc <br>
focus on how data looks xyz <br>
def <br>
</body>
</html>
XML information structures (1)
Example 1: A possible book structure

Book
FrontMatter
BookTitle
Author(s)
PubInfo
Chapter(s)
ChapterTitle
Paragraph(s)
BackMatter
References
Index Slide
80
XML Data Model: Example

<BOOKS>
<book id=“123” loc=“library”> BOOKS
book
<author>Hull</author> article
loc=“library”
<title>California</title> ref
123 555
<year> 1995 </year>
</book> author year author title
<article id=“555” ref=“123”>
title
<author>Su</author>
<title> Purdue</title> Hull 1995 Su Purdue
</article> California
</BOOKS>
XML information structures (2)
 Premise: A text is the sum of its component parts
 A <Book> could be defined as containing:
<FrontMatter>, <Chapter>s, <BackMatter>
 <FrontMatter> could contain:
<BookTitle> <Author>s <PubInfo>
 A <Chapter> could contain:
<ChapterTitle> <Paragraph>s
 A <Paragraph> could contain:
<Sentence>s or <Table>s or <Figure>s …
 Components chosen for book markup language should reflect anticipated
use ….

Slide
82
XML information structures (3)
A corresponding XML fragment
(based on corresponding XML application):
begin end
<Book> element element
<FrontMatter>
<BookTitle> XML Is Easy </BookTitle>
<Author> Tim Cole </Author>
<Author> Tom Habing </Author>
<PubInfo> CDP Press, 2002 </PubInfo>
</FrontMatter>
<Chapter>
<ChapterTitle> First Was SGML </ChapterTitle>
<Paragraph> Once upon a time …</Paragraph>
</Chapter>
</Book> Slide
83
XML information structures (4)
Example 2: Movies
 Elements can have attributes attribut
<movies> e
<movie genre="action" star="Halle Berry">
<name>Catwoman</name>
<date>(2004)</date>
<length>104 minutes</length>
</movie>

<movie genre="horror" star="Halle Berry">


<name>Gothika</name>
<date>(2003)</date>
<length>98 minutes</length>
</movie>

<movie genre="drama" star="Halle Berry">


<name>Monster&apos;s Ball</name>
<date>(2001)</date>
<length>111 minutes</length>
</movie> Slide
84
</movies>
What is an XML document ?

 AnXML document is a content marked up


with XML (can be a file, a string, a message
content or any other sort of data storage)

 There are 2 levels of conforming


documents:
 Well-formed: respects the XML syntax
 Valid: In addition, respects one (or
more) associated grammars (schemas).
Slide
85
What is a
well-formed XML document (1) ?
Well-formed documents follow basic syntax rules e.g.
 there is an XML declaration in the first line
 there is a single document root
 all tags use proper delimiters
 all elements have start and end tags
 But can be minimized if empty: <br/> instead of <br></br>
 all elements are properly nested
<author> <firstname>Mark</firstname>
<lastname>Twain</lastname> </author>
 appropriate use of special characters
 all attribute values are quoted:
<subject scheme=“LCSH”>Music</subject> Slide
86
What is a
well-formed XML document (2) ?
 Good example
<addressBook>
<person>
<name> <family>Wallace</family> <given>Bob</given> </name>
<email>bwallace@megacorp.com</email>
<address>Rue de Lausanne, Genève</address>
</person>
</addressBook>
 Bad example
<addressBook>
<address>Rue de Lausanne, Genève <person></address>
<name>
<family>Schneider</family> <firstName>Nina</firstName>
</name>
<email>nina@nina.name</email>
</person>
<name><family> Muller </family> <name> Slide
87
</addressBook>
XML Document Life
Cycle

88
XML vs. Relational Database
CUSTOMER
Name Age
ABC 30
XYZ 40

<customers>
<custRec>
<Name type=“String”>ABC</custName>
<Age type=“Integer”>30</custAge>
</custRec>
<custRec>
<Name type=“String”>XYZ</custName>
<Age type=“Integer”>40</custAge>
</custRec>
</customers>
XML vs. Relational
Database
XML vs. Relational
Database

<!ELEMENT note (to+, from, header, message*, #PCDATA)>


XML vs. Relational
Database
XML TREE
 XML documents form a tree structure that starts at "the root" and branches to
"the leaves".
 XML documents use a self-describing and simple syntax

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


<note> Start of Root Element
  <to>Tove</to>
  <from>Jani</from> Child
  <heading>Reminder</heading> Elements
  <body>Don't forget me this weekend!</body>
</note> End of Root Element

93
XML Documents Form a
Tree Structure
 The elements in an XML document form a document tree. The tree starts at the
root and branches to the lowest level of the tree.
 XML documents must contain a root element. This element is "the parent" of all
other elements.
 All elements can have sub elements (child elements)
 The terms parent, child, and sibling are used to describe the relationships
between elements. Parent elements have children. Children on the same level are
called siblings (brothers or sisters).
 All elements can have text content and attributes (just like in HTML).

94
XML Documents Form a
Tree Structure

95
XML Tags :
 XML tags are created like HTML tags. There's a start tag and a closing tag.

<TAG>content</TAG>
 The closing tag uses a slash after the opening bracket, just like in HTML.

XML Element :
The text between the brackets is called an element.
Empty Tags :
 An empty tag does not have a closing tag.
 The syntax differs from HTML:
<TAG/>
96
XML documents
The XML declaration
The first line of an XML document is the
XML declaration. It's a special kind of tag:
<?xml version="1.0"?>
The version 1.0 is the actual version of XML.

The XML declaration makes clear that we're


talking XML and also which version is used.
97
XML documents
The ROOT Element
 All XML documents must have a root
element.
 All other elements in the same document
are children of this root element.
 The root element is the top level of the
structure in an XML document.
The SUB Element
 Sub-elements are also called children
98
XML documents
Structure of XML page
<?xml version="1.0"?>
<root>
<element>
<sub-element>
content
</sub-element>
<sub-element>
content
</sub-element>
</element> 99

</root>
XML documents
A real XML page
<product>
<?xml version="1.0"?>
<name>
<sales>
carrots
<shop>
</name>
<number>
<totalprice>
100
10
</number>
</totalprice>
<manager>
</product>
Ray Bradbury
</sales>
</manager>
</shop>

100
XML documents
XML Attributes
Elements in XML can use attributes. The syntax is:

<element attribute-name = "attribute-value"> . .


</element>
The value of an attribute needs to be quoted, even if it contains only numbers.
An example

<car color = "green"> volvo </car>


The same information can also be defined without using attributes:

<car>
<brand>volvo</brand>
<color>green</color>
</car> 101
XML Syntax Rules
All XML Elements Must Have a Closing Tag
In XML, it is illegal to omit the closing tag. All elements must have a closing tag:

<p> This is a paragraph. </p> <br />


XML Tags are Case Sensitive
XML tags are case sensitive. The tag <Letter> is different from the tag <letter>.
Opening and closing tags must be written with the same case:
<Message>This is incorrect</message>
<message>This is correct</message>

102
XML Syntax Rules
XML Elements Must be Properly Nested
In HTML, you might see improperly nested elements:

<b><i>This text is bold and italic</b></i>


In XML, all elements must be properly nested within each other: <b><i>This
text is bold and italic</i></b>
XML Documents Must Have a Root Element
XML documents must contain one element that is the parent [ROOT ]of all other
elements.

<root>
  <child>
    <subchild>.....</subchild>
  </child> 103

</root>
XML Syntax Rules
XML Attribute Values Must be Quoted
XML elements can have attributes in name/value pairs just like in HTML. In
XML, the attribute values must always be quoted.

<note date="12/11/2007">
  <to>Tove</to>
  <from>Jani</from>
</note>
Comments in XML
The syntax for writing comments in XML is similar to that of HTML.

<!-- This is a comment -->

104
XML Syntax Rules
White-space is Preserved in XML
HTML truncates multiple white-space characters to one single white-space: With
XML, the white-space in a document is not truncated.

XML Stores New Line as LF


Entity References
Some characters have a special meaning in XML.
If you place a character like "<" inside an XML
element, it will generate an error because the
parser interprets it as the start of a new element.
This will generate an XML error:
<message>if salary < 1000 then</message> 105
XML Syntax Rules
To avoid this error,
replace the "<" character with an entity reference:
<message>if salary &lt; 1000 then</message>
There are 5 predefined entity references in XML:

106
XML Naming Rules
 XML elements must follow these naming rules:
 Names can contain letters, numbers, and
other characters
 Names cannot start with a number or
punctuation character
 Names cannot start with the letters xml (or
XML, or Xml, etc)
 Names cannot contain spaces
 Any name can be used, no words are reserved.

107
CHAPTER 5

Design Patterns:

Design patterns are recurring solution to recurring


problems in software architecture.

It is a description or template for how to solve a


problem that can be used in many different situations.
Uses of Design Patterns Design patterns can speed up the
development process by providing tested, proven
development paradigms.

People only understand how to apply certain software design


techniques to certain problems.

Design patterns provide general solutions, documented in a


format that doesn't require specifics tied to a particular
problem .
In addition; patterns allow developers to communicate using
well-known, well understood names for software interactions.
Common design patterns can be improved over time, making
them more robust than ad-hoc (unplanned) designs
Question:
Can you list down all patterns and their
classification?
There are three basic classifications of
patterns
- Creational
- Structural, and
- Behavioral patterns.
Creational Patterns
• Abstract Factory: - Creates an instance of several
families of classes
• Builder: - Separates object construction from its
representation
• Factory Method: - Creates an instance of several
derived classes
• Prototype: - A fully initialized instance to be copied
or cloned
• Singleton: - A class in which only a single instance
can exist
Note: - The best way to remember Creational pattern
is by ABFPS (Abraham Became First President of
States).
Structural Patterns
• Adapter:-Match interfaces of different classes.

• Bridge:-Separates an object’s interface from its


implementation.
• Composite:-A tree structure of simple and composite
objects.
• Decorator:-Add responsibilities to objects dynamically.
• Façade:-A single class that represents an entire
subsystem.
• Flyweight:-A fine-grained instance used for efficient
sharing.
• Proxy:-An object representing another object.
Note: To remember structural pattern best is (ABCDFFP)
Behavioral Patterns
• Mediator:-Defines simplified communication between classes.
• Memento:-Capture and restore an object's internal state.

• Interpreter: - A way to include language elements in a program.


• Iterator:-Sequentially access the elements of a collection.
• Chain of Resp: - A way of passing a request between a chain
of objects.
• Command:-Encapsulate a command request as an object.
• State:-Alter an object's behavior when its state changes.
• Strategy:-Encapsulates an algorithm inside a class.
• Observer: - A way of notifying change to a number of classes.
• Template Method:-Defer the exact steps of an algorithm to a
subclass.
• Visitor:-Defines a new operation to a class without change.
Note: - Just remember Music....... 2 MICS on TV
(MMIICCSSOTV).
Note: - No source code is provided for architecture.
MVC pattern:
Twist: - How can you implement MVC pattern in ASP.NET?
The main purpose using MVC pattern is to decouple the GUI from the
Data. It also gives the ability to provide multiple views for the same Data.
MVC pattern separates objects in to three important sections:-
 
• Model:-This section is specially for maintaining data. It is actually where
your business logic, querying database, database connection etc. is
actually implemented.
• Views: - Displaying all or some portion of data, or probably different view
of data. View is responsible for look and feel, Sorting, formatting etc.
• Controller:-They are event-handling section, which affects either the
model or the view. Controller responds to the mouse or keyboard input to
command model and view to change. Controllers are associated with views.

Model: - This section is represented by Data view, Dataset,


Data flow between MVC
architectures.
How can we implement singleton pattern in .NET?
When one need to have a class which can be only
instantiated once.
Singleton Design Pattern addresses to such situation
by providing a design for such classes.
Singleton pattern as defined in Design Patterns is to
"ensure a class has only one instance, and provide
a global point of access to it.
Singleton pattern mainly focuses on having one and
only one instance of the object running.
Example a windows directory service that has
multiple entries but you can only have single instance
of it throughout the network.
Following are the three steps needed to implement
singleton pattern in .NET:-
• First, create your class with static members.
Public class ClsStaticClass
Private shared objCustomer as clsCustomer
End class
This ensures that there is actually only one Customer
object throughout the project.
• Second, define a private constructor to your class.
Note: - defining a private constructor to class does not
allow a client
to create objects directly.
• Finally provide a static method to get access to your
singleton object.
The main difference between factory and
Abstract factory is, factory method uses
inheritance to decide which object has to
be instantiated while abstract factory uses
delegation to decide instantiation of object.

We can say Abstract factory uses factory


method to complete the architecture.
Abstract Factory is one level higher in
abstraction over Factory
delegates in C# = pointer in C++, Java
The Abstract Factory Pattern
Provide an interface for creating families of related or dependent
objects without specifying their concrete classes.
The Abstract Factory pattern is very similar to the Factory Method
pattern. One difference between the two is that with the Abstract
Factory pattern, a class delegates the responsibility of object
instantiation to another object via composition whereas the
Factory Method pattern uses inheritance and relies on a
subclass to handle the desired object instantiation.
Factory pattern
Factory patterns are examples of creational patterns
Creational patterns abstract the object instantiation process. They
hide how objects are created and help make the overall system
independent of how its objects are created and composed.
Class creational patterns focus on the use of inheritance to
decide the object to be instantiated Factory Method
Object creational patterns focus on the delegation of the
instantiation to another object Abstract Factory.
Facade pattern sits on the top of lot of
subsystems and makes access easy to interfaces
of these Subsystems. Basic purpose of Façade is
to make interfacing between many modules and
classes manageable.
FAÇADE Provide a unified interface to a set of interfaces in a subsystem
Facade   (MortgageApplication)
knows which subsystem classes are
responsible for a request.
delegates client requests to appropriate
subsystem objects.
Subsystem classes   (Bank, Credit, Loan)
implement subsystem functionality.
handle work assigned by the Facade object.
have no knowledge of the facade and keep
no reference to it.
What are subsystems for above figure?
FACADE implemented by C#
some basic difference between
C and C#
In C++, the programmer has to free the memory, while C#
has Garbage collector which frees the memory.
· C++ supports multiple inheritance, while C# does not.
· C++ has to use pointers to manipulate memory, while C#
can access memory directly/delegates/.
· C# uses pointers in codes declared as unsafe.
· In C++ access modifiers are public, private and protected,
while in C# access modifiers are public, private, protected,
internal and protected internal.
· C++ uses semicolon at the end of class definition, while
C# does not.
· C++ supports macros, while C# does not.
· C# is language type-safe, while C++ is not.
· C++ code usually compiles to assembly language, while
C# code usually compiles to intermediate language.
· C# does not contain any default constructor.
· As compared to C++, behavior of the command line
arguments is different in C#.
· Abstract of C# cannot be implemented.
· C# allows the switch statement to be used with string values.
· Arrays in C# are of reference type while in C++ arrays are of
value type.
· All the data types in C# are inherited from the object super
class and therefore they are objects.
· In C#, structs are of value type.
· C# does not support the typed of statement.
· C# supports native Boolean type and Boolean type data can
be implicitly or explicitly cast to any data type except object.
· C# does not support default arguments.
· C++ supports bit fields, while C# does not
Summary creational design pattern
This design patterns is all about class
instantiation.
Abstract Factory
Creates an instance of several families of classes
Builder
Separates object construction from its representation
Factory Method
Creates an instance of several derived classes
Object Pool
Avoid expensive acquisition and release of resources by
recycling objects that are no longer in use
Prototype
A fully initialized instance to be copied or cloned
Singleton
A class of which only a single instance can exist
Structural design patterns
This design patterns is all about Class and
Object composition.
Adapter
Match interfaces of different classes
Bridge
Separates an object’s interface from its implementation
Composite
A tree structure of simple and composite objects
Decorator
Add responsibilities to objects dynamically
Facade
A single class that represents an entire subsystem
Flyweight
A fine-grained instance used for efficient sharing
Behavioral design patterns
This design patterns is all about Class's
objects communication.
Chain of responsibility
A way of passing a request between a chain of objects
Command
Encapsulate a command request as an object
Interpreter
A way to include language elements in a program
Iterator
Sequentially access the elements of a collection
Mediator
Defines simplified communication between classes
Memento
Capture and restore an object's internal state
Null Object
Designed to act as a default value of an object
Observer
A way of notifying change to a number of classes
Lab Practical Part on IPT

 Revisit the following


- VB.NET Lab simulation
- C# Programming
 XML by using notepad++
 Socket Programming on Java
 RMI on Java
Software Versioning
and version control
 Versioning is the creation and management of multiple releases of a product, all of
which have the same general function but are improved, upgraded or customized.
 The term applies especially to operating systems (OSs), software and Web
services.
 Version control is the practice of ensuring collaborative data sharing and editing
among users of systems that employ different versions of a product. The terms
"versioning" and "version control" are sometimes used interchangeably even
though their technical meanings are different.
 In software versioning, subsequent releases of a specific product receive numerical
identifiers consisting of two or three numbers separated by periods. The first
number, called the major number, is increased when there are significant
improvements or changes in functionality. The second number, called the minor
number, is incremented when there are minor feature changes or significant fixes.
The third number, if it exists, is called the revision number. It is added or increased
when minor bugs are eliminated.
What Is Subversion?
Subversion is a free/open source version control system (VCS). That is, Subversion
manages files and directories, and the changes
 made to them, over time. This allows you to recover older versions of your data or
examine the history of how your data changed.
 In this regard, many people think of a version control system as a sort of “time
machine.”
Subversion's Components
Svn :The command-line client program
Svnversion :A program for reporting the state (in terms of revisions of the items
present) of a working copy
Svnlook :A tool for directly inspecting a Subversion repository
Svnadmin :A tool for creating, tweaking, or repairing a Subversion repository
mod_dav_svn :A plug-in module for the Apache HTTP Server, used to make your
repository available to others over a network
 Svnserve: A custom standalone server program, runnable as a daemon process or
invokable by SSH; another way to make your repository available to others over a
network
Svndumpfilter :A program for filtering Subversion repository dump streams
 Svnsync :A program for incrementally mirroring one repository to another over a
network
 Svnrdump:A program for performing repository history dumps and loads over a
network
Subversion architecture

You might also like