Sunday, December 11, 2011

Real time client-server communication on the web

If you are a software developer and keep your eyes open for what other people are developing, you must have seen Google Talk nicely sitting inside Gmail and you are able to chat using web interface. You also would have seen Twitter updating its recent tweets automagically without refreshing the page. Though it is not a new things, but this kind of applications are kind of new things to mainstream web development. This kind of applications used to be developed in state full programming environments and not in state less web environment.

Normal approach to implement these kind of scenarios would have been to poll the server frequently. Another option could be long polling or WebSockets. However now Microsoft’s ASP.Net team is developing a new library called SignalR. Being developed by Microsoft itself is one big enough buying point. Maarten Balliauw is introducing you to SignalR in detail.

So now if you need to build something related to real time communication on the web, you don’t need to pull your hair. SignalR is here.

Thursday, November 17, 2011

Want to become a good developer

QUALITY. How do you measure quality? Generally speaking quality is an intangible thing, however it is not invisible. Quality is the thing that makes Apple products different from rest of the world. Quality is the thing because of which some of Japanese and German brands enjoy premium over their counterparts.

The same quality can be applied when we work with any kind of software development. In today’s world where outsourcing is another word for software development, people are less concerned with quality and more involved in just head counting. At the end it impacts both customer and service provider.

So, how do you plan to bring quality to software development? By employing CMM, Agile, RUP etc. No, they are all ways to manage project delivery. By employing any one of them will not improve the quality of software. To improve the software quality we will have to first accept that it takes time to get it right. Here I will touch upon some basic things which if you understand and try to implement in your day to day working, you will see your code quality going upwards.

First set of design principles is called S.O.L.I.D. principles. These are five different rules and if you follow them, you certainly will be a step ahead in code quality. I am reiterating them here so that even if you don’t follow the links, it somehow sticks to you.

SRP The Single Responsibility Principle A class should have one, and only one, reason to change.
OCP The Open Closed Principle You should be able to extend a classes behavior, without modifying it
LSP The Liskov Substitution Principle Derived classes must be substitutable for their base classes.
DIP The Dependency Inversion Principle Depend on abstractions, not on concretions.
ISP The Interface Segregation Principle Make fine grained interfaces that are client specific.

If you want to know more about SOLID, you can follow aforementioned links or LosTechies have drafted a very good book on S.O.L.I.D.

Recently I was reading another architecture related book that I thought every developer and budding architects should read. It is Microsoft’s Application Architecture Guide V2.

Another thing is that every developer should start familiarizing themselves with design patterns. Sooner or later they will realize that understanding design patterns makes them a better developer. I am not advocating that you need to be master of design patterns but you need to know few of them. Head First Design Pattern is good book to start with.

I believe every small step towards code quality is a big step towards customer satisfaction and meeting business goals. There are many more such practices which can make you a better developer and make your customer happy. I might discuss those things in future.

Saturday, October 01, 2011

Flash is a Menace

Menace

Flash is a Menace. It keeps crashing now and then. Flash has power to slow down even i5 or i7 machines. My android devices are capable of running Flash but who on earth wants a hog. I don’t.

Death of Silverlight

Lately there has been a stir about the future of Silverlight. Developer community is worried about the future development model. I am least concerned about how things will turn out. All I am concerned about is the ROI of Silverlight. Why should I as an Architect zero on Silverlight? These days I have seen the trend of pushing Silverlight for LOB (Line of Business)/intranet applications where it makes least sense to use it. LOB applications are not usually public facing applications and mostly they run within the intranet of organizations.

There are some reasons people say when they push Silverlight for LOB applications:

  • Silverlight gets you rid of cross browser compatibility.

Well that seems to be the only reason why people are using Silverlight even on intranet applications. This reason alone is not sufficient to use Silverlight because in intranet scenario I can instruct my users to use only one browser (IE or any other better browser). So where is the cross browser compatibility? There is another reason Silverlight is not the best for intranet applications because of lack of good Silverlight developers. Whole point of developing an application in Silverlight is to have better look and feel. But believe me all those regular .net skills that Microsoft uses to push Silverlight are not designer type guys. They are same drag n drop guys and they can’t think of sophisticated UX. On top of this intranet/LOB applications are hardly focused on UX, they are more about getting the business done.

