Windows Live

Well as the name suggests it is not an online version of Microsoft’s venerable operating system. It is a kind of new type of web-based Microsoft Live Communication Server or you can say an enhancement of the services developed by MSN.
 
Windows Live consists of eight so Web-based services  designed for customers. It consists of services like mail, online-messenger, online folder sharing, Internet telephony etc.
 
The most striking examples of Windows Live is ways of of tying it with desktop. People could share files-folders with the instant-messaging buddies and use the ww.Live.com page to view not only the Web-contents but also the things like recently opened documents or corporate SharePoint portal.
 
Live.com and Gadgets
 
Although customizing Live.com is not as easy as it should be due to skills and steps required to add cutom gadgets to it but the personalization features offered btu it are far more than that of Yahoo or even Google. Imagine you can use same point to view your corporate portal from home, access files from your office PC  in another country or even check mails, send messages to your buddies and share file-folders with them. All from same point.
 
Microsoft has promised to ensure that adding gadgets will be as easy as dragging and dropping a link on a site but at the moment it is not as easy. People have to go to microsoftgadgets.com, copy a special URL, then go back to Live.com and follow a series of "advanced options".
 
Gadgets has an important place in Windows Vista and Windows Live as Microsoft plans to use them thorughout them with no difference. The same gadget can also be used in Windows Vista. Microsoft also plans to use gadgets to retrieve locally stored information from PC to Live.com Web-page.
 
Gadgets are actually small applications like Web-parts but they mainly consist of XML-based manifest file, JavaScript (containing entry point) and CSS file. Live.com uses Atlas framework to extend JavaScript functionality.
 
Live.com is designed to take things one step further. It allows people not only to view Web contents and personalize them but also to save search queries as well as data from their PCs.
 
Windows Live Mail
 
Windows Live mail is an  extension of hotmail codenames KAHUNA. It provides a new style of interface, a more desktop like mail software, with features including automatic inbox refreshing, spell-checking, phishsing detection and a preview pane that will enable hotmail users to read and respond to thier e-mails without ever leaving their inboxes. Its interface in known internally as  "WAVE 11" and it is designed to be lightweight and clean for better performance. It provides preview to your e-mail without loading a new page each time (like Outlook®) drag and drop messages into folders, and generally power through your e-mail in a flash.
 
Windows Live Spaces
 
Windows Live Spaces is a transition of MSN spaces with some added functionality.
 
Windows Live Messenger
 
Some of the biggest new thing that Microsoft has introduced in Windows Live is Windows Live Messenger. The new messenger has additional features like social networking, Internet telephony, folder sharing etc. Folder sharing is really a fantastic idea. You just have to drop a file on top of a contact which will allow you to create a shared folder. This folder will exist on both members’ desktop and stay up-to-date with any changes to the shared file.
 
Windows OneCore Live
 
It is a security system that helps you protect your system. It includes features like virus scanning, firewall settings, software backups and tune ups.
 
Windows Live Search
 
It includes elements of Microsoft’s Virtual Earth mapping. It allows members or their buddies to creat annotations, creating a personalized map of their favorite spots in the city, even from your mobile, plus you can see detailed maps, driving directions and more.
 

Web Site Counter

 

Lazy Instantiation and the Singleton Pattern

Lazy Instantiation:
 
Lazy Instantiation lets the creation of objects be put off until they are actually needed i.e. they are created on need. Then what is its relation with singleton pattern. This is actuall what it is required in singleton pattern. Here I want to point out one more thing that lazy instantiation is closely related with the static members. The .Net compiler deals with the static members in the same way. They are created when any member (static or instance) member of the class is first referenced in the Application Domain and remain alived until the AppDomain exists but I think the big plus of using static members is that they are thread-safe and optimized by the constructor of .Net.
 
Usually we implement singleton-pattern using the following code:
 
public sealed class Singleton
{
    static Singleton instance=null;

    Singleton()
    {
    }

    public static Singleton Instance
    {
        get
        {
            if (instance==null)
            {
                instance = new Singleton();
            }
            return instance;
        }
    }
}

 
but the above code is not thread-safe as two threads can simultaneously check the status of instance variable and both can enter into critical section. Another way of doing this is to use locking like :
 
public sealed class Singleton
{
    static Singleton instance=null;

    Singleton()
    {
    }

    public static Singleton Instance
    {
        get
        {
            lock (instance)
            {
                if (instance==null)
                {
                    instance = new Singleton();
                }
                return
instance;
                            }
                   }
          }
}

