Monday, December 29, 2008

OOPS-(C# OOPS,Concepts,Scenarios,Tips and Tricks)

Hi Friends ,We all know that OOP's is the buzz word in the programming environment and we use these concepts in our everyday developments to get flexibility,robustness,scalability.Now a days when we go for any interview that may be C++,.Net,C#,java or SAP,the first questions they ask is OOP's because of its frequent use and importance in real time.So I am bringing you this article that demonstrates the conceptual knowledge and use case scenarios on oops.Whatever the concepts i am covering here is beyond the basic level by thinking that you are familiar with basics .Here I am explaining all the concepts based on C#,same thing applies to other languages with little bit syntax difference .Fun concepts starts from here.........................

What is OOP's:

  • OOP is the common abbreviation for Object-Oriented Programming.
  • It is the new concept of programming ,parallel to Procedure oriented programming.It were intorduced in late 80's.It consider the programming simulated to real world objects.It help in programming approach in order to built robust,user friendly and efficient softwares and provide the efficient way to maintain real world softwares

Why OOP's:

  • OOP become a popular since it provide a better programming style, you don't need to write code which you really need to run anytime you need (such as in structured programming and assembler), you just make a class of object and you may call/instantiate the class and use it from any part of your application, it is reusable.
  • compiler provide a library of those class, and you just use it, no need to write the codes. Your application mostly concern on managing the interaction among object, not write a command for any specific jobs.
  • OOP provide Inheritances model, so your application can inherit another class which is having similarity on behavior such as the variables and its methods, but you just write the distinct behaviour for your own implementation
  • OOP provide encapsulation model, once you instantiate an object, it's behavior to do their own job will not interupt another object, you dont bother if your code will affect another object.
  • OOP provide polymorphism, here you may call any methods in run time which is depend on particular command you provide, but still using the same method implementations.
  • OOP provide modularity mobel once you change part of code which is in separate module, it will not impact any module developed in application

Class and Objects:

  • Everything in our world is considered to be an object. For example, people are objects, animals are objects too, minerals are objects; everything in the world is an object. Easy, But what about classes?
  • In our world we have to differentiate between objects that we are living with. So we must understand that there are classifications (this is how they get the name and the concepts of the Class) for all of those objects. For example, I'm an object, sunil is object too, lakshmi is another object. So we are from a people class (or type).
  • I have a dog called Puppy so it's an object. My friend's dog, Snoopy, is also an object so they are from a Dogs class (or type).
  • A third example: I have a Pentium 3; this is an object. My friend has a Pentium 4, so this is another object and they are from a Computers class (or type). Makes sense right...
  • Class features can be used only after creating object called instance Types.

Classes and Objects Behaviour:

1)Static Behaviour :Static classes can be used when there is no data or behavior in the class that depends on object identity.

  • Example:Consider you have a company .Assume that there are 10 employees in that company.Here we could declare company class as static ,because company it self as an independent entity and it is common for all 10 employees.So you dont require to assign different company names for each employee.
  • When you consider employee class its not good to declare static as values will keep changing for each employee like name, sal,age etc..
  • Static classes will always have a common memory where as normal classes are not
  • Its not possible to inherit static classes .If you try it will throw compilation error
  • Only static members are allowed in static classes
  • Its not possible to create objects to static classes.Can be accessed via class name
  • when you declare static variables in normal class ,those cant be accessed from object but can be inherited.
  • Its not possible to declare interface as static

2)Constructor :

  • It is also a method with out return type
  • It gets invoked while creating object
  • Private Constructor:
  • A private constructor is a special instance constructor.
  • It is commonly used in classes that contain static members only. If a class has one or more private constructors and no public constructors, then other classes (except nested classes) are not allowed to create instances of this class
  • Private constructors are used to prevent the creation of instances of a class when there are no instance fields or methods, such as the Math class, or when a method is called to obtain an instance of a class. If all the methods in the class are static, consider making the entire class static.

Example : public class Counter