This was about intranet/LOB applications. Talking about public web applications, you any way cannot think about Silverlight or any such thing. iOS (includes both iPhone, iPad and probably iPod touch) is not going to let you use any plugin in near future. Though Android now supports Flash but Silverlight is still a distant dream. I am talking about iOS and Android here because desktop is disappearing slowly. More and more people are using their smartphones for regular browsing. There was some hope from Microsoft’s own platforms but that is also gone with the details disclosed by Windows 8. Yes, you can switch IE 10 to legacy mode and plugins are supported there but I have real doubt whether this option will be there on slates or not. I won’t count WP7/7.5 here until it gathers 25-30% market share (not happening in near future). Until then it is waste of time talking about that platform.

Doing all this reasoning on my own and talking to couple of my colleagues, I don’t feel like selling Silverlight based applications to my clients anymore. Yes, Silverlight has its own niche offering (DRM etc.) and it makes sense to use Silverlight in such scenarios. But for normal intranet/LOB applications I will be better off with ASP.Net or ASP.Net MVC.

Hiding Certain Facebook Updates

Tired of getting unwanted updates being posted by applications that your friends are using. Well, I am tired of that. I want people to see only what I had been sharing and what my friends are personally sharing. I don’t want to know what childish applications they are using. One option is to click on “top right” corner of that “story” and then say “Hide story”. This works well if you get spammed occasionally. But what if you have hundreds of friends and all of them are using these kind of applications? If you permanently want to get rid of updates from certain kind of applications then you click on “top right corner” of story and towards the bottom you will find “Hide all by XYZ”. Select that option and you will never get spammed from that app again. Following is the screen shot of how to hide such updates.

Hiding spams on FB profile

After doing this, your news feed settings should look like below:

News Feed Settings

And to reach this “Edit News Feed Settings” you need to scroll to the bottom of your FB page. Usually when you scroll FB keeps bringing your older feeds and you may never reach the bottom of this page. So you can try CTRL+END. That should do the job. Following is the screen shot of bottom of the FB wall. Select “Edit Options” and above screen should open. Above screen is useful in case you want lift the ban on certain app.

Edit News Feed Settings

Monday, September 26, 2011

Multi Tenancy in Your Application

A year back I was working on one of my project and I was developing it as a multi tenant application. At that time I had not done enough research in the field of multi tenancy and using my common sense I had a multi tenant system with “shared database and shared schema” approach. I learnt many things while working on this pet project but then I closed it because of laziness.

Recently I tried to put more thoughts on multi tenancy. One reason behind this is that recently I came across of several miss-selling cases of Sharepoint 2010. Sharepoint 2010 was pushed down the throat of customers just because of it was a multi tenant system and if you need multi tenancy in your application, just build your application as a Sharepoint 2010 application. Why? Why on earth would I employ a Sharepoint just for a simple multi tenant application? You can say simple multi tenant application is oxymoron but I won’t argue on that. Smile

Multi Tenant Data Architecture is a good read on the topic of achieving multi tenancy at the level of database. Then there are some blog posts by some mature software architects. Multi Tenancy – Approaches and Applicability is a nice collect of several blog post by Ayende Rahien. He talks about Physical Data Model and Extensible Data Model. My view of extensible data model is that you need to make your data model extensible only if you have some serious plans for your application. Even if you don’t start with extensible data model in mind but have opted either separate database or separate schema approach, then you should be able to achieve it at a later date as well. Shared schema approach is what will prohibit you to go for extending data model for each tenant. Ayende also talks about Extensible Behaviors, Development Structure and keeping all this really simple. By looking at all this IoC comes as a critical component that you need to employ in order to build a multi tenant application. Ayende also takes a dig at the article I suggested on multi tenant data architecture.

This is it for now on multi tenant application and I am strictly against using Sharepoint to achieve multi tenancy. I would better roll out my own implementation instead of employing Sharepoint 2010 in this particular case.

Monday, August 01, 2011

GUIDs and their mystery

I learnt in my college that GUIDs are almost unique. You can be quite sure that they are unique. I had the information that GUIDs have component which is mapped to MAC address or say Network Interface Card (NIC). Well if you also had same information then it is no more valid in today’s fast changing world. While we were happily generating GUIDs and using it all over the place, the algorithm to generate it has gone through several revisions. If you are interested to know which version is in use currently, then it is v4.0 and it does not use NIC/MAC address. More details on GUID generation is here.

