A Google Gaming Console? It’s Madness!

June 29, 2013 § Leave a comment

A Google Gaming Console? It’s Madness!

Google and Apple would be nuts to dive into the gaming console business and would both be better off focusing on tablets.

google logo

Bubbling up in today’s news stream is a report thatGoogle wants to get into the game console businessand that Apple may too.

In a column earlier this week I concluded that unless a big spender willing to throw money away comes along, nothing will change. It’s a duopoly. That is, unless you think the business can be sustained by the Angry Birds franchise.

Let’s dissect some of these developments. To begin, the Google threat is a rumor. If it becomes more than a rumor it will become a pipe dream.

Both Google and Apple should be doing the logical thing: turn the tablet into a game machine. The idea is to sell tablets. What is the point of adding a game console unless it is nothing more than an HDTV interface?

The Nintendo Wii U comes with a small, dedicated tablet on which you can actually play a game without a TV or screen. I’m sure this attracted the attention of the folks at Google and Apple.

But instead of copying Nintendo while competing with Xbox and PlayStation, both Apple and Google should be sponsoring some development work designed to create a killer tablet-based game. This is where the future lies, not in clunky game consoles that many people only use for Netflix.

Also, does anyone think that Google and Apple are serious? Are these companies sincere or are they just scrambling for something to make it look as if they are growth companies?

I hope that none of this is true. The console side of the tech industry is a zombie. It’s not as if I don’t expect to see Halo 12 and Call of Duty 14 years from now, but how drab can the future be if you are looking at a screen carrying a virtual gun and roaming around some battlefield waiting for some action? If the economy ever corrects, nobody is going to have time for any of this. And if they do, then it’ll be on a tablet.

If Google or Apple indeed brings out a gaming console, I’ll be stunned. But if they create some sort of tablet add-on that has the controls similar to the Nintendo Wii U, which then hooks up to a tablet, then I’d say fine, at least this sort of retro idea sells more tablets. If instead neither company plans on doing anything and this is all part of a scheme to harass Microsoft, then great. But an actual game console based on iOS and Android? It’s madness.

Martin Fowler at GOTO Amsterdam 2013 about Agile Essence and Fluency

June 27, 2013 § Leave a comment

Martin Fowler at GOTO Amsterdam 2013 about Agile Essence and Fluency

by Ben Linders

The second day of the GOTO Amsterdam 2013 conference stared with a keynote by Martin Fowler on software development in the 21st century. He explored the reasons why agile was started in the 90s to discuss how teams can become fluent in agile, and reach for the stars.

Agile started as an answer on projects that were late, delivering buggy software to unhappy users, and had developers that were demotivated by this. Plan driven methods were used at that time to develop software, and Martin compared them to agile. Agile differs as it uses adaptive planning where plan driven uses predictive planning. Where agile focuses on the people, plan driven methods are mostly about processes. In plan driven methods there are separated steps to plan your work, and work your plan, and success is defined as “according to plan”. Since the plans depended on requirements stability, plan driven methods wanted to stabilize requirements, where agile wants to break the dependency between plans and stable requirements by embracing change.

As Martin mentioned earlier, agile also differs with plan driven on how it views processes and people. He showed how agile has a shift in mindset to “people first” in stead of “processes first”. Software development processes in plan driven methods are viewed as consisting of steps and links between steps, involving people who will follow the process. Agile takes a different approach, by starting with assembling good people into a team, and then let the team decides on a suitable process. Martin stated that it is “wrong to command a team to become agile”. Team will chose themselves to do things agile or not, and that’s ok.

This brings up the question when teams should agile, and when not, and how fluent they want to be in agile. Diana Larsen and James Shore wrote about Agile Fluency, and Martin published their article in your path through agile fluency. Diana and James defined fluency as:

Fluency is how a team develops software when it’s under pressure. Anyone can follow a set of practices when given time to focus in a classroom; true fluency is a skillful, routine practice that persists when your mind is distracted with other things.

Martin presented how teams can increase their agile fluency, from a first star level up to four stars. At the first star level, teams divide the work up in individual chunks to deliver business value. You need to invest in team development and process design to reach this level, it typically takes 2-6 months for a team to reach it. Teams at the two star level “ship on the market cadence”; realizing more value by delivering as often as their markets can handle. An investment is needed in technical skills and practices like XP, TDD and pair programming to increase software craftsmanship and get a productive team which delivers software with less defects. It typically takes teams 3-24 months to get on this level.

