Saturday, September 15, 2012

Telerik TV - Win 7 Phone App

Telerik TV is a Win 7 mobile App uses Telerik Odata and fetches some of the information which the user may be interested.

The following are the features on this App

  •  View Authors and his blog Information
  •  View Channel Information
  •  View Video Information

The App shows the panoramic view of Authors, Channel and Video Information. The panoramic view is made with an intention of easy navigation across various related information.

Author Info is shown with the Author Name, Author Photo if they have and the Blog link. The user can view the blog information by just clicking on the link which will open in a Web browser integrated with in the application.


The Channel information shows the Name, Url and Description information

The Video information shows the Name, Url and Description information. The user can click on the link that will navigate to telerik page. 

Telerik uploads view to viddler and uses render them in their web page using Adobe Flash. As of today there is no Flash support for Win 7 so you can’t view watch Telerik videos.

Saturday, May 26, 2012

WCF Service Vs Windows Service

This article is all about understanding WCF and Windows service. We will first try to understand what it is at high level and then dig in more.

WCF Service

WCF is meant for designing and deploying distributed applications and it’s a framework for building service-oriented applications.

What is SOA?

A service-oriented architecture is a collection of services. These services communicate with each other. The communication can involve either simple data passing or it could involve two or more services coordinating each other to do some activity.

SOA is a buzz word also it is a misconception that when it comes to SOA, we have to create and consume WCF services.Some architects mistakenly assumes and considers WCF as default. However in theory point of view it doesn’t really matter how it’s being implemented. WCF just provides a means for developing distributed services.

We all started working with Web services before WCF came into picture. Web services by itself is service oriented implementation. Guys we already we aware of what are SOA.

Simply stating for SOA, the most basic components would be a service user and a service provider that’s all. As I already mentioned about WCF, its Microsoft’s implementation of service oriented architecture.

What is a Service?

In simple words, a service is the work performed by one that serves or helps.

A service is a reusable component that can be used as a building block to form larger, more complex business-application functionality.

Services are independent. They don’t know or really care whether the service is:
– Running on Windows, J2EE or a Mainframe
– Written in assembler, C, Java, or COBOL.
– Being served by a CRM system, a DDA system, or a database

Don’t think service as just one big massive thing. The services can be broken into compound and granular services.

Why do we need an SOA?

The systems that we build and use today are much complex ones. That doesn’t mean the older systems are not much complex. From my own personal experience, When I was working for Healthcare clearing house , there were products which were built with technology like Foxpro , VB, .NET components (these are legacy systems for now that’s a different story) which are still running since from nearly 20 yrs.

The Object Oriented (OO) solved the problem for medium sized systems or applications. The component orientation solved the problem that a simple objected oriented could not do in a medium sized products or applications. With large systems, neither of this could solve the problem.

When is SOA good and Bad?

Good when you are building a large system or systems of systems or planning for distributed systems then it’s good to go.

It’s bad when there are no distributed systems. It may not be feasible for small or medium sized systems.

Windows Service

Windows service is generally used when an application needs to run continuously in the background without any human intervention. The main functions of a windows service is to run in the background.

We can set the windows service to start automatically when the machine boots and also we can manually stop and re-start later if required.

In simple, these services are developed when we want everything to be done and in a same machine. In contrast to WCF services these services are not distributed in nature. We can have multiple services where in each one can perform some activities.  But as such windows services won’t provide any service to consumers. I mean in general we use windows service to do something autonomously without any other external applications interacting with it. However we can host a WCF service with in a windows service and make the WCF services available to consume within in an intranet environment.

Consider an example where in you can make use of this. You have developed an application which pushes some messages (Say Windows MSMQ or a Service broker queue). In such cases you can go with a simple windows service which runs in the background continuously monitoring the queue for the incoming messages. Once you have the message, we can simply process the same.

Monday, May 7, 2012

Behavioral Driven Development (Part 1)