but it will cause performace loss as at one time only one thread can be in critical section and having instance check outside the critical section will cause the same problem. A simple solution of the above problem is to declare and define the static instance of the object at the same time like:
 
public sealed class Singleton
{
    static readonly Singleton instance=new Singleton();

    // Explicit static constructor to tell C# compiler not to mark type as beforefieldinit
    static Singleton()
    {
    }

    Singleton()
    {
    }

    public static Singleton Instance

    {
        get
        {
            return
instance;
                   }
        }
}
Now here a question arises. Why I have used static constructor when nothing is done in it? Well the secret of using it is the laziness of type initializers is only guaranteed by .NET when the type isn’t marked with a special flag called beforefieldinit Unfortunately, the C# compiler (as provided in the .NET 1.1 runtime, at least) marks all types which don’t have  a static constructor (i.e. a block which looks like a constructor but is marked static) as beforefieldinit. So to use static members in place of lazy instantiation, the class must have static constructor, otherwise ins laziness is not guaranteed.
 
Another thing, if the class has another static member, in that case also the laziness of the class is not guaranteed.

Technical Interview Questions-Part 3

Is it possible to have a private constructor?
Yes, it is possible if you want to prevent its instantiation or if you want to have a singleton class.
 
What is the purpose of singleton pattern?
To manage accesses to a shared resource.
 
Is it possible that we can inherit singleton class?
A singleton class cannot be inherited i.e. a class having its ocnstructors private including the default constructor cannot be inherited. It will generate a compile time error.
 
Can we implement inheritence (polymorphism) using delegates?
Yes we can implement polymorphism using delegates i.e. inheritance. A delegate can be attached to any function having same signature.
 
Can we use delegates in place of inheritence (polymorphism)?
Nops, we cannot do this as delegates can be attached to any function having same signature but in case of inheritance only methods of the same class or its parent class can be called.
 
Which is faster, stored procedures or embedded SQL?
Stored procedures as they are pre-compiled, optimized and stored with the database. On the other hand embeded SQL is compiled every-time when it is executed.

Technical Interview Questions-Part 3

What is the difference between Method Hiding and Shadowing?
Well there is no difference in these concepts.They are just 2 sides of the same coin, 2 names of the same term but in different technologies. Method hiding is the concept of C# whereas method shadowing is the concept of VB.Net. Method Hiding and Shadowing are the concepts by which you can provide a new implementation for the base class member without overriding the  member. It is similar to method overriding but only in this case you are hiding and shadowing the definition of the parent class. For both these concepts same rules apply as in case of Method overrding i.e. the signature of the method must be same.
 
Now what is the difference between Method hiding and Shadowing with Method overloading. Hmm, it is simple. The difference lies when you call the derived class object with a base class variable.In class of overriding although you assign a  derived class object to base class variable it will call the derived class function. In case of shadowing or hiding the base class function  will be called.
 
To shadow a member of the parent in child class, use Shadow keyword in VB.Net and to hide a member of the parent class in child, use new keyword in C#.
 
The following is the code snippent, showing these concepts:
 
Method Shadowing:
 
Public Class BaseShadow

    Public Overridable Function OverrideMe() As String
        Return "Base Class Override Me"
    End Function

    Public Function ShadowMe() As String
        Return "Base Class Shadow Me"
    End Function

End Class

Public Class DerivedShadow
    Inherits BaseShadow

    Public Overrides Function OverrideMe() As String
        Return "Derived Class Override Me"
    End Function

    Public Shadows Function ShadowMe() As String
        Return "Derived Class Shadow Me"
    End Function

End Class

Method Hiding:

 
public class BaseHide
        {
                public BaseHide()
                {

                }

                public virtual string OverrideMe()
                {
                        return "Base Class Override Me";
                }

                public string HideMe()
                {
                        return "Base Class Hide Me";
                }

        }

        public class DerivedHide:BaseHide
        {
                public DerivedHide()
                {

                }
                public override string OverrideMe()
                {
                        return "Derived Class Override Me";
                }

                public new string HideMe()
                {
                        return "Derived Class Hide Me";
                }

        }

Technical Interview Questions – Part 2

Can you have two applications on the same machine one which is using .NET Framework 1.0  and the other using  1.1 ?
Yes
 
If you are using a web service and you want its path to be picked up from the config file what will you do ?
Set its behaviour property to dynamic this will add a new appSetting entry in the config file for the webservice path.
 