{

private Counter() { }

public static int currentCount;

public static int IncrementCount() { return ++currentCount; }

}

  • Static Constructor:
  • A static constructor is used to initialize any static data, or to perform a particular action that needs performed once only. It is called automatically before the first instance is created or any static members are referenced.
  • A static constructor does not take access modifiers or have parameters.
  • A static constructor is called automatically to initialize the class before the first instance is created or any static members are referenced.
  • A static constructor cannot be called directly.
  • The user has no control on when the static constructor is executed in the program.
  • A typical use of static constructors is when the class is using a log file and the constructor is used to write entries to this file.
  • Static constructors are also useful when creating wrapper classes for unmanaged code, when the constructor can call the LoadLibrary method.

Abstract Behaviour:

Scenario's:

  • abstract class:In most cases, using an abstract class is the "right" thing to do if you're trying to create a common class from which others will derive and which isn't fully specified.
  • Use abstract class when you want to provide some functionality to the user and at the same time would like to enforce some skeleton (structure) for the users of your class
  • Interfaces: are nice if you don't want to force classes to have a single root class in their hierarchy, as a single class can implement multiple interfaces.
  • Interfaces are used to define a skeleton. Classes who want to confirm to that skeleton implementsts the interface
  • Concrete classes should be used if it's fully specified--i.e. subclasses don't have any hooks into which they must provide functionality.
  • Concrete class - Use a concrete class to represent an object (data & methods) which can be extended or reused.



Sunday, December 28, 2008

RFID-Radio-frequency identification(RFID Technology Description,RFID and .Net Integration )

Radio-frequency identification (RFID) :is an automatic identification method, relying on storing and remotely retrieving data using devices called RFID tags or transponders.

  • Main Components: RFID reader, RFID tag
  • RFID tag:
  • is an object that can be applied to or incorporated into a product, animal, or person for the purpose of identification and tracking using radio waves. Some tags can be read from several meters away and beyond the line of sight of the reader.
  • Most RFID tags contain at least two parts. One is an integrated circuit for storing and processing information, modulating and demodulating a radio-frequency (RF) signal, and other specialized functions. The second is an antenna for receiving and transmitting the signal.
  • Types of RFID tags: active RFID tags, which contain a battery, passive RFID tags, which have no battery.
  • RFID Reader:
  • A device used to communicate with RFID tags.
  • It has one or more antennas, which emit radio waves and receive signals back from the tag.
  • It is also sometimes called an interrogator because it "interrogates" the tag.
  • It is An electronic device used for communication between RFID tags and a host computer system.
  • A reader generally consists of an RF transmitter and receiver and an antenna for communicating with tags. A digital interface enables the reader to communicate with the host computer system.
  • Reading distance :
    The distance between the antenna of a reader and a tag over which the read function can be effectively performed. This distance is influenced by the orientation and angle of the tag with respect to the antenna, and possibly by environmental conditions.

RFID-Real Time Applications:

  • Supply chain automation - the key early driver for developments and implementation of the technology
  • Asset tracking - tracking of assets in offices, labs, warehouses, pallets and containers in the supply chain, books in libraries Medical applications - linking a patient with key drugs, personnel giving the drugs, biometric measurements
  • People tracking - security tracking for entrance management or security, contact management at events, baby tags in hospitals to manage access to post-natal wards
  • Manufacturing - tracking of parts during manufacture, tracking of assembled items Retail - tracking store trolleys in supermarkets, active shelves
  • Warehouses - Real-time inventory by automated registration of items in a warehouse or store-room
  • Livestock - implanted RFID tags in animals for tracking and linking the animal to food, location. Applicable to farming as well as exotic breeds in zoos
  • Timing - sports event timing to track athletes as they start a race and pass the finish line

How does an RFID system work:

  • An RFID system consists of a tag made up of a microchip with an antenna, and an interrogator or reader with an antenna.
  • The reader sends out electromagnetic waves. The tag antenna is tuned to receive these waves.
  • A passive RFID tag draws power from the field created by the reader and uses it to power the microchip's circuits.
  • The chip then modulates the waves that the tag sends back to the reader, which converts the new waves into digital data.