Teams on the third star level are optimizing their business value using metrics, and teams on the fourth star also contribute to enterprise wide success. Martin mentioned that he doesn’t see many teams on star level three and four. He suggest for teams to think about which level that they would want to reach, and if they are able and willing to do the investment.

Agile Software Architecture Sketches and NoUML

June 26, 2013 § Leave a comment

Interesting article I read on InfoQ.com  about the role architecture in Agile development. So I thought to share it in my blog.


Agile Software Architecture Sketches and NoUML

Posted by Simon Brown

If you’re working in an agile software development team at the moment, take a look around at your environment. Whether it’s physical or virtual, there’s likely to be a story wall or Kanban board visualising the work yet to be started, in progress and done. Visualising your software development process is a fantastic way to introduce transparency because anybody can see, at a glance, a high-level snapshot of the current progress. As an industry, we’ve become pretty adept at visualising our software development process over the past few years although it seems we’ve forgotten how to visualise the actual software that we’re building. I’m not just referring to post-project documentation, this also includes communication during the software development process. Agility is about moving fast and this requires good communication, but it’s surprising that many teams struggle to effectively communicate the design of their software.

Prescribed methods, process frameworks and formal notations

If you look back a few years, structured processes and formal notations provided a reference point for both the software design process and how to communicate the resulting designs. Examples include the Rational Unified Process (RUP), Structured Systems Analysis And Design Method (SSADM), the Unified Modelling Language (UML) and so on. Although the software development industry has moved on in many ways, we seem to have forgotten some of the good things that these older approaches gave us. In today’s world of agile delivery and lean startups, some software teams have lost the ability to communicate what it is they are building and it’s no surprise that these teams often seem to lack technical leadership, direction and consistency. If you want to ensure that everybody is contributing to the same end-goal, you need to be able to effectively communicate the vision of what it is you’re building. And if you want agility and the ability to move fast, you need to be able to communicate that vision efficiently too.

Abandoning UML

As an industry, we do have the Unified Modelling Language (UML), which is a formal standardised notation for communicating the design of software systems. I do use UML myself, but I only tend to use it sparingly for sketching out any important low-level design aspects of a software system. I don’t find that UML works well for describing the high-level software architecture of a software system and while it’s possible to debate this, it’s often irrelevant because many teams have already thrown out UML or simply don’t know it. Such teams typically favour informal boxes and lines style sketches instead but often these diagrams don’t make much sense unless they are accompanied by a detailed narrative, which ultimately slows the team down. Next time somebody presents a software design to you focussed around one or more informal sketches, ask yourself whether they are presenting what’s on the sketches or whether they are presenting what’s still in their head.

 (Click on the image to enlarge it)

Abandoning UML is all very well but, in the race for agility, many software development teams have lost the ability to communicate visually too. The example NoUML software architecture sketches (above) illustrate a number of typical approaches to communicating software architecture and they suffer from the following types of problems:

  • Colour-coding is usually not explained or is often inconsistent.
  • The purpose of diagram elements (i.e. different styles of boxes and lines) is often not explained.
  • Key relationships between diagram elements are sometimes missing or ambiguous.
  • Generic terms such as “business logic” are often used.
  • Technology choices (or options) are usually omitted.
  • Levels of abstraction are often mixed.
  • Diagrams often try to show too much detail.
  • Diagrams often lack context or a logical starting point.

Some simple abstractions

Informal boxes and lines sketches can work very well, but there are many pitfalls associated with communicating software designs in this way. My approach is to use a small collection of simple diagrams that each show a different part of the same overall story. In order to do this though, you need to agree on a simple way to think about the software system that you’re building. Assuming an object oriented programming language, the way that I like to think about a software system is as follows … a software system is made up of a number of containers, which themselves are made up of a number of components, which in turn are implemented by one or more classes. It’s a simple hierarchy of logical building blocks that can be used to model most of the software systems that I’ve encountered.

  • Classes: in an OO world, classes are the smallest building blocks of our software systems.
  • Components: components (or services) are typically made up of a number of collaborating classes, all sitting behind a coarse-grained interface. Examples might include a “risk calculator”, “audit component”, “security service”, “e-mail service”, etc depending on what you are building.
  • Containers: a container represents something in which components are executed or where data resides. This could be anything from a web or application server through to a rich client application, database or file system. Containers are typically the things that need to be running/available for the software system to work as a whole. The key thing about understanding a software system from a containers perspective is that any inter-container communication is likely to require a remote interface such as a web service call, remote method invocation, messaging, etc.
  • System: a system is the highest level of abstraction and represents something that delivers value to, for example, end-users.

