nikhil joshi
Theory
XML Theory…
Oct 2nd
Advantages of XML
-
Simplifies Data Sharing: XML data is stored in plain text format. This provides a software- and hardware-independent way of storing data.
-
Simplifies Data Transport: With XML, data can easily be exchanged between incompatible systems.
-
Since XML is independent of hardware, software and application, XML can make your data more available and useful. Different applications can access your data, not only in HTML pages, but also from XML data sources.
-
Here are some examples:
-
XHTML the latest version of HTML
-
WSDL for describing available web services
-
WAP and WML as markup languages for handheld devices
-
RSS languages for news feeds
-
RDF and OWL for describing resources and ontology
-
SMIL for describing multimedia for the web
-
-
XML Elements are Extensible: XML elements can be extended to carry more information.
XML Syntax rules:
-
XML Documents Must Have a Root Element
-
All XML Elements Must Have a Closing Tag
-
XML Tags are Case Sensitive
-
XML Elements Must be Properly Nested
-
XML Attribute Values Must be Quoted
-
Entity References
< < less than
> > greater than
& & ampersand
' ‘ apostrophe
" " quotation mark
XML attributes:
Attributes provide additional information about elements. Disadvantages of attributes:
-
attributes cannot contain multiple values (elements can)
-
attributes cannot contain tree structures (elements can)
-
attributes are not easily expandable (for future changes)
-
Attributes are difficult to read and maintain.
moral of attribute story – use elements instated of attributes.
XML Namespaces and name conflicts
Name conflicts in XML can easily be avoided using a name prefix.
<h:table>
<h:tr>
<h:td>Apples</h:td>
<h:td>Bananas</h:td>
</h:tr>
</h:table>
<f:table>
<f:name>African Coffee Table</f:name>
<f:width>80</f:width>
<f:length>120</f:length>
</f:table>
XML Namespaces provide a method to avoid element name conflicts.
-
xmlns attribute for element.
When using prefixes in XML, a so-called namespace for the prefix must be defined.
The namespace is defined by the xmlns attribute in the start tag of an element.
The namespace declaration has the following syntax. xmlns:prefix="URI"
<root>
<h:table xmlns:h="http://www.w3.org/TR/html4/">
<h:tr>
<h:td>Apples</h:td>
<h:td>Bananas</h:td>
</h:tr>
</h:table>
<f:table xmlns:f="http://www.w3schools.com/furniture">
<f:name>African Coffee Table</f:name>
<f:width>80</f:width>
<f:length>120</f:length>
</f:table>
</root> -
Default Namespaces
Defining a default namespace for an element saves us from using prefixes in all the child elements.
<table xmlns="http://www.w3.org/TR/html4/">
<tr>
<td>Apples</td>
<td>Bananas</td>
</tr>
</table>
CDATA
XML parsers normally parse all the text in an XML document. The term CDATA is used about text data that should not be parsed by the XML parser.
Characters like "<" and "&" are illegal in XML elements.
"<" will generate an error because the parser interprets it as the start of a new element.
"&" will generate an error because the parser interprets it as the start of an character entity.
Some text, like JavaScript code, contains a lot of "<" or "&" characters. To avoid errors script code can be defined as CDATA.
Everything inside a CDATA section is ignored by the parser.
A CDATA section starts with "":
<script>
<![CDATA[
function matchwo(a,b)
{
if (a < b && a < 0) then
{
return 1;
}
else
{
return 0;
}
}
]]>
</script>
Object Oriented Programming Fundamentals…
Oct 1st
Everything is OOP is grouped as self sustainable objects; hence you gain re-usability by means of four object oriented programming concepts.
Advantages of OOP
Bundling code into individual software objects provides a number of benefits, including:
-
Modularity: The source code for an object can be written and maintained independently of the source code for other objects. Once created, an object can be easily passed around inside the system.
-
Information-hiding: By interacting only with an object’s methods, the details of its internal implementation remain hidden from the outside world.
-
Code re-use: If an object already exists (perhaps written by another software developer), you can use that object in your program. This allows specialists to implement/test/debug complex, task-specific objects, which you can then trust to run in your own code.
-
Pluggability and debugging ease: If a particular object turns out to be problematic, you can simply remove it from your application and plug in a different object as its replacement. This is analogous to fixing mechanical problems in the real world. If a bolt breaks, you replace it, not the entire machine.
Concepts in OOP
-
Class
-
Object
-
Inheritance
-
Encapsulation or data hiding
-
Abstraction
-
Polymorphism
-
Class
A class is the blueprint from which individual objects are created. -
Object
Real-world objects share two characteristics: They all have state and behaviour. An object stores its state in fields(variables in some programming languages) and exposes its behaviour through methods (functions in some programming languages). -
Inheritance
Object-oriented programming allows classes to inherit commonly used state and behaviour from other classes. Each class is allowed to have one direct superclass, and each superclass has the potential for an unlimited number of subclasses.Sealed Classes:
The sealed modifier is used to prevent derivation from a class. An error occurs if a sealed class is specified as the base class of another class. A sealed class cannot also be an abstract class. -
Encapsulation or data hiding
access specifiers determine who can use the definitions that follow. public means the following definitions are available to everyone. The private keyword, on the other hand, means that no one can access those definitions except you, the creator of the type, inside member functions of that type. private is a brick wall between you and the client programmer. If someone tries to access a private member, they’ll get a compile-time error. protected acts just like private, with the exception that an inheriting class has access to protected members, but not private members. -
Abstraction
As per dictionary ‘abstraction is a general idea rather than a specific example”. Putting it in other word; abstraction is an emphasis on the idea, qualities and properties rather than the particulars (a suppression of detail). The importance of abstraction is derived from its ability to hide irrelevant details and from the use of names to reference objects. Abstraction is essential in the construction of programs. It places the emphasis on what an object is or does rather than how it is represented or how it works. Thus, it is the primary means of managing complexity in large programs.-
Abstract class:
Abstract classes, which declared with the abstract keyword, cannot be instantiated. It can only be used as a super-class for other classes that extend the abstract class. Abstract class is the concept and implementation gets completed when it is being realized by a subclass. In addition to this a class can inherit only from one abstract class (but a class may implement many interfaces) and must override all its abstract methods/ properties and may override virtual methods/ properties. -
Interface:
In summary the Interface separates the implementation and defines the structure, and this concept is very useful in cases where you need the implementation to be interchangeable. Apart from that an interface is very useful when the implementation changes frequently. Some say you should define all classes in terms of interfaces, but I think recommendation seems a bit extreme.Interface can be used to define a generic template and then one or more abstract classes to define partial implementations of the interface. Interfaces just specify the method declaration (implicitly public and abstract) and can contain properties (which are also implicitly public and abstract). Interface definition begins with the keyword interface. An interface like that of an abstract class cannot be instantiated.
If a class that implements an interface does not define all the methods of the interface, then it must be declared abstract and the method definitions must be provided by the subclass that extends the abstract class. In addition to this an interfaces can inherit other interfaces. .Net support multiple implementations, the concept of implicit and explicit implementation provide safe way to implement methods of multiple interfaces by hiding, exposing or preserving identities of each of interface methods, even when the method signatures are the same.
Theoretically a class emphasis the idea of encapsulation, while an interface emphasis the idea of abstraction (by suppressing the details of the implementation).
Abstract class Interface Interface definition begins with a keyword interface so it is of type interface Abstract classes are declared with the abstract keyword so it is of type class Interface has no implementation, but they have to be implemented. Abstract class’s methods can have implementations and they have to be extended. Interfaces can only have method declaration (implicitly public and abstract) and fields (implicitly public static) Abstract class’s methods can’t have implementation only when declared abstract. Interface can inherit more than one interfaces Abstract class can implement more than one interfaces, but can inherit only one class
-
- Polymorphism
In OOP the polymorphisms is achieved by using many different techniques named method overloading, operator overloading and method overriding.
Assume that the Class A implements a virtual method M and classes B and C that are derived from A override the virtual method M. When B is cast to A a call to the method M from A is dispatched to B. Similarly when C is cast to A a call to M is dispatched to C. The decision on exactly which method to call is delayed until runtime.
Good reference for Object Oriented Programming
Sep 28th
I found following reference for object oriented programming. This link covers all basic very nicely.
http://www.codeproject.com/KB/architecture/oop_concepts_and_manymore.aspx
Thanks to Bhushan Rane for giving me this link.
Recent Comments