Which frequency is right for your application?

  • Different frequencies have different characteristics that make them more useful for different applications.
  • For instance, low-frequency tags use less power and are better able to penetrate non-metallic substances. They are ideal for scanning objects with high-water content, such as fruit, but their read range is limited to less than a foot (0.33 meter).
  • High-frequency tags work better on objects made of metal and can work around goods with high water content. They have a maximum read range of about three feet (1 meter).
  • UHF frequencies typically offer better range and can transfer data faster than low- and high-frequencies. But they use more power and are less likely to pass through materials. And because they tend to be more "directed," they require a clear path between the tag and reader.
  • UHF tags might be better for scanning boxes of goods as they pass through a dock door into a warehouse. It is best to work with a knowledgeable consultant, integrator or vendor that can help you choose the right frequency for your application.

Standardized Frequency Bands:

  • low frequency (LF) : 125 to 134 kHz;
  • high frequency (HF) : 13.56 MHz;
  • ultrahigh frequency (UHF) : 860 to 960 MHz

RFID and .Net Integration:there are few API's which helps us to interact with RFID readers ,so that you can control the RFID devices functionality via .Net applications through these API's.Here i am using Phidgets application programming interface (API).

  • Phidgets :Phidgets are a set of "plug and play" building blocks for low cost USB sensing and control from your PC. All the USB complexity is taken care of by these API's. Applications can be developed quickly in .NET, Visual Basic, VBA (Microsoft Access and Excel), LabView, Java, Delphi, C, C++ and Python.Via (http://www.phidgets.com/)
  • Implementation :create new windows application.Install the Phidget API Dll in your system.Reference the dll in C# application.
  • NameSpaces:using Phidgets;using Phidgets.Events;
  • RFID : This object will be assigned to the RFID reader so that we can pull information from it.
  • To use the RFID reader, you will need to create an RFID object and then open the reader. You also will want to create a few event handlers to control actions that occur from the reader
  • The first thing that happens is that an RFID object is created called rfid1. This will be used to attach to the RFID hardware. Before opening the hardware for use, event handlers are created for attaching to the RFID reader (myRFID_Attach), detaching from the reader (myRFID_Detach), having a tag put near the reader (myRFID_Tag), and having a tag move out of the reader's range (myRFID_TagLost). After adding these handlers to the rfid1 object, the open method is called to begin using the RFID object
  • To use the RFID reader, in addition to being connected to your machine, it also has to be turned on
  • Turning on the reader is simply setting the Antenna property of your RFID object to true
  • myRFID.Antenna =true
  • The next important thing is to read a tag. This is done in the myRFID_Tag event handler that was added to the rfid1 object in the Form_Load event

Sample Code:

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing; using System.Text;

using System.Windows.Forms; using Phidgets; // Import Name Spaces

using Phidgets.Events;

namespace RFIDTest

{

public partial class MyRFIDReader : Form

{

RFID myRFID; // Declare RFID Object

string lastTag; // Tag that just read

public RFIDReader()

{

InitializeComponent();

lastTag = "";

}

private void Form1_Load(object sender, EventArgs e)

{

myRFID= new RFID();

myRFID.Attach += new AttachEventHandler(myRFID_Attach);

myRFID.Detach += new DetachEventHandler(myRFID_Detach);

myRFID.RFIDTag += new TagEventHandler(myRFID_Tag);

myRFID.RFIDTagLost += new TagEventHandler(myRFID_TagLost);

myRFID.open();

}
// Reading Tag

private void myRFID_Tag(object sender, TagEventArgs e)

{

lastTag= e.Tag;

myRFID.LED = true; // on light

}
// When tags over

void myRFID_TagLost(object sender, TagEventArgs e)

{

txtTag.Text =

myRFID.LED = false;

}
// Detaching Reader

private void myRFID_Detach(object sender, DetachEventArgs e)

{

lblAttach.Text = "Detached";

}
// Attaching Reader to application

Private void myRFID_Attach(object sender, AttachEventArgs e)

{

Phidgets.RFID phidTag = (Phidgets.RFID)sender;

lblAttach.Text = phidTag.Name;

lblSeriaNumberl.Text = phidTag.SerialNumber;

lblVersionNumber.Text = phidTag.Version;

}
// Turn On The Reader

private void antennaButton_Click ( object sender, EventArgs e)

{

myRFID.Antenna = True;

}

}

}