Can I serialize Hash table with XmlSerializer?
XmlSerializer will refuse to serialize instances of any class that implements IDictionary, e.g. Hash table. Soap Formatter and Binary  Formatter do not have this restriction.
 
Whether ADO.Net provides conneted recordset like ADO or dis-connected?
ADO.Net provides both types of recordsets. A connected recordset is called data-reader but using data-reader we cannot modify database using it. It is useful for small number of data-records as it is very fast but useless for large number of records as it will keep the connection with tha data-base for a long number of time. We can extract records from multiple tables i.e. multiple record-sets in the same data-reader.

 

A dis-connected record-set is called a DataSet. It is a complete mirror of data-base i.e. we even can keep relationships in it. A data-set can contain multiple tables with relationships among them. User can write the contents of the dataset in an XML file without any effort. A data-set can also be used to move data from one database to another.

 

What does ‘managed’ mean in the .NET context?
The term ‘managed’ is the cause of much confusion. It is used in various places within .NET, meaning slightly different things.
Managed code: The .NET framework provides several core run-time services to the programs that run within it – for example exception handling and security. For these services to work, the code must provide a minimum level of information to the runtime. Such code is called managed code. All C# and Visual Basic.NET code is managed by default. VS7 C++ code is not managed by default, but the compiler can produce managed code by specifying a command-line switch (/com+).
Managed data: This is data that is allocated and de-allocated by the .NET runtime’s garbage collector. C# and VB.NET data is always managed. VS7 C++ data is unmanaged by default, even when using the /com+ switch, but it can be marked as managed using the __gc keyword.
Managed classes: This is usually referred to in the context of Managed Extensions (ME) for C++. When using ME C++, a class can be marked with the __gc keyword. As the name suggests, this means that the memory for instances of the class is managed by the garbage collector, but it also means more than that. The class becomes a fully paid-up member of the .NET community with the benefits and restrictions that brings. An example of a benefit is proper interop with classes written in other languages – for example, a managed C++ class can inherit from a VB class. An example of a restriction is that a managed class can only inherit from one base class.

What is reflection?
All .NET compilers produce metadata about the types defined in the modules they produce. This metadata is packaged along with the module (modules in turn are packaged together in assemblies), and can be accessed by a mechanism called reflection. The System.Reflection namespace contains classes that can be used to interrogate the types for a module/assembly.
Using reflection to access .NET metadata is very similar to using ITypeLib/ITypeInfo to access type library data in COM, and it is used for similar purposes – e.g. determining data type, their sizes for marshaling data across context/process/machine boundaries.
Reflection can also be used to dynamically invoke methods (see System.Type.InvokeMember), or even create types dynamically at run-time (see System.Reflection.Emit.TypeBuilder). Reflection can also be used for late-binding,r producing generic methods or mosly for dynamically generating classes and modules. Remarkable, isnt it

 

Technical Interview Questions

What is a diff between an abstract class and an interface ? What would govern your decision for its usage in .NET?
Well I have seen many people get confused in this question and telling differences as:
 
1 — An abstract class is a class which cannot be instantiated and an interface is a set of functions. Thier usage would be goverened by  the follwoing reasons :-
a. If I have some common functions to be implemeted in the base class then one should  use abstract class as Interface cannot have  funcation implementations.
b. Languages like C# and VB.NET only allow single inheritance of classes hence you have only one base class and rest will have to  be created as interfaces.
e.g. If I did my class A to inherit from Class B and Class C .. then inheritance can only be done from one of these classes the one will  have to created as an interface.
c. Interfaces cannot have state information i.e. they cannot contain variables but can contain constants. On the other hand, an abstract class can contain both variables and constants.
 
All these answers are right but one has missed the key answer. A child class implements interface but extends abstract class.
 
What it actually means is that an interface is a contract between 2 or more classes i.e. it defines mutual agreement between 2 or more parties like interfaces exposed for COM objects.
 
On the other hand an abstract class defines a relationship with its child class not the contractual relationship but inheritance. It is a IS-A  relationship between abstract class and child class.
 
So if you want to implement generalization/specialization i.e. HAS-A relationship then use abstract class but if you want to provide a common interface or contract between 2 or more parties so that service-consumer class only needs to know the services of  its service-provider class not their implementation use Interfaces. 

Using Flash for GUI in .Net

Sometimes before we faced a problem where we want to enrich the GUI of our project and we decided to use Flash for this purpose. But how can we do this. Thanx to Mr.Adnan Farooqi we were able to achieve this. So  I am blogging a step by step procedure to achieve this.
 