Behavioral driven development is all about documenting or producing the executable specification. We think in terms of various scenario’s or steps and write unit tests to verify the behavior of objects under test.

BDD is said to be superset of TDD. If you are aware of the TDD process where in we write the failing unit tests, then write the production code; verify the test to make it pass. Refactor code and verify the tests. 

One thing I would like to tell the reader is BDD is not just about unit testing. It’s about how you drive your tests with various behaviors. One has to think and come up with various scenarios for a use-case then start writing acceptance test for the same.

TDD Technique

With BDD, we are writing a feature tests. What that means is write unit tests with the behavior in mind. We think about various scenarios and write unit tests to make it to pass.

BDD focuses on the Acceptance tests or executable specification. Think as an end user performing various steps to accomplish a particular use case/scenario. You can go with one Use case at a time and follow the acceptance tests to cover the same.

BDD Technique

The key difference what we can think of TDD and BDD is the focus on the initial design and creation of tests. With BDD we are focusing on the steps or features to achieve our goals rather than focusing on the just writing a passing test with TDD.

BDD is all about documenting the executable specification in terms on Unit tests which verifies the behavior of our system. There are many tools available for doing BDD. SpecFlow is one among the good tool that I personally suggest with which we can easily write acceptance tests describing the features.

Saturday, May 5, 2012

Introduction to Mocks and Stubs

Mock objects are simulated objects that mimic the behavior of real objects in controlled ways. We typically create mock objects to test the behavior of some other object.

A stub is a replacement for an existing dependency in the system. By using a stub, you can test your code without dealing with the dependency directly.

Consider a scenario where you need mocks and stubs

    You want to simulate the behavior of the dependent objects, say you wish to mock and test EmailSender. While testing such things we won’t be really connecting to Email server. In this scenario, we can simply mock and test the behavior of email sender and verify the expectations set against the mock object.

    Imagine you are testing a data access class which connects to DB fetches, inserts / updates some data. We can make use of mock and stub techniques to test the DAO logics without the database dependency.

Why Mocking?

If you are planning to isolate the dependencies of an object and unit test, then you will have to mock and test.

Here I'm considering an example of User object which has SendEmail method used to send an email with subject, body and email address.

