Pages

Thursday, 24 May 2012

Positioning Property and Z-Index in CSS

The CSS positioning properties allow you to position an element. It can also place an element behind another, and specify what should happen when an element's content is too big.

Elements can be positioned using the top, bottom, left, and right properties. However, these properties will not work unless the position property is set first. They also work differently depending on the positioning method.

There are four different positioning methods:

1. Static Positioning

HTML elements are positioned static by default. A static positioned element is always positioned according to the normal flow of the page. Static positioned elements are not affected by the top, bottom, left, and right properties.

2. Fixed Positioning

An element with fixed position is positioned relative to the browser window. It will not move even if the window is scrolled:
p
{
position:fixed;
top:30px;
right:5px;
}

Fixed positioned elements are removed from the normal flow. The document and other elements behave like the fixed positioned element does not exist.

3. Relative Positioning

A relative positioned element is positioned relative to its normal position.

h2
{
position:relative;
left:-20px;
}
or
h2
{
position:relative;
left:20px;
}

The content of relatively positioned elements can be moved and overlap other elements, but the reserved space for the element is still preserved in the normal flow.

4. Absolute Positioning

An absolute position element is positioned relative to the first parent element that has a position other than static. If no such element is found, the containing block is <html>

h2
{
position:absolute;
left:100px;
top:150px;
}

Absolutely positioned elements are removed from the normal flow. The document and other elements behave like the absolutely positioned element does not exist. Absolutely positioned elements can overlap other elements.

Z-INDEX Property (Overlapping Elements)

The z-index property specifies the stack order of an element. An element with greater stack order is always in front of an element with a lower stack order.

Note: z-index only works on positioned elements (position:absolute, position:relative, or position:fixed).

img
{
position:absolute;
left:0px;
top:0px;
z-index:-1;
}

Thursday, 17 May 2012

Validation Controls in ASP.NET: System.Web.UI.WebControls Class

System.Web.UI.WebControls contains all the validation controls. Here is a brief description of all the validation controls in ASP.NET:

1. RequiredFieldValidator (<asp:RequiredFieldValidator>)

Checks that the validated control contains a value. It cannot be empty.

<asp:RequiredFieldValidator
id="validateTxtName"
runat="server"
display="static"
controlToValidate="txtName"
errorMessage="Name must be entered" >
</asp:RequiredFieldValidator>

2. RegularExpressionValidator (<asp:RegularExpressionValidator>)

Checks the value against a regular expression (pattern). Checks that the value in the control matches a specified regular expression. If the validated control is empty, no validation takes place. The most important property in the RegularExpressionValidator is ValidationExpression.

<asp:RegularExpressionValidator
id="regvH"
runat="server"
display="static"
controlToValidate="txtH"
errorMessage="Hours must be 1-3 digits only"
validationExpression="\d{1,3}">
</asp:RegularExpressionValidator>

3. CompareValidator (<asp:CompareValidator>)

Checks if the value is acceptable compared to a given value or compared to the content of another control. In other words, it checks that the value in the validated control matches the value in another control or a specific value. The data type and comparison operation can be specified. If the validated control is empty, no validation takes place. The most important properties in the CompareValidator are ControlToCompare, Operator, and type.

<asp:CompareValidator
id="comvR"
runat="server"
display="static"
controlToValidate="txtR"
errorMessage="Rate must be numeric"
ValueToCompare="txtA">
</asp:CompareValidator>