Its even easier than consuming a web service any other way. This is because Flash provides a way to bind values returned by a web service to Flash Components. No coding is required; only a couple of clicks and drags, thats it! This is a great way to develop Flash tickers to display data (possibly Stock Quotes, Currency Exchange Rates, etc.) on a web page without ever needing to refresh it for updated data. So, how to go about doing this? Very simple.

1) Create a Web Service
Create a simple "Hello World" Web Service; one that simply returns the string "Hello World" when invoked. If you develop the Service using Visual Studio .NET, the code for "Hello World" is generated automatically. Run and test the Web Service in your web browser. Copy the URL for your Web Service Description or WSDL document i.e. if the URL for your web service is "http://localhost/FlashRemoting/HelloWorld.asmx", then you can access its service description at "http://localhost/FlashRemoting/HelloWorld.asmx?WSDL".

Run Macromedia Flash MX 2004 Professional, and create a new Flash document.

2) Link the Flash Movie to the Web Service
Open the "Web Services" panel by going to Window > Development Panels > Web Services. Click the globe icon on the panel; a small window will appear. Click the "+" Add button on the window, and enter the URL you copied for the WSDL document in step 1. (This will not work if you simply enter the URL for your web service; it MUST be the URL for the WSDL document). When you click the OK button, you will see that the Web Service has been added to the list in the Web Services panel. Expand the "[Your Web Service Name]" Node in the panel and right-click the method you want to call. From the pop-up menu, click "Add Method Call". (An instance of the Web Service Connector component would be added to the stage).

3) Place Flash UI Components on the stage
Go to Window > Development Panels > Components, and drag a "Label" and "Button" control on to the main Flash movie stage.

4) Name all the Component Instances on the stage
Name all 3 component instances on the stage, the Label, the Button, and the WebServiceConnector component from the "Properties" panel.

5) Bind Web Service Result to the UI Component
In order to display the string returned from the web service, you need to bind the result to the Label component you placed on the stage. Go to Window > Development Panels > Component Inspector. Select the Label component on the stage and go to the "Bindings" tab on the "Component Inspector" window. Click the "+" Add Binding button. Select "text : String" from the list and click the OK button. Now that you have specified the UI component property to bind to, you now need to specify the Data Source that would provide the value to display in the Label component. Select the "bound to" item in the Key-Value list on the "Bindings" tab, and then click the Magnifying Glass icon (The "Bound To" window will appear). From the "Component Path" list on the left, select the "WebServiceConnector <[Your Web Service Name]>" node, select "result : String" from the "Schema Location" list on the right, and click the OK button.

6) Add Behavior to Invoke/Trigger the Web Service
To invoke the web service, you need to add a behavior to the button. Go to Window > Development Panels > Behaviors. Select the Button component on the stage and on the "Behaviors" panel, click the "+" Add Behavior button. On the context menu, go to Data > Trigger Data Source (The "Trigger Data Source" window will appear). Select the "[Your Web Service Name]" node and click the OK button.

7) Run the Flash Movie
Press Ctrl+Enter to compile and run the Flash movie. When you click the button, the web service will be invoked and the returned text will appear in the Label component.

What is the Purpose of our Lives – 2nd

Well my friend Mujtaba is absolutely right. Why we have started all this social, economical and cultural circle? To fulfil our necessiities so that we can fulfil purpose of our lives i.e. to make God happy. A true religion is the one that will guide us in all aspects of life. So religions also governs socio-economic systems of the societies and we should perform these duties in such a way that we will remembered after-on in this world but what about the world where we will be taken after our death? Well my friends we should also prepare ourselves for this world  and this cannot be accomplished by performing only our socio-economic duties honestly and efficiently but also fulfilling the foremost purpose of not our lives but the purpose of all the creations in this world i.e. to get the happiness of God.
 
In short a true religion teaches us both socio-economic code of life and ways to fulfil our duties towards our God i.e. in Arabi Haqooq-ul-Allah and Haqooq-ul-Ibad.

MSN decides to jump into Net-calling future

Well now after Google Microsoft has also decided to come into Net-calling business. One of its demonstrations was given by Microsoft on the .Net 2005 launch ceremony. In Windows Live messaging service it is as easy to make a call to a friend as sending a text messaeg. It seemed to be a shot across the bow of companies like Skype and Vonage, which provides voice over IP.
 
The move comes as all the major portal and IM companies are moving more heavily into Internet calling. This move comes after the launch of Googles IM Google Talk, which focus on voice chatting. But Microsoft further added that it will be paid service even in its beta state.