Tuesday, July 05, 2011

MVC Mini Profiler

There seems to be an interesting profiler to profile your Asp.Net MVC based applications. This is the profiler used by StackOverflow guys. That’s a good enough reason for me to start using it in any of my Asp.Net MVC based application. To top it up it also provides capabilities to profile database. Database profiling is supporting any kind of DbConnection. That means that this profiler is virtually supporting any database providers under the Sun. Worth trying it in next project.

Sunday, May 01, 2011

Kamath; New Chairman of Infosys

As Kamath is appointed new chairman of Infy (as we know it affectionately), many people are wondering about the future Infy is heading towards. Mr. Kamath’s appointment as a chairman did not surprise me as that possibility was doing rounds in the media for quite some time. I am surprised that Infy could not find any young blood to drive it further. The point I am thinking is how this old horse is supposed to drive this behemoth named Infosys any further. By changing its name?

Who are watching Royal Wedding

Wedding Viewership

Well, this is the graph showing who all are watching YouTube video of Royal Wedding. According to my expectation entire world should have been marked in dark green. But then there are hard realities. South Americans and African countries and something more important to do then watching wedding videos on YouTube. But the I think countries highlighted above are considered to be developed countries. What are they doing? I can understand of Japan (poor souls are busy trying to get their life to normal) and China as usual is putting its great wall (firewall) to work. But then what about Russia? What is their problem, all snowed under?

Royal Wedding 2011

Wow, The Royal Couple look great. May God bless them.

Thursday, April 28, 2011

LightSwitch Beta 2 Extensibility Cookbook

According to me VS LightSwitch could be holy grail of LOB application development, however 80-20 rule still applies to it. According to this rule most of business scenarios could be achieved OOB (Out of the Box) but then as an Architect you don’t want to be in position where other 20% scenarios, which business is ready to die for are not possible.

In this case you need capabilities where you can extend LightSwitch and get something which was not exactly possible with OOB product. So grab your copy of LightSwitch Beta 2 extensibility cook book and see if you can develop all of your business cases or not.

Silverlight 5 is here

Oh boy, I am not done yet with Silverlight 4 and Silverlight 5 here. Sigh!

Wednesday, April 13, 2011

RIM Co-CEO Pulls Plug on BBC Interview

While puzzled over on going tussle between Indian Govt. and BlackBerry, in his infinite wisdom BB’s Co-CEO decides to abruptly end the interview. Now I understand that their could be something which are really hurtful and you lose your senses like Zinedine Zidan did.

But then the questions comes that what was it that a co-CEO had to abruptly end an interview. You can see the video here. All the BBC correspondent asked was “what does he feel about all that?”. And the “so called” co-CEO loses his cool. I had the feeling that CEOs are quite good when it comes to putting the thoughts in words. I thought that CEOs are excellent salesmen who can sell anything and can save you from any bad situation. Shouldn’t he have just ignored the question or better than this it was an exciting opportunity for him to explain the stand of BlackBerry to everybody. But he failed! Probably he flunked in his business administration classes where it is taught that “Most successful men have not achieved their distinction by having some new talent or opportunity presented to them. They have developed the opportunity that was at hand”.

Wait a minute, do I see an opportunity here? Like the torn jeans of Akhshay Kumar become fashion, it could be that this abruptly ending interview becomes fashion for techies. After all he is CO-CEO of BB. He must “have” “had” talent to reach there. Probably next time if I am asked some question in an interview/meeting, I can also walk out of interview/meeting saying “This interview/meeting is over”.

Friday, March 25, 2011

Overview of Microsoft® Visual Studio® LightSwitch™

If you have been introduced to Microsoft Visual Studio LightSwitch then you might be having one question, “What is LightSwitch really building under the covers?” Is it mere two tier application wrapped in some fancy UI or anything more? This question is very valid and answer is that LightSwitch applications are built on a standard three tier architecture where each tier runs independent of each other and performs the role within its boundaries.

The presentation tier is responsible for human interaction with the application. Its primary concern is data visualization and editing. The logic tier processes requests from a client to fetch data, update data, or to perform other operations. This tier’s primary role is to shield direct access to the data from unwanted or invalid reads and updates. This helps to ensure the long-term integrity and security of the data. The data storage tier is responsible for durable storage of the application data.