Summarising the static structure of your software with NoUML

By using this set of abstractions to think about a software system, we can now draw a number of simple boxes and lines sketches to summarise the static structure of that software system as follows (you can see some examples on Flickr):

  1. Context diagram: a very high-level diagram showing your system as a box in the centre, surrounded by other boxes representing the users and all of the other systems that the software system interfaces with. Detail isn’t important here as this is your zoomed out view showing a big picture of the system landscape. The focus should be on people (actors, roles, personas, etc) and software systems rather than technologies, protocols and other low-level details. It’s the sort of diagram that you could show to non-technical people.
  2. Containers diagram: a high-level diagram showing the various web servers, application servers, standalone applications, databases, file systems, etc that make up your software system, along with the relationships/interactions between them. This is the diagram that illustrates your high-level technology choices. Focus on showing the logical containers and leave other diagrams (e.g. infrastructure and deployment diagrams) to show the physical instances and deployment mappings.
  3. Components diagrams: a diagram (one per container) showing the major logical components/services and their relationships. Additional information such as known technology choices for component implementation (e.g. Spring, Hibernate, Windows Communication Foundation, F#, etc) can also be added to the diagram in order to ground the design in reality.
  4. Class diagrams: this is an optional level of detail and I will typically draw a small number of high-level UML class diagrams if I want to explain how a particular pattern or component will be (or has been) implemented. The factors that prompt me to draw class diagrams for parts of the software system include the complexity of the software plus the size and experience of the team. Any UML diagrams that I do draw tend to be sketches rather than comprehensive models.

(Click on the image to enlarge it)

A single diagram can quickly become cluttered and confused, but a collection of simple diagrams allows you to easily present the software from a number of different levels of abstraction. And this is an important point because it’s not just software developers within the team that need information about the software. There are other stakeholders and consumers too; ranging from non-technical domain experts, testers and management through to technical staff in operations and support functions. For example, a diagram showing the containers is particularly useful for people like operations and support staff that want some technical information about your software system, but don’t necessarily need to know anything about the inner workings.

Organisational ideas, not a standard

This simple sketching approach works for me and many of the software teams that I work with, but it’s about about providing some organisational ideas and guidelines rather than creating a prescriptive standard. The goal here is to help teams communicate their software designs in an effective and efficient way rather than creating another comprehensive modelling notation. It’s worth reiterating that informal boxes and lines sketches provide flexibility at the expense of diagram consistency because you’re creating your own notation rather than using a standard like UML. My advice here is to be conscious of colour-coding, line style, shapes, etc and let a set of consistent notations evolve naturally within your team. Including a simple key/legend on each diagram to explain the notation will help too.

There seems to be a common misconception that “architecture diagrams” must only present a high-level conceptual view of the world, so it’s not surprising that software developers often regard them as pointless. In the same way that software architecture should be about coding, coaching and collaboration rather than ivory towers, software architecture diagrams should be grounded in reality too. Including technology choices (or options) is a usually a step in the right direction and will help prevent diagrams looking like an ivory tower architecture where a bunch of conceptual components magically collaborate to form an end-to-end software system.

“Just enough” up front design

As a final point, Grady Booch has a great explanation of the difference between architecture and design where he says that architecture represents the “significant decisions”, where significance is measured by cost of change. The context, containers and components diagrams show what I consider to be the significant structural elements of a software system. Therefore, in addition to helping teams with effective and efficient communication, adopting this approach to diagramming can also help software teams that struggle with either doing too much or too little up front design. Starting with a blank sheet of paper, many software systems can be designed and illustrated down to high-level components in a number of hours or days rather than weeks or months. Illustrating the design of your software can be a quick and easy task that, when done well, can really help to introduce technical leadership and instil a sense of a shared technical vision that the whole team can buy into. Sketching should be a skill in every software developer’s toolbox. It’s a great way to visualise a solution and communicate it quickly plus it paves the way for collaborative design and collective code ownership.

Real-Time Web Enablement with SignalR in .Net

June 24, 2013 § 3 Comments

Here is good article on SignalR in .Net from Sonal Arora

Real-Time Web Enablement with SignalR in .Net

We know that Twitter is the classy example of the real-time web and we can find the latest idea, stories, trends and what not on Twitter as it happens. But then again what is real-time web and what is so gripping about it? The real-time web is fundamentally different from real-time computing since there is no knowing when, or if, a response will be received1 and HTTP being a stateless protocol, the server does not have any connection with the client once a response is sent back. So how can a server make its connected client update with some information when the client has not asked for it and can I achieve it for my web application to make it trendy? The Answer is Yes… read on to learn more about the Enabler, SignalR.

So What is SignalR

Real-time web functionality is the ability to have server-side code push content to connected clients instantly as and when required2 and ASP.NET SignalR is a library that enables applications to include real-time web as a feature in no time. It offers a simple to use, high-level API for making server to client RPC in ASP.NET applications, through which we can call JavaScript functions in clients’ browsers from our server-side .NET code. Enhancing it for connection management, e.g. connect/disconnect actions, grouping connections, authorization is also doable with SignalR, although Authorization is not offered out of the box here.

It is an Open Source library and currently licensed under the Apache License, Version 2.0. One may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.

How SignalR Works

SignalR is something that sits a layer above all of the different techniques of transport whether it’s Web Sockets or AJAX long polling or server-sent events. I, as a developer, code against the SignalR API, and SignalR takes care of ensuring that the appropriate persistent connection passage is set up and maintained between the browser and the server. So it is like layered abstraction over a connection.

When an application has a SignalR connection and it wants to send some data to the server, data is not sent in a raw form; SignalR wraps that data in some JSON along with other information and wraps it all on the JSON payload before sending it to the server. Similarly on the server side, when an app broadcasts data to all connected clients, it does not just broadcast the raw data but a bunch of framing information that contains connection information as well.

A typical request header sent through SignalR client could be something like the following.

POST/signalr/send?transport=foreverFrame&connectionId=ba0c3fe4-1a34-48b4-9a3a-8c7cdc02b5d9 HTTP/1.1

It has transport type (Web socket/Forever frame etc.), Connection Id and HTTP protocol information.

Most of SignalR pieces are replaceable with customized implementations. You can check more athttps://github.com/SignalR/SignalR/wiki/Extensibility

SignalR consists of a client-side library and a server-side library that work together; let’s check these one by one.


There are two programming prototypes of servers possible with SignalR.

Two programming prototypes of servers
Two programming prototypes of servers

  • Persistent Connections
    Persistent connection, the simpler of the two possibilities, provides mechanisms to alert the connection and disconnection of users, and to manage asynchronous messages to linked users, both individually and collectively. In this kind of implementation, your endpoint or server derives from PersistentConnection class.
  • Hubs
    Hubs provide a development interface, which is much easier to use. The integration between client and server is almost seamless. Hubs provide a higher level RPC framework over a PersistentConnection. It is advisable to use when the application has different types of messages that need to be sent between servers. We can create the same applications using persistent connections, but with hubs it will be simpler.

And Self Host

Any .NET application (console, forms, Windows services…) can act as the host of SignalR services. In case you want to run your host outside IIS, you can code for having Self host.


The SignalR JavaScript client comes in the form of a jQuery plugin. However, SignalR does not just have JavaScript client library. It is also possible to find client components for Windows Phone, Silverlight, WinRT or generic .NET clients, which extends the range of SignalR’s applicability as a framework for real-time applications in any kind of scenario.

Different client components currently available are:

  • Javascript
  • .NET 4.0
  • .NET 4.5
  • Silverlight 5
  • WinRT
  • Windows Phone 8

SignalR features
SignalR features


SignalR is built upon the idea of transports; every transport mode decides how data is sent /received and how it connects and disconnects. SignalR supports multiple transport modes with the assigned priority. If the client’s browser supports Web Socket transport then communication happens in this mode else it falls back to Server Sent or Forever frame; if browser does not support these two then it makes use of the long polling mode for communication.

Multiple transport modes
Multiple transport modes

Though SignalR tries to choose the “best” connection supported by the server and client, nevertheless you can also force it to use a specific transport. At the time of starting the connection, you specify transport mode as:

  1. //try only longpolling
  2. connection.start({ transport: ‘longPolling’ });
  3. // try longPolling then webSockets
  4. connection.start({ transport: [‘longPolling’,’webSockets’] });

The Magical Connection ID

When an app is using SignalR, every connected client is assigned a connection id, which is regenerated at every page refresh. The server identifies the calling client and other connected clients with the help of this connection id only. Any connected client can invoke a server method from the script with the help of proxy handler. And at the server end, along with the relevant processing, a client side method can be invoked. That makes it a Bi-Directional RPC, where one client invokes a server method defined on the hub and from this server method you can invoke methods at all/selected/calling client.

Where can I use SignalR?

SignalR works deliciously for simple notifications where we need to update all connected users for some news feed and broadcasting. However it can handle complex scenarios such as Chat, Co-Creating, Gaming, etc. Here is the small snapshot of the usability scenario.





Notify All or selected clients.

Notification could be of numerous types, like incoming message, some alert, progress bar, reminders, comment or feedback on your blog or post, etc.

It is easy to implement chat with the help of SignalR. Chat can be one-to-one or Group chat. You can try out a simple chat application as described here:http://www.asp.net/signalr/overview /getting-started/tutorial-getting-started-with-signalr Two or more connected users can enter into co-create mode similar to the one described here:http://www.codeproject.com/Tips /417502/Online-Whiteboard-using-HTML5-and-SignalR It enables applications like gaming, which require high frequency push from the server. You can check out the example given on the SignalR site:



SignalR and its usability looks very promising; it lets developers embed real-time web in the application without getting their hands dirty. It’s on GitHub and there is a dedicated team working tirelessly to make it even better. New users get instant support on the forums as well. To get hands on with this very promising library from Asp.net, read Part 2 of this article to know how to actually do that.


1.        Real Time Web. Wikipedia”

2.        Introduction. “SignalR


Getting Started with SignalR

Your app should be on .Net Framework 4.0 or higher in order to use SignalR. You can find it on NuGet. To install SignalR in your .Net Application, click on Tools | Library Package Manager | Package Manager Console in your VS IDE and run the command:

  1. install-package Microsoft.AspNet.SignalR

This command will add Server and Client side libraries in your application, making you ready to go.

Add Server and Client side libraries

Add Server and Client side libraries

Follow these steps to get hands on with SignalR with one simple example.

Adding Reference to SignalR

Add reference to SignalR in your class file.

  1. using Microsoft.AspNet.SignalR;

Implementing the Endpoint

The endpoint, or SignalR service, can be implemented using persistent connection or hubs. I will be implementing Hubs in the example.

Example Code

Route Registration

Once the endpoint is implemented, we must register it in the routing system, which will allow us to access it. The best place to do this is in the Application_Start() of Global.asax, so that it runs during initialization of the application.

Example Code

Implementing the Web Client

Implementing the web client begins by including a reference to the client library of this component on our page or view. In order to support older clients that do not natively support JSON deserialization, you will have to add a reference to the json2.js script library before referencing SignalR related script files.

Example Code

Initiate the Connection

To initiate a connection from client to server, you need to start the hub in script. Along with initiating connection you would want to define the event that triggers the server push; it could be anything from a button click or some status change. To keep it simple, in the example it’s a button click on your page.

Example Code

Defining Client Procedure to be Invoked by Server

If you recall from the “Implementing the endpoint” step, I had called a method broadcastMessage ()on all the clients. The definition of this method is done in the script at the client side as shown below.

Example Code

Now run the application in multiple browser windows and click at the button control on one page. This will display “Hello <User  Name> Welcome to Devx” in <YOUR HTML CONTROL> in opened browser windows, even for those that were not active.

So far so good, without worrying about the rawness of transport and real time web intricacies, you made your site RealTime web enabled in no time with SignalR. But is that all you wanted for your site, if not…then read on.

Unraveling Real World Problems with SignalR

Applications in the real world are not as easy as the example we saw just now. To implement real-time web with SignalR, you will have to play around with the connection ids of connected clients. And if authorization is enabled for a web site then you will have to write your own code and save the connection id along with logged in user details, as authorization is not offered here out of the box. Today authorization is more or less an integral part of web sites, and I am not taking up some unexplored topic here. Nevertheless, I would like to detail different strategies to help you choose the best one for your requirement.

Diverse Approaches for Managing Connection IDs

  • DEPRECATED: In its initial releases, SignalR provided a way to override its Connection Factory where a programmer could assign a unique connection id to each connected client and that could be used while invoking the client method; however it is no longer supported.
  • Now you will have to save the connection id along with the unique key of the authorized user in order to enable your code to invoke the method on the selected client. A very commonly used design is to maintain a user list on the server that plots connection IDs to users and registers the users as they connect and disconnect1, as proposed at the link http://forums.asp.net/t/1887454.aspx/1?How+to+manually+set+the+connection+id.
  • For application sanity and keeping the app server memory free for processing, I personally suggest using DB tales instead of adding things up in some variable at the app server. The above mentioned concept can be implemented using a DB table we well. I will elaborate this approach in article and at the end suggest some enhancements based on the requirement.

Step 1: Boot up

Here I assume that:

1. You have installed SignalR lib in your .Net application, on framework 4.0 or higher(ref).

2. You have defined your end point by deriving your class from Hub (ref).

3. You have made the necessary changes to your Global.asax (ref).

Step 2: Change in DB Schema

Create one db table to save logged in user’s id along with connection id. Entity class would look something like what is shown below.

Example Code

Step 3: Client and Connection

After including references to the SignalR client library as we did in previous example, you will have to initiate connection. When a client connects to Hub, you can invoke the method to save user information along with connection id. So here we write a client method, which is invoked when the master page or frame window loads.

Example Code

Heremarkonline() is a server side method in your Hub class, to store User and connection id info in the table.

Example Code

Once we are done with “Setting up the connection,” which includes saving rows to db schema, we should implement logic to clear the table as and when the user disconnects from application.

Now disconnection can happen in two manners. The user can close the browser or can log off. To handle both scenarios, you can write methods similar to those shown below.

In the class that derives from Hub, override onDisconnected().

Example Code

And when a user logs off from the application, invoke a method similar to the one shown below.

Example Code

Step 4: Updating DB Schema

Code for updateOnlineUser()method is shown below.

Example Code

Step 5: Fetching a User’s Connection ID/s

Now write a code that fetches all connection ids for a specific user.

Example Code

Step 6: Client-Server BI Directional RPC

Now whenever a server method is invoked, you can fetch list of available connection ids for the target user/s and invoke the method on available connection ids.

Example Code

Where broadcastMessage is a client side method defined as:

Example Code

The above mentioned code will work even If you have multiple connection id scenarios like notification, chat and Co-Create on the same screen, working parallel to each other.

Multiple connection id scenarios
Multiple connection id scenarios

How to Make Multiple Connection ID Scenario More Scalable

Until now we were fetching all connection ids for a user and invoking client method on all of these. This way, methods meant for Chat would be called upon frame for co create or notification as well, which eventually slows down the application with unnecessary processing.

To make it better, you can store the origin of connection id along with it. When invoking markonline(), you can send a string say “source” as a parameter. For example from the Co-Create frame as markonline(“cocreate”) and from Chat window  markonline(“chat”)  and from the master page markonline(“master”) ; this will make your table look like this:




User1 24b11640-XXXX-4069-XX96-8389223418ac cocreate
User1 eaa2de3d-f7df-46ce-XXXX-32bdfe612794 master
User2 8d2XXcc5-XX61-4f8d-a9f4-d3bcXXX1f14c cocreate
User2 3b900a78-4c1e-4XX8-be2c-XXXXXXXX chat
User3 XXXXXX-af57-4cc0-a2c0-4075947e3915 cocreate
User3 7f946c23-XXXX-4b49-b7d8-ee97cac5eXXX chat
User4 b2136fe5-XXXX-48d3-XXXX-047b77f34b09 master
…… …… ……

Now while fetching the list of connection ids from the table with isUserOnline(string username) method, you can specify source based on the method you are invoking it for by passing it as a where clause to the query. So when you want connection id for chat methods, you will fetch record only for source=”chat”.

How to Enhance Same Code for Multiple Sessions of Same User

Today a user can run the application from multiple devices as well. To make the above approach work for multiple session scenarios, you can store session id along with userid, source and connection id and fetch the result based on these parameters. This will ensure that when you invoke client method from the server, it reaches the destination it is meant to reach. Similarly, while deleting records when a user logs off or closes a browser window, you delete rows belonging to that session only.


As I said earlier, SignalR and its usability looks very promising, and you saw how you can embed real time web in the application without getting your hands dirty. Yes, there are tricks, which you would have to play while working on selected list of connection ids however that is restricted to some “ifs” here and some “where” there but saves us from dealing with the rawness of communication APIs.


1. ASP.Net Forums. “How to manually set the connection id”.

Email Formatted HTML Table with T-SQL

June 21, 2013 § 3 Comments

This is life savior stuff. As we send HTML formatted email. Sharing Steve Moore articles below

Email Formatted HTML Table with T-SQL

By Steve Moore, 2013/06/20

One of the most common tasks for me is to send data from a query as the body of an e-mail.  You can do this in SSIS by outputting a query to a flat file, but there’s no easy way to format the content.  You have the option of using XML and XSLT transformations, but that is a bit onerous for simple use cases.

This article is about how to produce a table like the one below in an e-mail using just SQL.  The only real complexity is formatting alternate rows, which was my goal.  I wanted it to look like a .NET DataGrid (shown below).



The basic approach involves three steps:

  1. Create a query that pulls together the data as HTML.
  2. Use bcp and xp_cmdshell to write the SQL to a file.
  3. Email the file using Blat, a free SMTP client (www.blat.net)

One of the problems I ran into is the use of a <script> tag in the email, so there I had to abandon CSS styling and instead do inline styling on every row.

In order to find the odd/even rows, you need the ROW_NUMBER() function in a CTE, then use a CASE statement, and the modulo operator, to format the result:

CREATE PROCEDURE [dbo].[procHtmlSql] AS


WITH htmlresult AS (
SELECT ROW_NUMBER() OVER (ORDER BY AuditTrail.EnteredDate) AS RowNumber,
'<td>' + AuditTrail.OldValue + '</td><td>' + AuditTrail.NewValue + '</td><td>'
+ AuditTrail.LoginID + '</td><td>'
+ CAST((CONVERT(smalldatetime, AuditTrail.EnteredDate)) AS VARCHAR(20)) + '</td>' AS HtmlData
FROM  AuditTrail
WHERE (AuditTrail.EnteredDate > GETDATE() - 1)
SELECT '<html><head><title></title></head>
    <body><br><br><table><tr style="background-color: #5D7B9D; font-weight: bold; color: white;">
    <td>Old Value</td><td>New Value</td><td>Login</td><td>Entered Date</td></tr>' AS HtmlData
SELECT HtmlData =
    CASE RowNumber%2
        WHEN 0 THEN '<tr style="background-color: #F7F6F3">' + HtmlData + '</tr>'
        ELSE '<tr>' + HtmlData + '</tr>'
FROM htmlresult
SELECT '</table></body></html>'


Once you have the SQL with HTML formatting, you want to use that within another stored procedure to write the result to a file.  This is what the second proc should look like:


CREATE PROC [dbo].[procHtmlFile] AS

   DECLARE @strCommand varchar(255)
   DECLARE @lret int
   SET @strCommand = 'bcp "EXECUTE MYDB.dbo.procHtmlSql" QUERYOUT C:\MyProject\SqlHtml.html -T -c'

   EXEC @lRet = master..xp_cmdshell @strCommand, NO_OUTPUT


Now you should be able to open the file “C:\MyProject\SqlHtml.html” in a browser and it should look similar to a .NET DataGrid.

Finally, send the file as the body of an e-mail with this procedure.

CREATE PROCEDURE [dbo].[procBlatSendMail]
  @to varchar(255) = 'foo@foo.com',   
  @from varchar(255) = 'foo@foo.com',
  @subject varchar(100) = 'My Example - '  
  DECLARE @command as varchar(1500)

  SET @command = ''
  SET @command = @command + 'Blat C:\MyProject\SqlHtml.html'
  SET @command = @command + ' -to ' + '"' + @to + '"'
  SET @command = @command + ' -f ' + '"' + @from + '"'
  SET @command = @command + ' -subject ' + '"' + @subject + CONVERT(nvarchar(25), GETDATE()) + '"'

  EXEC master.dbo.xp_cmdshell @command

Simple, effective, and professional looking.

Top JavaScript MVC Frameworks

June 19, 2013 § 3 Comments

As more and more logic ends up being executed in the browser, JavaScript front-end codebases grow larger and more difficult to maintain. As a way to solve this issue developers have been turning to MVC frameworks which promise increased productivity and maintainable code. As part of the new community-driven research initiative, InfoQ is examining the adoption of such frameworks and libraries by developers.

  • Backbone.js: Provides models with key-value binding and custom events, collections, and connects it all to your existing API over a RESTful JSON interface.
  • AngularJS: A toolset based on extending the HTML vocabulary for your application.
  • Ember.js: Provides template written in the Handlebars templating language, views, controllers, models and a router.
  • Knockout: Aims to simplify JavaScript UIs by applying the Model-View-View Model (MVVM) pattern.
  • Agility.js: Aims to let developers write maintainable and reusable browser code without the verbose or infrastructural overhead found in other MVC libraries.
  • CanJS: Focuses on striking a balance between size, ease of use, safety, speed and flexibility.
  • Spine: A lightweight framework that strives to have the most friendly documentation for any JavaScript framework available.
  • Maria: Based on the original MVC flavor as it was used in Smalltalk – aka “the Gang of Four MVC”.
  • ExtJS: Amongst other things offers plugin-free charting, and modern UI widgets.
  • Sammy.js: A small JavaScript framework developed to provide a basic structure for developing JavaScript applications.
  • Stapes.js: A tiny framework that aims to be easy to fit in an existing codebase, and because of its size it’s suitable for mobile development.
  • Epitome: Epitome is a MVC* (MVP) framework for MooTools.
  • soma.js: Tries help developers to write loosely-coupled applications to increase scalability and maintainability.
  • PlastronJS: MVC framework for Closure Library and Closure Compiler.
  • rAppid.js: Lets you encapsulate complexity into components which can be easy used like HTML elements in your application.
  • Serenade.js: Tries to follow the ideas of classical MVC than competing frameworks.
  • Kendo UI: Combines jQuery-based widgets, an MVVM framework, themes, templates, and more.

The Difference Between Managers and Leaders

June 19, 2013 § Leave a comment

The Difference Between Managers and Leaders

by Ilya Pozin

It’s time to face the music as a manager: You don’t always have all of the right answers. Your “it’s my way or the highway” approach to management isn’t going to encourage anyone to help you in your problem solving endeavors.

Managers and leaders are often referred to synonymously, but only leaders allow their employees to solve problems with their own insight. The truth of the matter is this: Every leader may not be a manager, but every manager should be a leader. It’s easy to see that leadership and management aren’t the same thing, but a manager who lacks effective leadership traits will drive a business into the ground faster than you can count to 10.

Change doesn’t happen overnight when it comes to transforming managers into leaders. It takes time and energy to improve the way you manage and utilize more leadership characteristics on a daily basis.

Here are some tips to help you make the necessary improvements:

1. Managers give answers, leaders ask questions. There’s nothing certain to turn your employees against you faster than shouting orders at them. Why not spare yourself the impending resentment and simply ask your employees this: “What would you do?” or “What do you think of this idea?” Allowing people to participate in the decision-making process will not only transform what could have been an order into something more easily swallowed–it also inspires creativity, motivation, and autonomy.

2. Managers criticize mistakes, leaders call attention to mistakes indirectly. It may seem more efficient to point out your employees’ mistakes directly, but this will only leave them feeling embarrassed and frustrated. You should really be giving them the chance to learn and grow from through your critiques. Instead, give your employees the chance to address their mistakes.

For example, say a project was sent to a client and you receive back a disgruntled message. Calmly ask your employee about the clients concern and whether they feel what was provided was on par. This will give them a chance to provide their input, while also improving for the future.

3. Managers forget to praise, leaders reward even the smallest improvement. Praise pays off when it comes to increasing the overall success of your company. Finding time to recognize your employees for even the smallest accomplishment will only increase their interest in what they do. If you’re interested in ensuring your employees take pride in all that they do, regular feedback and recognition is certain to do the trick. Everyone wants to be genuinely appreciated for their efforts.

4. Managers focus on the bad, leaders emphasize the good. This really comes down to seeing the cup half empty or half full. If you’re only willing to point out the flaws of a project or an employee, you’re not giving them much interest in learning or improving. Instead, create a sandwich effect. Start with some form of praise, follow with the criticism, and end with praise.

5. Managers want credit, leaders credit their teams. Managers who lack leadership abilities are always first to take credit. But effective leaders understand the importance of crediting their teams for the big wins. This pays off in the long run for creative a workplace with a more positive company culture and employees who are driven toward more successes as a team.

Management shouldn’t be approach through force, but rather through influence. Put these techniques in place to improve the way your employees perform.

What do you think? Do you ask questions instead of giving answers?

Where Am I?

You are currently viewing the archives for June, 2013 at Naik Vinay.