4. RangeValidator (<asp:RangeValidator>

Checks if the input control’s value is within a specified range. In other words, it checks that the value in the validated control is within the specified text or numeric range. If the validated control is empty, no validation takes place. The most important properties in the RangeValidator are MaximumValue, MinimumValue, and type.

<asp:RangeValidator
id="ranvDependents"
runat="server"
display="static"
controlToValidate="txtDependents"
errorMessage="Must be from 0 to 10"
type="Integer"
minimumValue=0
maximumValue=10>
</asp:RangeValidator>

5. CustomValidator (<asp:CustomValidator>)

Allows you to develop custom validation. Performs user-defined validation on an input control using a specified function (client-side, server-side, or both). If the validated control is empty, no validation takes place. The most important property in the CustomValidator is ClientValidationFunction.

<asp:CustomValidator
id="cusvDeptNum"
runat="server"
display="static"
controlToValidate="txtDeptNum"
onServerValidate="validateDeptNum"
errorMessage="Must be in multiples of 10" >
</asp:CustomValidator>

6. ValidationSummary (<asp:ValidationSummary>)

Displays a summary of all current validation errors. In other words, reports a summary of all errors. The most important properties in the ValidationSummary are DisplayMode, ShowHeaderText, ShowMessageBox, and ShowSummary.

<asp:ValidationSummary
id="valSummary"
runat="server"
display="static"
headerText="Please correct the following errors"
showSummary= "True" />

Wednesday, 16 May 2012

COM Family: COM+ and DCOM, Interop, RPC and TLB

Microsoft COM (Component Object Model) technology enables different software components to communicate. It was introduced by Microsoft in 1993. The family of COM technologies includes COM+, Distributed COM (DCOM) and ActiveX Controls.

COM provides interoperability. COM allows reuse of objects with no knowledge of their internal implementation.COM objects can be used with all .NET languages through .NET COM Interop.

COM interfaces have bindings in several languages, such as C, C++, Visual Basic, Delphi, and several of the scripting languages implemented on the Windows platform. All access to components is done through the methods of the interfaces.

Type Library in COM (.tlb file)

First, you must create a type library for the assembly. A type library is the COM equivalent of the metadata contained within a .NET assembly. Type libraries are generally contained in files with the extension .tlb. A type library contains the necessary information to allow a COM client to determine which classes are located in a particular server, as well as the methods, properties, and events supported by those classes. Each component or dll file must contain type library.

COM Interop

COM Interop is a technology included in the .NET CLR that enables COM objects to interact with .NET objects, and vice versa. COM Interop allows COM developers to access managed objects as easily as they access other COM objects.

The .NET Framework creates a type library and special registry entries when a component (compiled in the form of DLL) is registered. It provides a specialized utility that exports the managed types into a type library and registers the managed component as a traditional COM component. When the type is instantiated through COM, the .NET CLR is the actual COM object that executes and it merely marshals any method calls or property access to the type implementation.

Reference Counting, Pooling and Memory Management in COM:

The COM specifications require a technique called reference counting to ensure that individual objects remain alive as long as there are clients which have acquired access to one or more of its interfaces and, conversely, that the same object is properly disposed of when all code that used the object have finished with it and no longer require it. A COM object is responsible for freeing its own memory once its reference count drops to zero. Pooling for objects can also be set for different components.

RPC (Remote Procedure Call)

Microsoft Remote Procedure Call (RPC) is a powerful technology for creating distributed client/server programs. RPC is an interprocess communication technique that allows client and server software to communicate.

dcomcnfg:

To access settings on a computer running Windows 2000, Windows XP and earlier, click Start > Run, and type "dcomcnfg". (Click NO for any warning screens that appear.) To access DCOM settings on a computer running Windows Vista or later, click Start, type "dcomcnfg", right-click "dcomcnfg.exe" in the list, and click "Run as administrator".

COM is very similar to other component software interface technologies, such as CORBA and Java Beans, although each has its own strengths and weaknesses.

COM Family:

COM+: COM+ is the name of the COM-based services and technologies first released in Windows 2000. It provides  distributed transactions, resource pooling, disconnected applications, event publication and subscription, better memory and processor (thread) management.

DCOM: DCOM isDistributed COM. DCOM uses RPC mechanism for communication. It allows COM components to communicate across network boundaries.It provides load balancing.COM installation and execution is done in its clien machine where DCOM is intalled and run on selected server machine.

DCOM is generally equivalent to the Common Object Request Broker Architecture ( CORBA ) in terms of providing a set of distributed services. But unlike CORBA, which runs on many operating systems, DCOM is currently implemented only for Windows.

Migrate from COM application

Although calling a COM component from managed code is simple, you should not consider this a permanent solution for most applications. Over the long run, you'll want to migrate heavily used components to native .NET code. This will provide you with the full range of .NET capabilities, as well as make your code faster by eliminating the RCW layer.

Decline of COM

Several of the services that COM+ provides have been largely replaced by recent releases of .NET. For example, the System.Transactions namespace in .NET provides the TransactionScope class, which provides transaction management without resorting to COM+. Similarly, queued components can be replaced by Windows Communication Foundation with an MSMQ transport.

Frameset, Frame and IFrame Elements in HTML

Frame Element

With frames, you can display more than one HTML document in the same browser window. Each HTML document is called a frame, and each frame is independent of the others.

Disadvantages of using frames:

1. Frames are not expected to be supported in future versions of HTML
2. Frames are difficult to use. (Printing the entire page is difficult).
3. The web developer must keep track of more HTML documents

Frameset Element

The frameset element holds one or more frame elements. Each frame element can hold a separate document. The frameset element states HOW MANY columns or rows there will be in the frameset, and HOW MUCH percentage/pixels of space will occupy each of them.

The <frameset> tag defines a frameset. The <frameset> element holds one or more <frame> elements.

Example: The first column is set to 25% of the width of the browser window. The second column is set to 75% of the width of the browser window. The document "frame_a.htm" is put into the first column, and the document "frame_b.htm" is put into the second column:

<frameset cols="25%,75%">
   <frame src="frame_a.htm" />
   <frame src="frame_b.htm" />
</frameset>

IFrame Element

IFrame defines an inline sub window (frame). An iframe is used to display a web page within a web page.

Syntax: <iframe src="URL"></iframe>

The height and width attributes are used to specify the height and width of the iframe.
The attribute values are specified in pixels by default, but they can also be in percent (like "80%").

Example
<iframe src="demo_iframe.htm" width="200" height="200"></iframe>
The frameborder attribute specifies whether or not to display a border around the iframe.
Set the attribute value to "0" to remove the border:

Example
<iframe src="demo_iframe.htm" frameborder="0"></iframe>

Points to note about Frames, Framesets and IFrames

1. The <frameset> tag is supported in all major browsers.
2. If you want to validate a page containing frames, be sure the <!DOCTYPE> is set to either "HTML Frameset DTD" or "XHTML Frameset DTD".
3. If a frame has visible borders, the user can resize it by dragging the border. To prevent a user from doing this, you can add noresize="noresize" to the <frame> tag.
4. Add the <noframes> tag for browsers that do not support frames.
5. Inline frame is just one “box” that is placed anywhere on browser page. In contrast, frame is a bunch of boxes put together to make one site.
 

Tuesday, 15 May 2012

List of problems occuring while using html tables

1. Rendering the table is time consuming

The entire table must be downloaded and the dimensions of everything in the table must to be known before the table can be rendered. That can delay the rendering of your content, especially if your table contains images without HEIGHT or WIDTH attributes.

2. Problems in display and layout of contents

If any of your table's content is too wide for the available display area, then the table stretches to accomodate the oversized content. The rest of the content then adjusts to fit the oversized table rather than fitting the available display area. This can force your readers to scroll horizontally to read your content, or can cause printed versions to be cropped.

For readers whose displays are narrower than the author anticipated, fixed-width tables cause the same problems as other oversized tables. For readers whose displays are wider than the author anticipated, fixed-width tables cause extremely wide margins, wasting much of the display area. For readers who need larger fonts, fixed-width tables can cause the content to be displayed in short choppy lines of only a few words each.

3. Search Engine Optimization Issues

Some search engines use the text at the beginning of a document to summarize it when it appears in search results, and some index only the first n bytes of a document. When tables are used for layout, the beginning of a document often contains many navigation links that appear before than actual content. Some search engines ingnore the tables.

4. Syntax issues with tables

Many browsers are especially sensitive to invalid syntax when tables are involved. Correct syntax is especially critical. Even with correct syntax, nested tables may not display correctly in older versions of Netscape Navigator.

Some browsers ignore tables, or can be configured to ignore tables. These browsers will ignore any layout you've created with tables.

Many versions of Navigator have problems linking to named anchors when they are inside a table that uses the ALIGN attribute. These browsers seem to associate the named anchor with the top of the table, rather than with the content of the anchor. You can avoid this problem by not using the ALIGN attribute on your tables.

Take precautions while using tables:

If you use tables for layout, you can still minimize the related problems with careful markup. Avoid placing wide images, PRE elements with long lines, long URLs, or other wide content inside tables. Rather than a single full-page layout table, use several independent tables. For example, you could use a table to lay out a navigation bar at the top/bottom of the page, and leave the main content completely outside any layout tables.

Alternative of XML: JSON (JavaScript Object Notation)

JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate.JSON is a text format that is completely language independent.

The JSON format is often used for serializing and transmitting structured data over a network connection. It is used primarily to transmit data between a server and web application, serving as an alternative to XML. JSON is a subset of The file type for JSON files is ".json". The MIME type for JSON text is "application/json"

Data Types in JSON

Data structures in JSON are based on key / value pairs. The key is a string, the value can be a numerical value, a boolean value (true or false), array or an object.

1. Number (integer or floating point)
2. String  (in double quotes)
3. Boolean (true or false)
4. Array (an ordered sequence of values, comma-separated and enclosed in square brackets; the values do not need to be of the same type)
Example: var continents = ["Europe", "Asia", "Australia", "Antarctica", "North  America", "South America", "Africa"];
5. Object (an unordered collection of key:value pairs with the ':' character separating the key and the value, omma-separated and enclosed in curly braces; the keys must be strings and should be distinct from each other)
Example: var mailingAddress = {  "Address" : "123 Anywhere St.",  "City" : "Springfield", "PostalCode" :   99999 };
6. null (empty)

JSON Parser

Since JSON syntax is a subset of JavaScript syntax, the JavaScript function eval() can be used to convert a JSON text into a JavaScript object. The eval() function uses the JavaScript compiler which will parse the JSON text and produce a JavaScript object.

The eval() function can compile and execute any JavaScript. This represents a potential security problem. It is safer to use a JSON parser to convert a JSON text to a JavaScript object. A JSON parser will recognize only JSON text and will not compile scripts. In browsers that provide native JSON support, JSON parsers are also faster. Native JSON support is included in newer browsers and in the newest ECMAScript (JavaScript) standard.

Similarities between XML and JSON

1. JSON and XML are plain text
2. JJSON and XML are "self-describing" (human readable)
3. JSON and XML are hierarchical.
4. JSON and XML can be parsed by JavaScript
5. JSON and XML data can be transported using AJAX

Differences between XML and JSON

1. Data types

XML: Does not provide any notion of data types. One must rely on XML Schema for adding type information.
JSON: Provides scalar data types and the ability to express structured data through arrays and objects.

2. Support for arrays

XML: Arrays have to be expressed by conventions, for example through the use of an outer placeholder element that models the arrays contents as inner elements. Typically, the outer element uses the plural form of the name used for inner elements.
JSON: Native array support

3. Support for objects

XML: Objects have to be expressed by conventions, often through a mixed use of attributes and elements.
JSON: Native object support.

4. Null support

XML: Requires use of xsi:nil on elements in an XML instance document plus an import of the corresponding namespace.
JSON: Natively recognizes the null value

5. Comments

XML: Native support and usually available through APIs.
JSON: Not supported.

6. Namespaces

XML: Supports namespaces, which eliminates the risk of name collisions when combining documents. Namespaces also allow existing XML-based standards to be safely extended.
JSON: No concept of namespaces. Naming collisions are usually avoided by nesting objects or using a prefix in an object member name.

7. Formatting decisions

XML: Complex. Requires a greater effort to decide how to map application types to XML elements and attributes. Can create heated debates whether an element-centric or attribute-centric approach is better.
JSON: Simple. Provides a much more direct mapping for application data. The only exception may be the absence of date/time literal.

8. Size

XML: Documents tend to be lengthy in size, especially when an element-centric approach to formatting is used.
JSON: Syntax is very terse and yields formatted text where most of the space is consumed (rightly so) by the represented data.

9. Parsing in JavaScript

XML: Requires an XML DOM implementation and additional application code to map text back into JavaScript objects.
JSON: No additional application code required to parse text; can use JavaScript's eval function.

10. Learning curve

XML: Generally tends to require use of several technologies in concert: XPath, XML Schema, XSLT, XML Namespaces, the DOM, and so on.
JSON: Very simple technology stack that is already familiar to developers with a background in JavaScript or other dynamic programming languages.

11. Tools

XML: Enjoys a mature set of tools widely available from many industry vendors.
JSON: Rich tool support—such as editors and formatters—is scarce.

12. Reserved Keywords

XML: There are reserved keywords.
JSON: No reserved keywords

JSON: An Alternative of XML

1. When data is encoded in XML, the result is typically larger than an equivalent encoding in JSON, mainly because of XML's closing tags. JSON is smaller than XML, and faster and easier to parse.

2. AJAX Support in JSON: Althought most browsers can construct, send, and parse XML, JavaScript Object Notation (or JSON) provides a standardized data exchange format that is better-suited for Ajax-style web applications.

For AJAX applications, JSON is faster and easier than XML:

Using XML

1. Fetch an XML document
2. Use the XML DOM to loop through the document
3. Extract values and store in variables

Using JSON

1. Fetch a JSON string
2. eval() the JSON string

Basic Points of SOA (Service Oriented Architecture)

1. SOA stands Service Oriented Architecture.

2. SOA is not a specific technology, nor a specific language. It is just a blueprint, or a system design approach.

3. The key concepts of SOA are services, high interoperability and loose coupling.

4. SOA states that every component of a system should be a service, and the system should be composed of several loosely-coupled services.

5. A service means a unit of a program that serves a business process. A service is typically hosted on a remote machine (provider), and called by a client application (consumer) over a network. After the provider of a web service publishes the service, the client can discover it and invoke it. The communications between a web service and a client application use XML messages.

The client application is unaware of how the service is implemented, or of the signature that should be used when interacting with those services. The client application interacts with these services by exchanging messages. What a client application knows now is only the interfaces, or protocols of the services, such as the format of the messages to be passed in to the service, and the format of the expected returning messages from the service.

6. Web services are the most popular and practical way of realizing SOA. Each web service has a unique URL, and contains various methods. When calling a web service, you have to specify which method you want to call, and pass the required parameters to the web service method. Each web service method will also give a response package to tell the caller the execution results.

7. "Loosely-coupled"  means that these services should be independent of each other. A change to one service does not affect any other service. Also, the deployment of a new service does not affect any existing service. This greatly eases release management and makes agility possible.

8. As OOPs replaced various procedural techniques, SOA replaced various existing communication technologies like RPC, DCOM, and CORBA

11 Commonly used AJAX Frameworks

There are hundreds of AJAX Frameworks available. Most commonly used frameworks are jQuery, MooTools, Prototype, ASP.NET AJAX, Apache Wicket, Dojo Toolkit, DWR (Direct Web Remoting), Spry Framework, YUI (Yahoo User Interface) and Google Web Toolkit.

Here is a small description of these frameworks:

1. jQuery:  The jQuery library is providing many easy to use functions and methods to make rich applications. These functions are very easy to learn and even a designer can learn it fast. Due to these features jQuery is very popular and in high demand among the developers. You can use jQuery in all the web based applications irrespective of the technology.

2. MooTools: MooTools (My Object-Oriented Tools) is a lightweight, object-oriented, JavaScript framework. It is released under the free, open-source MIT License. It is used on more than 5% of all websites, and is one of the most popular JavaScript libraries.

3. Prototype: Prototype is a JavaScript Framework that aims to ease development of dynamic web applications. It features a unique, easy-to-use toolkit for class-driven development and the nicest Ajax library around, Prototype is quickly becoming the codebase of choice for web application developers everywhere.

4. ASP.NET AJAX: The ASP.NET AJAX Control Toolkit is an open-source project built on top of the Microsoft ASP.NET AJAX framework. It is a joint effort between Microsoft and the ASP.NET AJAX community that provides a powerful infrastructure to write reusable, customizable and extensible ASP.NET AJAX extenders and controls, as well as a rich array of controls that can be used out of the box to create an interactive web experience.

5. Apache Wicket: Apache Wicket, commonly referred to as Wicket, is a lightweight component-based web application framework for the Java programming language conceptually similar to JavaServer Faces and Tapestry.

6. Dojo Tookit: Dojo Toolkit is an open source modular JavaScript library (or more specifically JavaScript toolkit) designed to ease the rapid development of cross-platform, JavaScript/Ajax-based applications and web sites.

7. DWR (Direct Web Remoting): DWR is a Java library that enables Java on the server and JavaScript in a browser to interact and call each other as simply as possible.

8. Spry Framework: The Spry Framework is an open source Ajax framework developed by Adobe Systems which is used in the construction of Rich Internet Applications. Unlike other pure JavaScript frameworks such as the Dojo Toolkit and Prototype, Spry is geared towards web designers, not web developers.

9. YUI (Yahoo User Interface) Library: It is a set of utilities and controls, for building richly interactive web applications using techniques such as DOM scripting, DHTML and Ajax BSD.

10. Google Web Toolkit: Google Web Toolkit is an open source set of tools that allows web developers to create and maintain complex JavaScript front-end applications in Java. Other than a few native libraries, everything is Java source that can be built on any supported platform with the included GWT Ant build files. It is licensed under the Apache License version 2.0.

11. ZK Framework: ZK is an open-source Ajax Web application framework, written in Java, that enables creation of rich graphical user interfaces for Web applications without the application developer having to write JavaScript and with little required programming knowledge.

Monday, 14 May 2012

WCF: A SOA based Service Framework


WCF stands for Windows Communication Foundation (Code Name: Indigo). Windows Communication Foundation (WCF) is a framework for building service-oriented applications. It is unified programming model provided in .Net Framework 3.0. WCF is meant for designing and deploying distributed applications under Service Oriented Architecture (SOA) implementation. WCF accomodates functionalities of its older communication technologies like:

1. Web Service (ASMX)
2. Web Service Enhancement (WSE)
3. Microsoft Message Queuing (MSMQ)
4. Component Object Model (COM+)
5. .Net Remoting

Components of WCF:

1. Service: A service is basically a class written in a .Net compliant language which contains some methods that are exposed through the WCF service. A service may have one or more endpoints – an endpoint is responsible for communication from the service to the client.

2. End Points: The End Points consists Address (Where), Contract (What) and Binding (How).

Address (Where): Indicates where a webservice could be found. Technically speaking, URL of the webservice.

Contract (What): Contract is an agreement between two or more parties. It defines the protocol how client should communicate with your service. Technically speaking, it describes parameters and return values for a web method in a web service.

Binding (How): Binding specifies what communication protocols are used to access the service, whether security mechanisms are to be used, and the like. WCF includes predefined bindings for most common communication protocols such as SOAP over HTTP, SOAP over TCP, and SOAP over Message Queues, etc. Interaction between WCF endpoint and client is done using a SOAP envelope. SOAP envelopes are in simple XML form that makes WCF platform independent.

The mnemonic "ABC" can be used to remember address / binding / Contract.

3. Hosting Environment: WCF can be hosted on IIS or on other environment (Self-hosting). There are two main advantages of using IIS over self-hosting:-

Automatic activation: IIS provides automatic activation that means the service is not necessary to be running in advance. When any message is received by the service it then launches and fulfills the request. But in case of self hosting the service should always be running.

Process recycling: If IIS finds any memory leaks etc in web service, IIS recycles the process.

Features of WCF:

Service Orientation: One consequence of using WS standards is that WCF enables you to create service oriented applications. Service-oriented architecture (SOA) is the reliance on Web services to send and receive data. The services have the general advantage of being loosely-coupled instead of hard-coded from one application to another. A loosely-coupled relationship implies that any client created on any platform can connect to any service as long as the essential contracts are met.

Interoperability: WCF implements modern industry standards for Web service interoperability.

Multiple Message Patterns: Messages are exchanged in one of several patterns. The most common pattern is the request/reply pattern, where one endpoint requests data from a second endpoint. The second endpoint replies. There are other patterns such as a one-way message in which a single endpoint sends a message without any expectation of a reply. A more complex pattern is the duplex exchange pattern where two endpoints establish a connection and send data back and forth, similar to an instant messaging program.

Service Metadata: WCF supports publishing service metadata using formats specified in industry standards such as WSDL, XML Schema and WS-Policy. This metadata can be used to automatically generate and configure clients for accessing WCF services. Metadata can be published over HTTP and HTTPS or using the Web Service Metadata Exchange standard.

Data Contracts: Because WCF is built using the .NET Framework, it also includes code-friendly methods of supplying the contracts you want to enforce. One of the universal types of contracts is the data contract. In essence, as you code your service using Visual C# or Visual Basic, the easiest way to handle data is by creating classes that represent a data entity with properties that belong to the data entity. WCF includes a comprehensive system for working with data in this easy manner. Once you have created the classes that represent data, your service automatically generates the metadata that allows clients to comply with the data types you have designed.

Security: Messages can be encrypted to protect privacy and you can require users to authenticate themselves before being allowed to receive messages. Security can be implemented using well-known standards such as SSL or WS-SecureConversation.

Multiple Transports and Encodings: Messages can be sent on any of several built-in transport protocols and encodings. The most common protocol and encoding is to send text encoded SOAP messages using is the HyperText Transfer Protocol (HTTP) for use on the World Wide Web. Alternatively, WCF allows you to send messages over TCP, named pipes, or MSMQ. These messages can be encoded as text or using an optimized binary format. Binary data can be sent efficiently using the MTOM standard. If none of the provided transports or encodings suit your needs you can create your own custom transport or encoding.

Reliable and Queued Messages: WCF supports reliable message exchange using reliable sessions implemented over WS-Reliable Messaging and using MSMQ.

Durable Messages: A durable message is one that is never lost due to a disruption in the communication. The messages in a durable message pattern are always saved to a database. If a disruption occurs, the database allows you to resume the message exchange when the connection is restored. You can also create a durable message using the Windows Workflow Foundation (WF).

Transactions: WCF also supports transactions using one of three transaction models: WS-AtomicTtransactions, the APIs in the System.Transactions namespace, and Microsoft Distributed Transaction Coordinator.

AJAX and REST Support: REST is an example of an evolving Web 2.0 technology. WCF can be configured to process "plain" XML data that is not wrapped in a SOAP envelope. WCF can also be extended to support specific XML formats, such as ATOM (a popular RSS standard), and even non-XML formats, such as JavaScript Object Notation (JSON).

Extensibility: The WCF architecture has a number of extensibility points. If extra capability is required, there are a number of entry points that allow you to customize the behavior of a service.

Relation between SOA and WCF

1. In SOA, a service must have End Points. WCF has all these end points: Address, Contract and Binding

2. Versioning of Services in WCF: In SOA, services can be versioned and you can host those services at new end points.

For example: You have a service named 'YourService' at end point “ep1”. Now you make enhancements in your service and launch a new service 'YourService2'. You can use it at another end point say "ep2". So the client who is consuming the service at end ep1 continues and at the other end, you have evolved your service by adding new ends ep2.

3. In SOA, the client who is consuming the service does not need to know how the implementation of the service is done. Services use Schemas to represent data and Contracts to understand behavior. They do not use language dependent types or classes in order to understand data and behavior. XML is used to define schemas and contracts.Same strategy is followed in WCF.

Advantages of WCF over older communication technologies:

1. WCF is interoperable with other services when compared to .Net Remoting, where the client and service have to be .Net.
2. WCF services provide better reliability and security in compared to ASMX web services.
3. WCF has integrated logging mechanism, changing the configuration file settings will provide this functionality. In other technology developer has to write the code.
4. WCF is faster than previous communication technologies by microsoft.
 

WPF (Windows Presentation Foundation): Features

Microsoft introduced WPF (Windows Presentation Foundation) API in .NET 3.0 framework (previously known as WinFX). WPF merged all the unrelated APIs into a single unified object model. WPF combines application UIs, 2D graphics, 3D graphics, documents and multimedia into one single framework. It provides a consistent programming model for building applications and provides a clear separation between the user interface and the business logic. So if you want to use 3D graphics or multimedia for your application, you do not use to need use different APIs. WPF provides all the functionalities you need to develop richer GUI applications.

Features of WPF:

1. Separation of Appearance and Behavior: WPF separates the appearance of an user interface from its behavior. The appearance is generally specified in the Extensible Application Markup Language (XAML), the behavior is implemented in a managed programming language like C# or Visual Basic. XAML, the Extensible Application Markup Language is used to create custom controls, graphics, 3D images and animations that are not available in traditional HTML implementations.

2. Rich composition: Controls in WPF are extremely composable. You can define almost any type of controls as content of another. Although these flexibility sounds horrible to designers, its a very powerful feature if you use it appropriate. Put an image into a button to create an image button, or put a list of videos into a combobox to choose a video file.

3. Highly customizable: Because of the strict separation of appearance and behavior you can easily change the look of a control. The concept of styles let you skin controls almost like CSS in HTML. Templates let you replace the entire appearance of a control.

4. Resolution independence: All measures in WPF are logical units - not pixels. A logical unit is a 1/96 of an inch. If you increase the resolution of your screen, the user interface stays the same size - it just gets crispier. Since WPF builds on a vector based rendering engine it's incredibly easy to build scaleable user interfaces.

5. Data binding: WPF has a built-in set of data services to enable application developers to bind and manipulate data within applications.

6. Direct3D: Graphics, including desktop items like windows, are rendered using Direct3D. This allows the display of more complex graphics and custom themes, at the cost of GDI's wider range of support and uniform control theming. It allows Windows to offload some graphics tasks to the GPU.

7. Media services: The WCF provides an integrated system for building user interfaces with common media elements like vector and raster images, audio, and video. WPF also provides an animation system and a 2D/3D rendering system.

8. Templates: In WPF you can define the look of an element directly, via its properties, or indirectly with a Template or Style.

9. Animations: WPF supports time-based animations, in contrast to the frame-based approach. This decouples the speed of the animation from how the system is performing.

10. Imaging: WPF can natively access Windows Imaging Component (WIC) code and APIs allowing developers to write image codecs for their specific image file formats.

11. Documents: WPF natively supports paginated documents. It provides the DocumentViewer class, which is for reading fixed layout documents.

12. Text: WPF includes a number of typographic and text rendering features that were not available in GDI.

Sunday, 13 May 2012

Relation between Tablespace, Datafile and Control File

Databases, tablespaces, and datafiles are closely related, but they have important differences:

An Oracle database consists of one or more logical storage units called tablespaces, which collectively store all of the database's data.

Each tablespace in an Oracle database consists of one or more files called datafiles, which are physical structures that conform to the operating system in which Oracle is running.

A database's data is collectively stored in the datafiles that constitute each tablespace of the database. For example, the simplest Oracle database would have one tablespace and one datafile. Another database can have three tablespaces, each consisting of two datafiles (for a total of six datafiles).

Tablespace:

A database is divided into one or more logical storage units called tablespaces. Tablespaces are divided into logical units of storage called segments, which are further divided into extents. Extents are a collection of contiguous blocks.

Default Tablespaces: System, SysAux, Undo and Temporary

Other Tablespaces: Bigfile, Read-only, Temporary Tablespaces for Sort Operation

1. Tablespaces can be made online and offline.
2. Tablespaces can be transported from one database to another.

Datafiles:

When a datafile is first created, the allocated disk space is formatted but does not contain any user data. However, Oracle reserves the space to hold the data for future segments of the associated tablespace—it is used exclusively by Oracle. As the data grows in a tablespace, Oracle uses the free space in the associated datafiles to allocate extents for the segment.

Control Files:

The database control file is a small binary file necessary for the database to start and operate successfully. A control file is updated continuously by Oracle during database use, so it must be available for writing whenever the database is open. If for some reason the control file is not accessible, then the database cannot function properly.

Each control file is associated with only one Oracle database.

6 Advantages of using stored procedures in your application

Applications that use stored procedures have the following advantages:

1. Stored Procedures are Precompiled

Once created, these can be used again and again  without compilation.

2. Reduced network usage between clients and servers

A client application passes control to a stored procedure on the database server. The stored procedure performs intermediate processing on the database server, without transmitting unnecessary data across the network. Only the records that are actually required by the client application are transmitted. Using a stored procedure can result in reduced network usage and better overall performance.

Applications that execute SQL statements one at a time typically cross the network twice for each SQL statement. A stored procedure can group SQL statements together, making it necessary to only cross the network twice for each group of SQL statements. The more SQL statements that you group together in a stored procedure, the more you reduce network usage and the time that database locks are held. Reducing network usage and the length of database locks improves overall network performance and reduces lock contention problems.

Applications that process large amounts of SQL-generated data, but present only a subset of the data to the user, can generate excessive network usage because all of the data is returned to the client before final processing. A stored procedure can do the processing on the server, and transmit only the required data to the client, which reduces network usage.

3. Enhanced hardware and software capabilities

Applications that use stored procedures have access to increased memory and disk space on the server computer. These applications also have access to software that is installed only on the database server. You can distribute the executable business logic across machines that have sufficient memory and processors.

4. Improved security

By including database privileges with stored procedures that use static SQL, the database administrator (DBA) can improve security. The DBA or developer who builds the stored procedure must have the database privileges that the stored procedure requires. Users of the client applications that call the stored procedure do not need such privileges. This can reduce the number of users who require privileges.

5. Reduced development cost and increased reliability

In a database application environment, many tasks are repeated. Repeated tasks might include returning a fixed set of data, or performing the same set of multiple requests to a database. By reusing one common procedure, a stored procedure can provide a highly efficient way to address these recurrent situations.

6. Centralized security, administration, and maintenance for common routines

By managing shared logic in one place at the server, you can simplify security, administration, and maintenance . Client applications can call stored procedures that run SQL queries with little or no additional processing.

Friday, 11 May 2012

Window Object in Javascript: Properties and Methods

1 The Window object is the top level object and represents the window of the browser.

2. Window objects are either the current window (if the browser is displaying only a single document), or those created with a window.open() method (where the name is specified in the code), or separate frames, if the document is laid out using a <FRAMESET> definition (where the windows are named in the <FRAME> element).

3. As the Window object is the top level object in the object hierarchy and the existance of the current window is assumed, most Window properties need not be prefixed by Window. For example, the following two references are identical :

window.defaultStatus
defaultStatus

and would both return the default text of the status bar for the current window.

4. Difference between Window and Documnet Objects:

Window is the first thing that gets loaded into the browser. The document object is your html document that will be loaded into the browser. The Document object provides access to all HTML elements in a page, from within a script. The document actually gets loaded inside the window object. The Document object is a part of the Window object, and can be accessed through the window.document property.

Window Objecy Properties

closed: Returns a Boolean value indicating whether a window has been closed or not
defaultStatus: Sets or returns the default text in the statusbar of a window
document: Returns the Document object for the window
frames: Returns an array of all the frames (including iframes) in the current window
history: Returns the History object for the window
innerHeight: Sets or returns the inner height of a window's content area
innerWidth: Sets or returns the inner width of a window's content area
length: Returns the number of frames (including iframes) in a window
location: Returns the Location object for the window
name: Sets or returns the name of a window
navigator: Returns the Navigator object for the window
opener: Returns a reference to the window that created the window
outerHeight: Sets or returns the outer height of a window, including toolbars/scrollbars
outerWidth: Sets or returns the outer width of a window, including toolbars/scrollbars
pageXOffset: Returns the pixels the current document has been scrolled (horizontally) from the upper left corner of the window
pageYOffset: Returns the pixels the current document has been scrolled (vertically) from the upper left corner of the window
parent: Returns the parent window of the current window
screen: Returns the Screen object for the window
screenLeft: Returns the x coordinate of the window relative to the screen
screenTop: Returns the y coordinate of the window relative to the screen
screenX: Returns the x coordinate of the window relative to the screen
screenY: Returns the y coordinate of the window relative to the screen
self: Returns the current window
status: Sets the text in the statusbar of a window
top: Returns the topmost browser window

Window Object Methods

alert(): Displays an alert box with a message and an OK button
blur(): Removes focus from the current window
clearInterval(): Clears a timer set with setInterval()
clearTimeout(): Clears a timer set with setTimeout()
close(): Closes the current window
confirm(): Displays a dialog box with a message and an OK and a Cancel button
createPopup(): Creates a pop-up window
focus(): Sets focus to the current window
moveBy(): Moves a window relative to its current position
moveTo(): Moves a window to the specified position
open(): Opens a new browser window
print(): Prints the content of the current window
prompt(): Displays a dialog box that prompts the visitor for input
resizeBy(): Resizes the window by the specified pixels
resizeTo(): Resizes the window to the specified width and height
scroll(): Scrolls the window
scrollBy(): Scrolls the content by the specified number of pixels
scrollTo(): Scrolls the content to the specified coordinates
setInterval(): Calls a function or evaluates an expression at specified intervals (in milliseconds)
setTimeout(): Calls a function or evaluates an expression after a specified number of milliseconds

DECODE Function vs CASE Statement in Oracle

Decode Function and Case Statement in Oracle: Decode Function and Case Statement are used to transform data values at retrieval time. DECODE and CASE are both analogous to the "IF THEN ELSE" conditional statement.

History of DECODE and CASE:

Before version 8.1, the DECODE was the only thing providing IF-THEN-ELSE functionality in Oracle SQL. Because DECODE can only compare discrete values (not ranges), continuous data had to be contorted into discreet values using functions like FLOOR and SIGN. In version 8.1, Oracle introduced the searched CASE statement, which allowed the use of operators like > and BETWEEN (eliminating most of the contortions) and allowing different values to be compared in different branches of the statement (eliminating most nesting). In version 9.0, Oracle introduced the simple CASE statement, that reduces some of the verbosity of the CASE statement, but reduces its power to that of DECODE.

Decode Function and Case Statement Example: 

Example with DECODE function

Say we have a column named REGION, with values of N, S, W and E. When we run SQL queries, we want to transform these values into North, South, East and West. Here is how we do this with the decode function:

select
decode (
region,
‘N’,’North’,
‘S’,’South’,
‘E’,’East’,
‘W’,’West’,
‘UNKNOWN’
)
from
customer;

Note that Oracle decode starts by specifying the column name, followed by set of matched-pairs of transformation values. At the end of the decode statement we find a default value. The default value tells decode what to display if a column values is not in the paired list.

Example with CASE statement

select
case
region
when ‘N’ then ’North’
when ‘S’ then ’South’
when ‘E’ then ’East’,
when ‘W’ then ’West’
else ‘UNKNOWN’
end
from
customer;

Difference between DECODE and CASE:

Everything DECODE can do, CASE can. There is a lot more that you can do with CASE, though, which DECODE cannot. Differences between them are listed below:

1. DECODE can work with only scaler values but CASE can work with logical oprators, predicates and searchable subqueries.
2. CASE can work as a PL/SQL construct but DECODE is used only in SQL statement.CASE can be used as parameter of a function/procedure.
3. CASE expects datatype consistency, DECODE does not.
4. CASE complies with ANSI SQL. DECODE is proprietary to Oracle.
5. CASE executes faster in the optimizer than does DECODE.
6. CASE is a statement while DECODE is a fucntion.

Thursday, 10 May 2012

Oracle Streams: An Overview

Oracle Streams enables information sharing. Each unit of shared information is called a message. The stream can propagate information within a database or from one database to another. Oracle Streams can be set up in homogeneous (all Oracle databases) or heterogeneous (non-Oracle and Oracle databases) environments.

Oracle Streams Information Flow

The database changes (DDL and DML) are captured at the source; those are then staged and propagated to one or more destination databases to be applied there.

Capturing ---> Staging ----> Propagating ---> Consuming

Capturing a Message:

Oracle Streams provides two ways to capture database changes implicitly: capture processes and synchronous captures.

Capture Process (Implicit Capture)

A capture process can capture DML changes made to tables, schemas, or an entire database, as well as DDL changes. Database changes are recorded in the redo log for the database. A capture process captures changes from the redo log and formats each captured change into a message called a logical change record (LCR - A message with a specific format that describes a database change). The messages captured by a capture process are called captured LCRs. A capture process can capture changes locally at the source database, or it can capture changes remotely at a downstream database. Capture Processes always caputre change from REDO LOGS.

Synchronous Process (Implicit Capture)

A synchronous capture can capture DML changes made to tables. Rules determine which changes are captured by a capture process or synchronous capture. A synchronous capture uses an internal mechanism to capture changes and format each captured change into an LCR. The messages captured by a synchronous capture are called persistent LCRs. A synchronous capture can only capture changes locally at the source database.

Explicit Capture:

Users and applications can also enqueue messages manually. These messages can be LCRs, or they can be messages of a user-defined type called user messages. When users and applications enqueue messages manually, it is referred to as explicit capture.

Staging a Message

Messages are stored (or staged) in a queue. These messages can be logical change records (LCRs) or user messages. Capture processes and synchronous captures enqueue messages into an ANYDATA queue, which can stage messages of different types. Users and applications can enqueue messages into an ANYDATA queue or into a TYPED queue. A TYPED queue can stage messages of one specific type only.

Propagating a Message

Oracle Streams propagations can propagate messages from one queue to another. These queues can be in the same database or in different databases.

Oracle Streams enables you to configure an environment in which changes are shared through directed networks. In a directed network, propagated messages pass through one or more intermediate databases before arriving at a destination database where they are consumed. The messages might or might not be consumed at an intermediate database in addition to the destination database.

Consuming a Message

A message is consumed when it is dequeued from a queue. An apply process can dequeue messages implicitly. A user, application, or messaging client can dequeue messages explicitly. The database where messages are consumed is called the destination database. In some configurations, the source database and the destination database can be the same.

Message Types:

Raw Bytes
Oracle Objects
XML