Following is the architectural representation of a standard three tier application:

Following is a more concrete representation of three tier architecture in context of Microsoft Visual Studio LightSwitch application.

If you carefully look into all these three tiers you will have enough reasons to be excited. On presentation tier you are getting Silverlight 4.0 based UI. Office automation will let you export you data directly to Excel. Logic tier or application tier or middle tier is built on a set of technologies. There is ADO.NET Entity Framework for access to SQL Server and SQL Azure. There is WCF Data Services for access to SharePoint 2010 via the OData protocol. And if this was not enough there is a shim to talk to an in-memory WCF RIA DomainService for extensibility. Then on the storage front you have SQL Server, SQL Azure and as I mentioned above, using WCF Data Services you can also consume SharePoint based data.

Is it not something more than what you had wished for? I am placing my bet on LightSwitch. Are you?

Thursday, March 24, 2011

Introducing Microsoft® Visual Studio® LightSwitch™

Here comes another development tool from Microsoft. Microsoft Visual Studio LightSwitch is an extension of Microsoft Visual Studio product line and it is squarely aimed to cut down development time drastically. I am sure you would have worked on many applications where there were just some tables and all you had to develop was CRUD functionality. For this kind of applications you don’t need to split your applications in tiers and layers and you don’t need to apply many other architectural principles.

Business value will be better realized if you can turn around such application with minimum of lines and yet with elegant user interface and ability to choose kind of deployment scenarios (web/desktop or cloud). Microsoft Visual Studio LightSwitch is aimed to fill such gap and it will immensely help LOB application development. I believe Jason Zanders did better job Introducing you to Microsoft Visual Studio LightSwitch then I could have done. Go through the Jason’s post and get awestruck! Once you are out of that awe download LightSwitch and start a brand new journey.

Thursday, March 17, 2011

ILSpy, Free Alternative to .Net Reflector

If you ever worked on .net, I am sure you definitely would have used .Net reflector. After all it is such a useful tool to dissemble and see the code. On top of it, it was free. Well it is no more free? Company that maintains the code base of .net reflector has decided to discontinue free version and started charging a fee for it.

Once the news about .net reflector got out, open source community started working on free alternatives of .net reflector. One prominent alternative that is taking shape is ILSpy. It is still not there where it can replace .net reflector, but it is quite good considering the time it has been in development. Give it a try!

Monday, March 14, 2011

Interface or Abstract class

If you are one among who were searching for an answer to the question that what is difference between abstract class and interface then Abstract class Vs Interface provides you enough arsenal. However if you were looking for when to use which one, I will give you two SOLID reasons you should not use abstract classes and instead use interfaces.

SOLID principles are five majorly used guidelines that how should you design your classes. One such SOLID principle is Interface Segregation Principle (ISP). Another principle is The Liskov Substitution Principle (LSP). Interface segregation principle cannot be followed if you are leaning on abstract class. Substitution principle is itself a big problem and if try to work your way out of Substitution principle then you cannot rely on abstract classes. Let's see these two things in detail.

ISP – Many a times you will get into the argument that if an Abstract class is having all its methods as abstract then it is as good as an Interface. Technically yes, but there is more to it than just being technically correct. ISP tells me that make my interfaces as fine grained as I can make them. My interfaces should not be fat. This is so that my clients need not implement something that they were not interested in. Now take an example – Some behaviors of advance nature in Car object:

  1. Air Bag
  2. Alloy Wheels
  3. Power Steering
  4. ABS

Put these guys together in one interface and we have a fat interface, which not all client might be interested to implement. It will look something like this:

interface IAdvanceFeatures
{

AirBag();

AlloyWheel();

PowerSteering();

ABS();

}

Now if you need to apply ISP on it and implement it using abstract classes, then following would be the scenario:

abstract class AirBag
{
AirBag();
}

abstract class AlloyWheels
{

AlloyWheels();

}

I just separated only two features. But wait a minute. In my infinite wisdom I recalled that many modern programming languages stop you from multiple inheritance. Bingo… now you are in a soup where you want to use ISP but abstract classes are not letting you do it. This is one place where abstract class is bad guy.