Is RFID better than using bar codes:The two are different technologies and have different applications, which sometimes overlap. The big difference between the two is bar codes are line-of-sight technology. That is, a scanner has to "see" the bar code to read it, which means people usually have to orient the bar code toward a scanner for it to be read. Radio frequency identification, by contrast, doesn't require line of sight. RFID tags can be read as long as they are within range of a reader. Bar codes have other shortcomings as well. If a label is ripped or soiled or has fallen off, there is no way to scan the item, and standard bar codes identify only the manufacturer and product, not the unique item. The bar code on one milk carton is the same as every other, making it impossible to identify which one might pass its expiration date first.

Well-timed acquisitions

In a fast deteriorating economic environment India’s IT majors appear to be looking beyond the immediate crisis plaguing the global economy.
While others are holding on to whatever cash they have, the likes of TCS, Wipro and HCL are using their stockpile to make strategic acquisitions to strengthen their business.
Wipro has acquired Citi Technology Services, Citigroup’s IT arm in India, in an all cash $127 million deal. Last week, HCL Tech had closed the acquisition of UK-based Axon Group for $658 million. And earlier TCS had bought out Citi’s captive BPO arm Citigroup Global Services for about $505 million.

These acquisitions have come at a time when the consensus is that the Indian IT industry is entering a difficult phase. IT budgets are usually the first to be slashed when companies need to cut costs. This is likely to be particularly severe in the case of the crisis hit banking sector, with serious implications for the Indian IT sector.
A significant chunk of the Indian IT industry’s revenues comes from the Banking and Financial Services (BFS) vertical. One can argue that the cost cutting could conceivably lead to outsourcing of more work to the cheaper offshore centres such as India. That possibility is, however, clouded somewhat by the virtual nationalisation of many financial institutions.

Source: The Economic Times

Wednesday, December 24, 2008

SAP .NET Connector

Purpose:
The SAP .NET Connector is a development environment that enables communication between the Microsoft. NET platform and SAP systems.

This connector supports RFCs and Web services, and allows you to write different applications such as Web form, Windows form, or console applications in the Microsoft Visual Studio.Net. With the SAP .NET Connector, you can use all common programming languages, such as Visual Basic. NET, C#, or Managed C++.

Features:
Using the SAP .NET Connector and SAP .NET Proxy Wizard, you can:
· Write .NET Windows and Web form applications that have access to SAP business objects (BAPIs).
· Develop client applications for the SAP Server. Here you can use either RFCs or HTTP/SOAP/XML (outside-in).
· Write RFC server applications that run in a .NET environment and can be installed starting from the SAP system (inside-out).

With Microsoft Visual Studio .NET you can:
· Use the integrated Proxy Wizard to generate proxy objects.
· Use any common programming language that has complete access to Microsoft Visual Studio .NET.
· Link SAP tables and structure with Windows and Web form controls (Data Binding).
· Use secure authorization methods such as Single Sign-On, Kerberos, and Microsoft Passport (http://www.passport.net/).


Via : http://help.sap.com/

SAP Enterprise Services Explorer for Microsoft .NET

SAP – Microsoft interoperability Made Easier:
As part of its Enterprise Service-Oriented Architecture (ESOA) offering, SAP provides a set of consumer tools that allow discovering and consuming enterprise services from various development environments, such as NetWeaver Developer Studio, Visual Composer and Microsoft Visual Studio. SAP Enterprise Services Explorer tool for Microsoft .NET (ES Explorer for .NET) is an add-in for Microsoft Visual Studio 2005 that helps to leverage SAP ESOA by enabling .NET developers to discover SAP enterprise services and consume them in their applications. It is an important element of SAP – Microsoft interoperability. For more information please read the article Introducing SAP Enterprise Services Explorer tool for Microsoft .NET.
VIA:https://www.sdn.sap.com

Microsoft SQL Server Migration Pays Big Dividends for SAP/ERP Customers

Migrating an SAP/ERP environment to Microsoft SQL Server can reduce unplanned downtime by over 20%, cut IT labor costs by nearly 25%, and cut ongoing software support costs up to 85%. Migration from competitive databases is made easy by tools, best practices, and certified SAP migration specialists. Payback is as short as nine months, with ongoing annual savings of 30%-37% possible.
Read the full White Paper
Via http://www.microsoft.com/isv/sap/