public class User
    public FirstName { get; set; }
    public LastName { get; set; }
    public UserName { get; set;}
    public Password { get; set; }
    public Email { get; set; }       
    public User() { }
    public bool SendEmail(IEmailSender emailSender)  {
        string subject = "Your Password";
        string body = String.Format("{0} {1}, your password is {2}", FirstName,  LastName, Password);
        return emailSender.Send(subject, body, Email);

You will notice one thing here the User object depends on the instance of IEmailSender type to send mail for the specified user email address.

public interface IEmailSender
   bool Send(string subject, string body, string email);  

We will learn how we can mock the EmailSender and test the expected behavior.

The below example is making use of Moq Framework for mock and unit testing

public void User_Can_Send_Email()
        var emailMock = new Moq.Mock<IEmailSender>();
             .Expect(sender => sender.Send(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>()))
          User user = new User();
          Assert.That(user.SendEmail(emailMock.Object) == true);

The unit tests creates a mock object of type IEmailSender and sets the expectation for Send method with any arguments passed as a parameter to it should return ‘true’.

At the ends of the unit test, we did an assertion for the user.SendMail to verify for the true value. You can also add a .Verifiable() on the end of the mock setup code and then call emailMock.Verify() after you run your test code and verify that the method was actually called.

An Example for a Stubbed Class

public class StubbedSecurityDataStore : ISecurityDataStore
    public bool Authenticate(string userName, string password)
        return true;
    public string[] GetRoles(string userName)
       return new string[]{“Admin”, “Write”, “Read”};

About Moq Framework

Moq is an open source framework and has adopted an API that tries to be both simple to learn and easy to use. The API also follows the arrange-act-assert style and relies heavily on .NET 3.5 features, such as lambdas and extension methods. The learning curve is quite easy, but you need to feel comfortable with using lambdas. 

Difference between Mock and Stubs

Mock objects are used to define expectations i.e. we expect some methods to be called with such and such parameters. Mocks record and verify such expectations.

Stubs, on the other hand have a different purpose: they do not record or verify expectations, but rather allow us to provide “fake” objects in order to utilize a test scenario. Stubbing a method is all about replacing the method with code that returns a specified result. Most important thing is a stub will never cause a test to fail.

Sunday, February 12, 2012

Licensing a product with the help of Licenser


This article explains the importance of why licensing a product/application is important. Also explains how we can re-use open source License Manager Tools in our application.

Consider a scenario where in you have developed a small application for a customer. At first you may not be thinking about licensing part. You may have developed as a prototype or a proof of concept and deliver it to the customer. She/he may be happily using all the features that you have provided in your application. The customer may also install and use your application in more than one system.

Eventually as the product/ application features get enhanced, one has to think about how we can license a feature so that we can restrict the clients from being using that. Or you can think about selling your product based upon some features. This is where product or application licensing by features comes into picture and it is very much important for a product/ application developer or an organization.

We shall see how to license our applications with the help of one Open Source codeplex tool named Licenser which is located at

The Licenser package has the following things:

1. Licenser / Production – A license production tool

2. Licenser / API – An API for checking a license
3. Licenser / Identification – A tool that is used one-time by the end-user to display the computer id.
The first thing which is required for licensing is the client computer id. Ask your client to run LicenserIdentification.exe and send the computer id.

Creating a License File:

Once you receive the customer Id you are ready to go with generating a license for your client. Run LicenserProduction.exe , Click on File -> New

Fill in the customer details and save it.
Right click on the customer and click on New License

You need to fill in the following details and click on OK button to save the information
1.     Product name: Name of the product for which you want to license.
2.     License Type:
a.  Node Locked License: You are licensing based upon the computer Id.
b.  Demo license: Used for demo purpose and not in production.
3.     Password: The password with which you want to license you client. You can choose any password and send it across to your client. The client will make use of this while using the product. The LicenserAPI will validate based upon the License file, password and Feature name.
4.     Computer Ids: Computer Id of the client for which you want to generate a license.

Adding product features for licensing

In the Feature grid, key in the Feature Name. You have an option to make it either time dependent or not. If ‘IsTimeDependent’ is checked then you will have to provide the Expiration date.
Click on ‘Generate’ button to generate the License file. A Save dialog will be opened with a default file name. Just select the location where you wish to save the license file.

Test License

Now we will see how we can test the license by product feature from the LicenserProduction tool.

Under Customer -> Right click and select Test License. Below is the screen which pops up.

Testing the license file requires the following.

1.  Selecting the License file.
2.  Key in the password that you have chosen while generating the license for your customer.
3.  Enter the Feature name for which you want to test.

Click on ‘Test’ button to verify whether the LicenserAPI validates with the information which you have provided.

So now you got the license file, it has the list of features with which you can validate for a client to see if we can allow him to use a feature or not.                                                 

You will have to use this information in your application to validate the client and provide access to use only those features which are meant for him.

Behind the scene of a Licenser Tool:

The produced license file is digitally signed and it’s also specific for the licensed computer.
   In order to enhance security, the application has to pass to the licenser a PASSCODE during run-time.
   There are no restrictions for the number of features being licensed for the product.
  The feature information, as well as the licensed computer identification together with the PASSCODE is encrypted into a digital signature that is written in the license file. So any tampering done to the license file say by modifying the information within it will invalidate the license.

Thursday, February 9, 2012

Convert PowerPoint to HTML


A tool developed to convert PowerPoint to HTML. It was completely developed using .NET Framework 4.0 Winform Technology.

Consider a scenario, where you are preparing some presentation for a client. Assume the client may not be having a PowerPoint installed in his/her machine, he/she may wish to view the same PowerPoint presentation through static HTML pages.

This tool evolved from the above requirement. It takes PowerPoint as input and converts the same to static HTML pages.

Note: Surprisingly the MS PowerPoint did not provide an option to Save As HTML.

Features of this tool:

1.     Convert PowerPoint to HTML static pages.
2.     Save HTML folder path settings: Once the settings are saved by the user; the HTML folder settings will be read and displayed on the html folder path textbox for the subsequent use of the application.
3.     Minimize on System tray option: You can simply minimize the application if you are not currently using it. On minimize, the convertor will be on the system tray. You can notice a folder icon for this tool in system tray.

1.     Main screen

2.     Select a PowerPoint by clicking on the Open PowerPoint File button. Then type the HTML folder path.

3.     Click on the ‘Convert to HTML’ button to convert the Powerpoint presentation to HTML static pages.

4.     Folder settings

5.     About Us

Sunday, January 29, 2012

Remote System Monitoring and Controlling via Web based Mobile or Desktop Application


The idea of remote system monitoring and controlling application is to do some of the actions like ex: Shutdown, Reboot, Hibernate of the users systems remotely. The user can also make use of this application to query additional details of the systems.
Consider a scenario where you have a set of systems (Computers) and you want to control them from your mobile or any other desktop anywhere from the world. So this started as initial requirement of how we can implement the same to control numerous systems remotely.
Consider another scenario of how you can retrieve the information of a particular system remotely from your handheld devices or through desktops. By retrieving information, one may be interested in knowing the following

1.       Machine Name
2.       CPU information
3.       Username
4.       Domain Name
5.       OS Version

Software Requirements Specification

1.       Aim: The aim of this project is to provide a facility for the end user to remotely control their systems through desktop or mobile based web application.
2.       Purpose: The purpose of this project is to implement a proof or concept of the same. And to show how easily it can be done with .NET technology
3.       Scope: The scope of this project is very limited to controlling the system with few actions like Shutdown, Reboot, Hibernate, Logoff, Force close all applications etc. The user registration is done only at the client application and the it should be always running in-order to control the system remotely.

4.       User Characteristics:  The Following things are taken into consideration with this software development
a.       Users can have multiple systems for controlling. There is absolutely no limit in the number of systems being controlled by the users.
b.      The user can either control her/his systems through mobile or desktop based web application.
c.       Each user can control his/her system only and don’t have access to control others systems.
d.      Right now there is only one type of user of this system i.e. the System Administrators who will be using this system to control or fetch additional information of the system on their own interest.

Software and Hardware Requirement

Software Requirements:
·       Operating system: Microsoft Windows XP / Win 7 / Vista
·       .NET framework 4.0
·       SQL Server 2008

Hardware Requirements:
·       Processor Pentium 4
·       RAM- 256Mb
·       HDD-10GB

Technologies Used
·       Visual Studio.NET
    • The Client Application is developed with .NET C# Winform technology
    • The Server side web application is developed with ASP.NET MVC3 technology.

·       Internet based / Cloud based Microsoft SQL Server 2008
    • This software is designed with Software as a Service model with a common single cloud database which stores all the users and their system information.

How does the software functions?
Client Application:

When you run the client application for the first time, you will have to register yourself with the username and password. The same has to be provided as log on information which will authenticate the user in client and server applications.

Once authenticated, the user has to click on the Start button for continuous monitoring of the system behind the scene. The system registers by itself by putting an entry in database (this happens only for the first usage of the client app) so that the user can control that particular machine.  When the user closes the client application, the entry in the database for that system will be deactivated.  For subsequent usable of the client application, the system will be activated for monitoring and controlling.

Server Application:

It is a web based application, on requesting the user will be authenticated. The use has to provide the same username and password he/she has provided at the time of user registration in client app.
On successful authentication, the list of active systems will be displayed in a screen. The user can select one and perform the actions like Shutdown, Reboot etc.

Database Entity Relationship Design Diagram

Snapshots of Client App

Snapshots of Server Application