LSP – Liskov Substitution Principle tells you that "Derived classes must be substitutable for their base classes". This means we should be able to use any of child class object in place of base class object. But in real time will you be able to create such inheritance hierarchy where child class can be substituted for base class. Not really because child class might have specialized something in such manner that it misbehaves when we put it in place of base class. I agree that such a behavior can be called a programming blunder but such is life. What are our alternatives? Our alternative is design by contract. Now contract can be in form of abstract class or interface. But as we established earlier there are limitations (having more than one abstract class) and you wouldn't want to have LSP on the cost of ISP. Would you? So option for abstract class is again stricken out. Sorry abstract class.

In a nutshell if you are trying to implement ISP and trying to stick to design by contract, abstract class is not a choice for you.

Saturday, March 05, 2011

SaaS Maturity Model

A simple blog post on SaaS maturity model.

Wednesday, February 02, 2011

Ditching Firefox

I have just decided to ditch Firefox in favor of Chrome. This is because Firefox 3.6.13 was very unstable. Every time I used to start, it used to crash. I then upgraded to Firefox 4.0 Beta, but because it is beta, it is very sluggish. On firefox beta hotmail also didn’t work quite good. Hotmail not working is not firefox’s problem but I was getting victimised. Chrome sorts out all those problems and gives me feeling of being light and brisk.

Firefox will be the choice of browser only at work and that too only because of one add-in ”Firebug”. There is “firebug lite” for IE and Chrome, but it is not there yet. So firefox for work, chrome for all other personal stuff. Oh yeah, IE 9 beta is there on my home Windows 7. But that is just for fun!

Difference between Association, Aggregation and Composition

This has been a haunting question to me for some time. I had been trying to get a concrete understanding on differences among these three terms. If you google on differences among these three terms, you will get all sorts of explanation. I was tempted to link couple of those explanations here but that would have just increased their relevancy in google’s eyes (so I won’t do that).

If you google for Aggregation, you will find innumerous guys (in-fact Wikipedia) out there who would define aggregation for you like this:

Aggregation differs from ordinary composition in that it does not imply ownership. In composition, when the owning object is destroyed, so are the contained objects. In aggregation, this is not necessarily true. For example, a university owns various departments (e.g., chemistry), and each department has a number of professors. If the university closes, the departments will no longer exist, but the professors in those departments will continue to exist. Therefore, a University can be seen as a composition of departments, whereas departments have an aggregation of professors.

Isn’t this definition useless? If my cell phone “has a” camera, without cell phone this camera is useless on its own. Camera might be atomic unit on its own however without the parent object it does not reveal its behavior. People try to define this same scenario in other words that camera continues to have its existence and might be fully functional within another cell phone. This is where I have problem. I see this that once parent object is not in existence, contained object has lost its value.

Gang of Four in their book “Design Patterns Elements of Reusable Object Oriented” has handled it pretty good and in a clear way:

Aggregation implies that one object owns or is responsible for another object. Generally we speak of an object having or being part of another object. Aggregation implies that an aggregate object and its owner have identical lifetimes.

This is what we know as composition. They go further and try to define association:

Acquaintance implies that an object merely knows of another object. Sometimes acquaintance is called "association" or the "using" relationship. Acquainted objects may request operations of each other, but they aren't responsible for each other. Acquaintance is a weaker relationship than aggregation and suggests much looser coupling between objects.

This is fine. In association we are not talking about containing each other and controlling the life time. All we are doing is requesting the operations i.e File.IsExists or Path.Combine.

On Composition vs Aggregation, in his book “UML Distilled, third edition”, Martin Fowler says:

Composition is a good way of showing properties that own by value, properties to value objects, or properties that have a strong and somewhat exclusive ownership of particular other components. Aggregation is strictly meaningless; as a result, I recommend that you ignore it in your own diagrams.

And when Martin Fowler is discouraging us to use Aggregation, he meant messed up Aggregation.

Hence forward my stand on Aggregation and Composition will be the union of what GoF says and what Martin Fowler says. GoF calls Composition by the name of Aggregation, so I say that Aggregation and Composition are the same things where there is a “has a” relationship and lifetime is identical for Owner and contained object (Aggregator and Aggregatee). Going forward there are only two things for me, Association and Composition (which is also called Aggregation by GoF).