Friday, December 31, 2010

Interesting links for 31st December 2010

 

Agile

 

WPF / Silverlight / WP7

Miscellaneous

Wednesday, December 29, 2010

Interesting Links for 29th December 2010

 

WPF / Silverlight / WP7

Developers guide to Microsoft Prism : http://msdn.microsoft.com/en-in/library/gg406140.aspx

WCF

Windows Communication foundation Firestarter : http://channel9.msdn.com/blogs/egibson/windows-communication-foundation-wcf-firestarter-part-1-of-5-keynote-intro-to-soa—wcf. I hope that this series on WCF is as good as the firestarted event for Silverlight. I learnt so much about Silverlight just watching the firestarter videos.

Agile

Agile / Lean principles will simply not scale : http://flowchainsensei.amplify.com/2010/12/29/agilelean-principles-will-simply-not-scale/

Agile is relationship management : http://agilescout.com/agile-is-relationship-management/

Tuesday, December 28, 2010

Interesting links for 28th December 2010

 

After a brief stoppage due to my relocation from India to Singapore, the interesting posts series is back. Enjoy the links.

ASP.NET / ASP.NET MVC

How to implement a date time picker across multiple drop downs with ASP.NET MVC - http://dariosantarelli.wordpress.com/2010/12/26/asp-net-mvc-2-splitting-datetime-in-drop-down-lists-and-model-binding/ This is a nice post which was recommended by Scott Guthrie on twitter.

Resetting form fields in ASP.NET Webforms - http://scottonwriting.net/sowblog/archive/2010/12/23/resetting-form-field-values-in-an-asp-net-webform.aspx. Another article by Scott, but this time its Scott Mitchell Smile

Agile

Just enough, just in time and sometimes Just because - http://www.jessefewell.com/2010/12/27/just-enough-just-in-time-and-sometimes-just-because/. This is a very nice post by the person whom I interacted a bit in my last organization Jesse Fewell. Good one Jesse.

Theory of Constraints – blaming the bottleneck : http://www.markhneedham.com/blog/2010/12/26/theory-of-constraints-blaming-the-bottleneck/

Rotating responsibility for Scrums and Retrospectives - http://agilescout.com/agile-guide-rotating-responsibility-for-scrums-and-retrospectives/ 

Jack Welch’s leadership attributes - http://herdingcats.typepad.com/my_weblog/2010/12/jack-welchs-leadership-attributes.html

Servant Leader - http://thecriticalpath.info/2010/12/27/servant-leadership/. If you have time please read the linked post about practicing servant leadership in this article.

Monday, December 27, 2010

Yodlee Money Centre–Free online money manager

Background

Few days back I had written about a personal finance manager software called Money Manager. This is a desktop application. My friend Mahesh Sawaiker suggested another open source software called GNUCash. Unfortunately I did have a good first impression about this one as it crashed on my laptop within hours of installing it. This post is about an free online personal finance manager software called Yodlee Money Centre.

Yodlee Money Centre

This is a free software. Initially it takes bit of a time to get used to it because it has a different notion of accounts of different types some of which include Savings, Credit Cards, Insurance, Loan etc. It also has a concept of manual transactions which are nothing but transactions with a particular type of account. One feature which I like about Yodlee is that it gives you an option to register a future transaction. Every transaction has a flag called Cleared which indicates whether a transaction should be considered for summary of accounts or it should just be noted down for follow up.

Here is a screenshot of the cash flow analysis

image

There is a budgeting feature wherein based on actual spending the graph shows how much are the expenses towards each category. We  can also define our own budget and compare it against the actuals. There are some very good reports available for summary purposes. We can also set reminders for recurring as well as forthcoming payments.

The software also supports multiple currencies. Although the support is limited to few currencies we can hope for more currencies to be added later. There is a nice financial calendar which depicts the income and expenses for each day of a calendar month.

image

We can also record a transaction as split transaction. For eg. if we want to associate all the expenses incurred during a holiday trip then we can group all of them under one parent transaction but still spilt it further. The list of categories is also quite extensive and we can extend it as per our needs. 

For security reasons at the time of registration there are a set of questions asked. At the time of logging in one of these questions is asked randomly along with the username and password. I like this feature. The random question is asked very occasionally and ensures that the right person is accessing the information.

image

Conclusion

All in all Yodlee is a very simple web based personal finance manager. I like its features because the reports give very clear trends. Only feature I find missing right now is the double entry system. This means that if I have two accounts A  and B and I transact between them the balance is handled automatically by the system. This feature is supported in the windows based Money Manager EX. But Yodlee doesn’t seem to have support for this. Which means I need to record the transactions in both the places. Apart from that so far I am liking the features provided by Yodlee. The ability to keep track of expenses from anywhere in the world is a great one.

Do let me know if you come across something similar or better than this. Until next time Happy Programming Smile

Friday, December 24, 2010

My Bangalore Experience

Background

This post is like a retrospective of my stay in Bangalore and how I felt about living in this city. I was feeling sad about leaving Bangalore and just wanted to highlight some of the things which made me feel so. I’ll try to keep this very short but its quite possible that this might be one of my longest post.

A bit of professional history

I first came to Bangalore in the year 2000 for a training. I was working with NIIT as a faculty then and within couple of weeks of joining I was asked to attend a training for a MIS system called Encore. I was the only person from Goa in that training. It was the first time I had been to a metro outside of Goa. The trip lasted for about 2 weeks. I did not  get much chance to explore the city but whatever I visited it all looked very extravagant and big to me. A brief visit to M G Road and Brigade road was good enough to differentiate it from a visit to Miramar beach in Goa.

My second visit was as a student of NIIT one year later for my final semester of GNIIT program. This is the first time me and my best friend for last one decade Mr. Vishal Naik came together to Bangalore. We experience many of the things for the first time. Getting an accommodation with the help of an agent, staying in a PG with the landlord who coul speak only Kannada language and we did not understand a single word of what she was saying. It was all sign language then.

After few months we moved into an apartment with few other guys sharing the same. I had also started working in a company called Netgalactic Internet Solutions Pvt Ltd. I started my professional career here. This was the time when finding a job in a city like Bangalore was very difficult. People with far better educational qualifications from me and good grades compared to that of mine were finding it difficult to get a job. Some of the people who were selected in campus interviews had to face delays in joining and some were even unfortunate to have their offers taken back by the companies.

I had enrolled for the placement program of NIIT and I clearly remember the placement officer telling me that I should try for customer support and call centre based jobs. But somewhere deep inside me I knew that my heart lies in being a developer and in the profession of Software Engineering. I remember the words I told that person “I am willing to wait for the opportunity but I’ll not join call centre”. It was just a metter of getting one opportunity to show the world that I belong to this genre of software engineer. I am really thankful to Netgalactic which was later rebranded as the Skelta. If it was not for them I don’t know where I would have been today.

That was the beginning of my journey in Software industry. I learnt some of the very good things in a short span of time here. After about 18 months I joined Thomson Financials which was my first multi national company. The colleagues here were really fantastic. Even today after leaving this company after almost 3 years I remember the good times I had with some of the most wonderful people I have ever met. I got to attend many professional trainings while I was there with Thomson for about 3 years. Whenever I meet people from this company I still feel as if I am part of a family. I miss the work culture of this place very badly. I am yet to come across a better workplace than Thomson in my professional life so far.

In December 2007 I joined Tesco. I had an opportunity to travel to UK within 2 months and a short stay there helped me in many ways. This was beginning of a new journey for me. This is where I started with my exposure to Agile. If I can talk and write a little bit about Agile it all started here. I was the first member of the new Instore team that was getting formed in the Bangalore office of Tesco. I always took a lot of pride in introducing myself to almost everyone saying “ I am the first member of this team”. I am still proud of being associated with some of the best people I have worked with during my tenure in Tesco. These include both the people in Bangalore as well as UK offices. It would be hard to name individuals but I have made some of the best friends here and I value their contribution in helping me in becoming a better person in whatever I am right now at this moment in my life.

Some of my experiences in Bangalore

Apart from working in 4 different companies in the span starting from June 2003 to December 2010 I also tried participating in user groups and stuff like that. I was a member of Bangalore DotNet (BDotNet) group.

From my personal experience I can say that Bangalore is one of the best city to live in India. There are positives and negatives about each city wherever you go in this world. Instead of looking at the negatives I would like to highlight the positives that I feel are working in favor of Bangalore.

The climate is one of the best I have ever experienced in India. Coming from a hot and humid part of Goa, I found Bangalore to be very pleasant. Although off late with all the constructions going around in every corner of the city, it has lost most of its green cover. Compared tow hen I first came to Bangalore I hardly find any resemblance now. But still I would prefer it anytime compared to other places.

If you are in IT industry I doubt any other city in India can boast of so much opportunities. And this is yet to reach the saturation level. I am sure the IT expansion will continue for some more time in Bangalore. You’ll get opportunity to work with some of the best brains in the world if you are in IT industry.

I find the traffic very irritating factor. But then as I read once in an email, you can always take alternatives like coming in early before peak hours if you travel by your own vehicle to beat the traffic. Hopefully once the Bangalore metro starts operating we can see some difference in traffic conditions. Although I have not travelled much in the Volvo busses, whatever little I did I personally liked them. Tell me which other city in India has this facility?

Accommodation is slightly on the higher side but I don’t think anybody in IT industry gets paid so less that they can’t afford a reasonable living in Bangalore. With so many shopping malls coming up in every part of the city, entertainment and shopping are going to be easier.

Earlier when I came to Bangalore for the first time there was problem with the language. In some areas people did not understand Hindi or English. But now a days I find everyone right from auto drivers to maid servants communicating in Hindi. At least they understand  the language. If you know any one of the South Indian languages you can always manage in a city like Bangalore.

When I decided to relocate to Singapore and give my apartment for rent, I sent a mail to the mail group of the apartment residents. Within 2 minutes I got a call from someone asking me about the house details. Within 12 hours of shooting that mail I had already finalized the deal for renting the house. Even for selling the household items and my vehicle I could do it without taking help from any broker or agent just by posting online adds. Half of the items that I managed to sell were just through emails to my friends and ex colleagues.  This was the time I realized the true power of networking Smile. I can safely stake a claim that Bangalore has got the highest Internet penetration in India based on the number of queries I got for my bike and sofa set.

Conclusion

While I spent more than 9 years in Bangalore never did I feel anything bad about it. Right from the time when I was just a collage pass out with hardly any clarity about my future until recently where I could make certain decisions for myself and my family this city has always been wonderful to me. I liked the people, the environment. I don’t know what I liked so much about the place the first time I landed here. But from that time onwards somewhere deep inside my heart I wanted to make this place a place of my work. I never realized when I started saying Our Bangalore from their or your Bangalore. This city became the integral part of my life in a very short span of time. I learnt the tricks of my trade here. At this moment Bangalore is the city I love the most.

It was a very difficult decision to take to move out of Bangalore. Those who know me well would know that I don’t like to show emotions. Even in the worst situations, I have never felt so emotional anytime in my life before. But on the Sunday morning when I was about to leave from Bangalore I felt very sad. I felt I was leaving something which was very close to my heart. I am sure as and when I decide to relocate to India, it will be none other city than namma Bangalore. Thanks once again to all the wonderful people of this city who helped me achieve some of my dearest dreams and also in helping me to become a better individual at what I do.

Until next time wish you all a very happy Merry Christmas!!!

Friday, December 10, 2010

Interesting links for 11th December 2010

Agile

Hiring managers admit they need Agile PM - http://www.agilistapm.com/needed-leaders-not-yes-people/

Why projects fail – the real reason http://herdingcats.typepad.com/my_weblog/2010/12/why-projects-fail.html

Manager, nothing depends on you - http://blog.brodzinski.com/2010/12/nothing-depends-on-you.html

Estimating defects using Principled Negotiation -http://www.andrewfuqua.com/2010/12/estimating-defects-using-principled.html. A nice thoughtful post about estimating defect fixes.

ASP.NET

Favor privileges over roles - http://stevesmithblog.com/blog/favor-privileges-over-role-checks/

Using Raven DB with ASP.NET MVC - http://www.codecapers.com/post/Using-RavenDB-with-ASPNET-MVC.aspx

Miscellaneous

Ranking the popularity of programming languages - http://www.dataists.com/2010/12/ranking-the-popularity-of-programming-langauges/

Windows Phone 7 Experience - http://www.keithcredendino.com/2010/12/10/my-windows-phone-7-wp7-experience/

Interesting links for 10th December 2010

Agile

Becoming Lean – The Why, What and How - http://www.agilejournal.com/articles/columns/column-articles/3467. Nice post regarding Lean concepts and applicability of them to software projects.

Agile Testing Techniques – How to incorporate Testers into Agile teams - http://agilescout.com/agile-testing-techniques-how-to-incorporate-testers-into-agile-teams/

Should a manager know a language? Yes. One that enables communication with people -http://www.estherderby.com/2010/12/should-a-manager-know-a-language-yes-one-that-enables-communication-with-people.html

7 Tips to boost web application development - http://blog.outsystems.com/aboutagility/2010/12/7-tips-to-boost-web-application-development.html

DotNet

XML Serializable Generic Dictionary - http://weblogs.asp.net/pwelter34/archive/2006/05/03/444961.aspx

Using Lambda for sorting in C# - http://blog.adampresley.com/2010/using-lambda-for-sorting-in-c-net/

VS 2010

Visual Studio Explosion by Scott Hanselman http://www.hanselman.com/blog/VisualStudioExplosionVS2010SP1BETAReleasedAndContext.aspx

Windows 7 Phone

Windows 7 phone guide - http://blogs.msdn.com/b/jmeier/archive/2010/12/09/now-available-windows-7-phone-guide.aspx

Wednesday, December 08, 2010

Interesting links for 9th Dec 2010

 

Agile

Does adding more people increase the velocity? - http://agilescout.com/increase-your-velocity-by-adding-more-people/

But it just had to get done - http://www.leadingagile.com/2010/12/but-it-just-had-to-get-done/

WebMatrix

Building a sample Web Matrix application - http://msjoe.com/blog/posts/building-a-sample-webmatrix-application/

WPF & Silverlight

Dynamically generating controls in WPF & Silverlight - http://10rem.net/blog/2010/12/08/dynamically-generating-controls-in-wpf-and-silverlight

A very nice post by Pete Brown on dynamically generating controls in WPF & Silverlight. The post also talks about handling events for such controls.

Entity Framework

Entity Framework Code First CTP5 Release - http://weblogs.asp.net/scottgu/archive/2010/12/08/announcing-entity-framework-code-first-ctp5-release.aspx

EF Feature CTP5 released - http://blogs.msdn.com/b/adonet/archive/2010/12/06/ef-feature-ctp5-released.aspx

ADO.NET team code walkthrough of EF Code First - http://blogs.msdn.com/b/adonet/archive/2010/12/06/ef-feature-ctp5-code-first-walkthrough.aspx

Profiling Database Activity in the Entity Framework - http://msdn.microsoft.com/en-us/magazine/gg490349.aspx. Wonderful post by Julie Lerman on profiling database activities with EF. She also talks about few tools available to do so.

ASP.NET MVC

Optional Razor sections with Default Content - http://blogs.msdn.com/b/marcinon/archive/2010/12/08/optional-razor-sections-with-default-content.aspx

ASP.NET
Using ASP.net Output Caching with WCF Data Services - http://blogs.msdn.com/b/peter_qian/archive/2010/11/17/using-asp-net-output-caching-with-wcf-data-services.aspx

Phil Haacks suggested links for NuGet - http://haacked.com/archive/2010/12/07/nuget-roundup-december-2010-edition.aspx

Detecting postback or refresh in ASP.NET - http://www.c-sharpcorner.com/UploadFile/archak/704/Default.aspx

Miscellaneous

Clean Code : Too much of Good Thing? - http://xprogramming.com/articles/too-much-of-a-good-thing/. This is my personal favorite. Ron Jeffries does a great job in discussing about clean code. I love the last para of this post which says

“Bad code will slow you down if you write it for even a few days. If you write bad code long enough to get an actual product out, you will deliver that product more slowly, and with more bugs, than if you had gone clean.” 

I have personally experienced this situation and would request every developer who is serious about their work and passionate about their skills to read the book on Clean Code by Bob Martin.

Scott Hanselman on Backing up the data to various destinations - http://www.hanselman.com/blog/BACKUPYOURCRAPMissingOperatingSystemBackupsDiskImagesHomeServersBootRecBootMgrRebuildBCDFixBootAndProblemsPlural.aspx

Interesting links for 8th Dec 2010

 

DotNet

Everything you ever wanted to know about Deep-Vs-Shallow copy in DotNet - http://www.csharp411.com/c-object-clone-wars/

This is very nice article about different ways of performing deep and shallow copy in DotNet as well as the difference between the two methods.

LINQ secrets revealed : Chaining & Debugging - http://www.simple-talk.com/dotnet/.net-framework/linq-secrets-revealed-chaining-and-debugging/

ASP.NET

ASP.NET and Entity Framework series – Getting started part 1 - http://www.asp.net/entity-framework/tutorials/the-entity-framework-and-aspnet-–-getting-started-part-1

Nice post about using Entity Framework with ASP.NET.

Miscellaneous

Train your brain everyday in just 10 minutes - http://www.lumosity.com

Career development as a Software Developer without becoming a Manager http://alpascual.com/post/2010/12/07/Career-development-as-a-Software-Developer-without-becoming-a-manager.aspx.

This post is pretty close to what I believe in. The author has done a far better job than what I could have if I were to write a similar post.

Tuesday, December 07, 2010

Interesting links for 7th Dec 2010

Background

There are different sources of information from where we get to know about various things. In this age of hi-tech gadgets and Web 2.0 the channels of communications just keep multiplying day by day. I myself use social media like Twitter and Facebook along with Orkut a lot. Twitter has overtaken my RSS feeds in Google Reader with respect to the links to various topics I am interested in.

I used Google Reader mainly to subscribe to the content of my interest. Most of the technical stuff I manage to keep track with the help of Google Reader. StackOverflow is my favourite go to site for technical issues and problems.

Although I use Delicious to store my favourite links online, still it becomes difficult to manage the flow of information. I remember reading a daily post by one of the blogger (apologize because I don’t remember his name right now) who used to put a summary of links from twitter of all the interesting posts. Off late I have not seen him blog. I am missing his links very badly.

For the benefit of my friends and for my own reference I thought of following a similar practice. I plan to put all the useful links that I came across during a day in a blog. This is the first part of that series.

Interesting links for 7th December 2010

Agile

http://www.leadingagile.com/2010/12/lean-software-systems-conference-call-for-papers-registration-open/

http://www.rallydev.com/agileblog/2010/12/is-agile-the-key-to-building-high-assurance-software/

Windows phone 7

A small but important UX improvement for ScrollViewer on the Windows Phone – Jeff Wilcox
http://www.jeff.wilcox.name/2010/12/betterscrollviewer/

Miscellaneous

Strategies for becoming better programmer – J P Boodhoo
http://blog.developwithpassion.com/2010/12/strategies-for-becoming-a-better-programmer. JP Boodhoo is the one of the guys who has some very good videos recorded on DNRTv website related to Design Patterns.

 

Conclusion

Couple of colleagues and some of the ex-colleagues have been requesting me to share the links with them for quite sometime. I think this would be a better option compared to sending an email everyday. I am planning to blog about interesting and useful links related to technologies that I am currently working on. Mostly this will involve stuff like Agile, ASP.NET MVC, WCF, DOTNET, WPF, Silverlight, ORM, JQuery, HTML 5 etc.

Until next time Happy Programming :)

Monday, December 06, 2010

Introduction to Design Patterns

Sometime back I had given a presentation to my team regarding introduction to Design Patterns. I covered the topics like pre-requisites for learning and implementing Design Patterns, principles which drive developers to make use of Design Patterns including SOLID principles etc.

I have uploaded the slides used during the presentation to dropbox. You can download it Design Patterns.pptx. I had used one of the simplest design pattern Singleton as an example to show the demo.

The complete source code of the project related to Singleton is available SingletonPatterDemo.zip

Until next time Happy Programming :)

Friday, December 03, 2010

Powertools – December 2010

Background

Back in October 2009 and November 2009 I had written 2 blog posts about the powertools I have been using. There have been some additions to those tools off late. I thought of listing them down for my own future reference.

Visual Studio 2010 Ultimate Edition

With the release of Visual Studio 2010, I have upgraded my development IDE from Visual Studio 2008 to the 2010 Ultimate edition. I love the extensions manager feature along with the performance enhancements done by Visual Studio team. Instead of mixing all the extensions that I use for Visual Studio 2010 in this post, I’ll leave it for a dedicated blog post in itself.

Resharper (VS Add in)

Resharper is indispensible tool for developers. It helps in improving the productivity of developers by many folds. I have been using it for past few months. I am making an attempt not to touch the mouse for any development related tasks. With Resharper you can almost get there. I like the features of this add in like real time code analysis. In my opinion it’s a must for every developer.

Apart from the basic Reshaper add in there are supplementary ones which work along with Reshaper like StyleCop for Resharper. It’s a treat when you have both of them working together within VS IDE. I love TDD and try as much as possible to implement Agile methodology. Resharper is a great tool for refactoring and building software using TDD.

Tweetdeck (Twitter client)

Over the past few years social media has become a very integral part of everyone's lives. I use tweetdeck which is a twitter client. It also has integration with other social media sites like facebook, linkedin, foursquare etc. 

TweetDeck

Sesmic Desktop (Twitter client)

Along with TweetDeck, I also tend to use Sesmic Desktop once in a while. One thing I don’t like about Tweetdeck is the size of the columns. Its kind of fixed. If I use Sesmic Desktops single column view I get a nice full screen updates for any of the accounts that I have set up with Sesmic. In terms of capabilities both these twitter clients are almost similar.

Sesmic Desktop 2

Windows Live Writer 2011 (Blog publisher)

For quite some time I was using the Windows Liver Writer 2009 version. After upgrading my hard disc recently, I upgraded to the latest version of the Windows Liver Writer 2011. Its bit surprising that this is in production before 2011 Smile. Anyways that’s for Windows live team to decide. I like the changes to the user interface. Especially the toolbars which follow the same convention like that of Office suite like MS Work and MS Excel. The Ribbon is one of the nice features. I think Windows Live Writer is one of the best blog editing and publishing software available for free right now.

RocketDeck (Desktop / window manager)

This is a nice little utility to manage the taskbar items. It hides all the active programs into a dock and gives a Mac like menus and feel to a Windows desktop. We can drag and drop the commonly used files and program shortcuts onto the dock. This leaves the desktop much more cleaner and gives a very elegant look.

iTunes 10 (Music playlists)

I have been using iTunes to manage the playlists for my iPod. Even when I am not using iPod, I tend to listen to music on my laptop. I like the simple user interface of iTunes. I also prefer to use the smart playlist feature of iTunes.

Skype (Communication / Video Chat)

I have tried various chat clients including Yahoo messenger, MSN messenger, gTalk and still continue to use them. But compared to all those I like Skype. Ability to store previous chat history is one feature which I find very helpful. I have tried video chat with Yahoo messenger, gtalk and Skype. In skype it seems to be very clear and audio quality is also good compared to others.

Conclusion

I am sure many of you would be using the same utilities. There might be some utilities which are better than the ones I am using. I would like to hear about them. Until next time Happy Programming Smile

Wednesday, December 01, 2010

Money Manager

Background

Since year 2003, I have been using Microsoft Excel as a tool for keeping track of all my financial transactions. I used a workbook containing 12 worksheets for each month. It also contained another worksheet for credit card related transactions. There were few graphs and charts I had used to summarize the transactions. I had also decorated some of the sheets with coloured columns to make them look intuitive. All these while I was looking for some piece of software which could help me keep track of the same using a much better user interface other than Excel.

My colleague Ranjith directed me to a site called AlternativeTo. This was actually in relation to one of my status update on the social networking site Facebook with regards to managing playlists for music library. Accidently I came across this personal finance management software and thought of trying it.

Here are some of the options for software which can be used for managing personal finances http://alternativeto.net/software/money-manager-ex/. I tried couple of them before settling down on Money Manager Ex. Its free and open source. There are other options like Microsoft Money or iBank which are commercial products. But for a single user needs I think Money Manager is sufficient. I think Microsoft Money is no more available for sale. HomeBank is another option which I looked at.

Features of Money Manager

Support for Multiple accounts – Money Manager supports multiple account. I have couple of savings accounts in different banks. Using excel it was difficult to get to know the details related to a particular account. Money Manager gives a very good user interface for managing multiple accounts.

Support for Stock – Money Manager can also be used to track investments in stock market.

Recurring transactions -   Most of us use online banking for payment of various utility bills as well as other things like insurance premiums etc. Money Manager has a option of setting up recurring transaction and reminders will be shown when the due date approaches.

Categories -  Money Manager comes with a set of pre-built categories for income and expenses like Automobiles, Bills, Homeneeds, Income etc. We can define our own categories.

Budget – Money Manager allows us to come up with a budget for a complete year. Based on the categories we have defined in the categories section, we can set the budget for each of them. Here is a screen shot of the budget setup screen.

Budget screen

Simple reports – There are some basic reports like Summary of Accounts, Where the Money Goes, Where the Money Comes From, To Whom the money goes, Income Vs Expenses, Transaction Report, Budget performance etc.

Summary

For my current needs Money Manager serves the purpose of giving up to date information about the state of my finances in a single window. I like the simplicity of the user interface and ease of use. The reports are also very minimal but they help in getting us the kind of information we need. I personally like the budgeting feature a lot since it can be used to plan for short term and long term financial needs. Only thing I miss in Money manager is the support for handling credit cards related stuff. This was available in the HomeBank software. But the user interface wasn’t really appealing. I am sure being part of open source community, Money Manager will have the feature for supporting Credit Card related transactions very soon.

Monday, November 29, 2010

Overview of functional testing

Recently I did a presentation for my team on the overview of functional testing. Here are the slides I used during this presentation. I thought of sharing this with my blog readers. It also acts as a reference for me in future.

You can download the slides from the dropbox.

Feel free to drop in your comments.

Until next time Happy Programming :).

Monday, November 15, 2010

Use Should Assertion Library to write clean Unit Tests

Background

Back in September 2009, I had written a blog post about comparison of unit testing frameworks. In that post I had compared NUnit and MS Testing unit testing frameworks for Dot Net. For the purpose of demonstration I had taken a sample BankAccount class with very basic methods like Deposit and Withdraw. I had used the assertions from both these unit testing frameworks. There were minor differences in syntax between the two. In this post I am going to use a library named Should.

Should is a unit testing framework agnostic assertion library. This means that the asserts used to verify the behavior of system under test can remain the same even if the testing framework changes. To take an example let me take a code snippet from the test project using MS Test framework.

            Assert.AreEqual<int>(accountID, bankAccount.AccountID);
            Assert.AreEqual<string>(accountHolder, bankAccount.AccountHolder);


The same test written in test project using NUnit is



            Assert.AreEqual(accountID, bankAccount.AccountID);
            Assert.AreEqual(accountHolder, bankAccount.AccountHolder);

Recent versions of NUnit also supports fluent asserts and the above lines of code can be re written as

            Assert.That(bankAccount.AccountID, Is.EqualTo(accountID));
            Assert.That(bankAccount.AccountHolder, Is.EqualTo(accountHolder));


This syntax reads far better than the earlier one. But still it is not very good. It looks as if we are still talking in terms of compiler language and not in terms of domain or business terms. Should helps us overcome this limitations by providing a very simple assertions.



How to use Should library



First of all we need to get the Should.dll and Should.Fluent.dll if we wish to use the fluent syntax. Both these dlls are freely available at the codeplex project site http://should.codeplex.com. Without wasting too much time lets see how can make use of this library in our tests.



Here is how I would refactor the MS Test project code to accommodate assertions using Should



        [TestMethod]
        public void AccountConstructorTest()
        {
            // Arrange - NA
            const int expectedBalance = 1000;

            // Act
            Account bankAccount = new Account();

            //// Assert
            // Assert.IsNotNull(bankAccount, "Account was null.");
            // Assert.AreEqual<int>(expectedBalance, bankAccount.AccountBalance, "Account balance not mathcing");

            bankAccount.ShouldNotBeNull("Account was null");
            bankAccount.AccountBalance.ShouldEqual(expectedBalance, "Account balance not matching");
        }


As we can see I have commented the old code which was using MS Test style asserts. Lets check the refactored code which was developed using NUnit unit testing framework



        [Test]
        public void AccountConstructorTest()
        {
            // Arrange - NA
            const int expectedBalance = 1000;

            // Act
            Account bankAccount = new Account();

            // Assert
            // Assert.IsNotNull(bankAccount, "Account was null.");
            // Assert.AreEqual(expectedBalance, bankAccount.AccountBalance, "Account balance not mathcing");

            bankAccount.ShouldNotBeNull("Account was null");
            bankAccount.AccountBalance.ShouldEqual(expectedBalance, "Account balance not matching");
        }


If you compare the two code snippets you can see that the test code looks exactly the same.



I have refactored the code in both the MS Test as well as the NUnit projects and uploaded them for the reference.



Conclusion



I am obsessed with clean code and unit testing. In general I like to follow Agile practices as much as possible and believe that unit testing is at the heart of Agile development. These small little things go a long way in making developers life easier. With libraries like Should it becomes very easy to switch unit testing framework from NUnit to others like MS Test or XUnit.



People who are familiar with Behavior Driven Development (BDD) will be able to relate better to this style of asserts.



If I were to port all the tests written using MS Test and Should assertion library over to NUnit framework probably the only change I would need to make is to change the attributes used to decorate the test classes and methods. This relieves us from making use of framework specific stuff like Collection Asserts which are available in NUnit. We are no more bound to a specific testing framework.



Should also supports a very fluent assertion syntax. I’ll leave it probably for a future post. If you can’t wait till then I would suggest have a look at the Should documentation and it should be fairly easy to use it if you have any other libraries which supports Fluent interface like Automapper or Rhino Mocks.



As always I have uploaded the complete source code to dropbox as BankAccountWithShouldLibrary.zip.



Until next time Happy Programming :)

Monday, October 11, 2010

Entity Framework : Part 9 Use Stored Procedures with Entity Framework

Background

This is the ninth part of the Entity Framework 4 learning series. In this post I’ll be demonstrating how to use Stored Procedure with Entity Framework. If we are working on a green field project, it becomes easier to implement concepts like model first development. Using this approach we can define our entities first and based on the entity model we can arrive at the database model required for persisting the data.

In many cases we already have a set of database objects in place. We might have spent lot of time writing complex business logic in database objects such as Stored Procedures and Views. From a return on investment (ROI) point of view it might make sense to reuse them to reduce the time required to convert the complex logic into an object oriented code.

Entity Framework 4 supports stored procedures and views as you might have already seen if you have been following the complete learning series. This is presented as an option in the wizard which prompts us to select the database objects which we want to convert into entities during the generation of entity model.

Pre Requisites

I’ll be reusing the Northwind sample database we have been using all this while for this series. If you don’t have a copy of the database I would recommend you follow the steps from first part of this series to set up the database.

How to use Stored Procedures with Entity Framework 4

If we want to use a stored procedure, we need to follow the steps similar to all other earlier posts until we reach the step in the wizard where we are asked to select the database objects as shown below

select sp

I have selected the 3 stored procedures

  1. Sales By Year
  2. SalesByCategory
  3. Ten Most Expensive Products

After finishing the wizard, you might notice that the designer file is empty. Unlike on previous occasions where we would get to see the list of entities for the selected tables we do not get anything for the selected stored procedures. We need to access the model explorer window which displays the stored procedures as shown in the screenshot

model browser

If the model browser is not visible along side solution explorer we can navigate to it by selecting View –> Other Windows –> Entity Data Model Browser. In order to use the stored procedure in Entity Framework 4, we need to use a feature called Function Import. What this does is it tries to map the stored procedure to a function. We can invoke the stored procedure as if we would be invoking a function. So lets look at the simplest stored procedure which is Top_Ten_Most_Expensive_Products.Select this stored procedure from the model browser and right click which will display the context menu. Select Add Function Import option which shows a popup with various options

function import

This popup has lots of options like name of the function, return values which can be a list, a scalar value, a complex type or an entity which is already present in our entity model. If I am not sure what columns are returned by the stored procedure , I can click on the Get Column Information button to query the metadata about the stored procedure itself.

For the purpose of this demo I have created a temporary class which can be done by selecting the returns Complex option and clicking on the Create New Complex Type button towards the bottom. This would add one item each to the Function Imports folder and Complex Types folder under the model browser.

Now I can query the database using these functions with the help of an object context like

            NORTHWNDEntities context = new NORTHWNDEntities();

 

            var topTenMostExpensiveProducts = context.TenMostExpensiveProducts();

 

            foreach (var expensiveProduct in topTenMostExpensiveProducts)

            {

                Console.WriteLine(expensiveProduct.UnitPrice);

            }


I started off as usual with an instance of NorthWNDEntities class. I made a call to the TenMostExpensiveProducts function and stored the results in an variable. I loop over the results to display the UnitPrice of the top ten most expensive products.

If you run the project now you should be bale to see the ten most expensive products from the database. This was a simple stored procedure which did not take any input parameters.

Lets look at the other stored procedure which requires input parameters. We’ll use the Sales_By_Year which requires Begining_date and Ending_date parameters to be passed as inputs. We’ll import this stored procedure into a function as

import sales by year

I’ll again store the resultset into a complex type. In order to execute this stored procedure I’ll follow

            var salesByYear = context.Sales_by_Year(DateTime.Now.AddYears(-20), DateTime.Today);

 

            foreach (var salesByYearResult in salesByYear)

            {

                Console.WriteLine("{0} - {1}", salesByYearResult.Year, salesByYearResult.Subtotal);

            }

If you execute the program now, you’ll be able to see the year and the sub total for those years in the results.

Conclusion

As we saw from the code above, its very easy to invoke a stored procedure using Entity Framework 4. We can call all types of stored procedures and handle different types of results like lists, scalar values etc. Here I have demonstrated using the results directly, but we can use options like filtering the results what the stored procedure returns. I’ll leave it to the viewers to try those filter options to get better understanding of the framework.

For most part of my career I have had the privilege of working on green field applications. I personally follow the TDD approach more. Since it becomes very difficult to test the logic residing in database objects like stored procedures, triggers and views I tend to stay away from them. Also debugging stored procedures is difficult. Another disadvantage of using stored procedures could be that the application logic is spread across different layers apart from business logic layer or service layer. If we are using any ORM tools like Entity Framework 4 or NHibernate I would try and stay away from stored procedures as much as possible.

As always I have uploaded the compete working solution to dropbox which can be downloaded as Part9_StoredProcedures.zip

Until next time Happy Programming :)

Further Reading

Here are some books I recommend related to the topics in this post.

  

Friday, October 08, 2010

Unit Test Background Worker

Background

I was refactoring a piece of code with a colleague when we encountered a multi threaded code. We were refactoring some unit tests. As part of the test we needed to cover this code which was using BackgroundWorker to execute a long running task and updating the user interface once the background thread had completed its job. In this post I am going to demonstrate how to unit test the multi threaded code.

 

Scenario for using Background Worker

Assume that we have a requirement to fetch some data using a service and display it in the user interface. The user interface calls a method on a object which delegates the call to the service. While the service is processing, we do want the user interface to be responsive and give a visible feedback to the user. We are making use of the MVP pattern to separate the concerns in our project. So the view is abstracted and we program to an interface. So we are really not worried about how the view display the information to the user. We can just set a property on the view to display something like an hourglass symbol.

We call a method on the background thread using Background worker. In MVP the presenter takes care of handling such logic. So the model would abstract the part which relates to fetching the data from the data source. Lets assume that we have a repository which does this job for us. Based on these things lets start building the code.

 

Code which makes use of Background Worker

For the kind of scenario described above you’ll have a Windows or Web UI based application with a front end developed using either WPF, Winforms, WebForms or ASP.Net MVC. For simplicity I have created a simple console application just for demo purpose. I am not going to show any visual stuff hence I decided to use console application.

I have created a ProductPresenter which is defined as

        private readonly IProductRepository productRepository;

        public ProductPresenter(IProductRepository productRepository)
        {
            this.productRepository = productRepository;
        }

        public IProductListView ProductListView
        {
            get;
            set;
        }

        public void GetAllProducts()
        {
            BackgroundWorker worker = new BackgroundWorker();

            worker.DoWork += new DoWorkEventHandler(worker_DoWork);

            worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(worker_RunWorkerCompleted);

            ProductListView.DisplayHourGlass = true;

            worker.RunWorkerAsync();
        }


The constructor has a dependency on IProductRepository which I’ll mock using RhinoMocks during testing phase. If you look at the complete source code you’ll notice that I have not implemented the IProductRepository interface. From the point of TDD it makes sense because I am programming to an interface. I have property ProductListView which is of type IProductListView. This is also an abstraction of the view and I do not have any concrete code for ProductListView.



Then comes the method which is the point of contention for this blog post GetAllProducts. This method creates an instance of the of BackgroundWorker class available in the DotNet Framework 2.0 onwards. It assigns the delegate for the method which will run a piece of code on the worker or background thread using DoWork event. We have assigned a method named worker_DoWork. Assume that the long running process of contacting the service and fetching the data will happen in this method.



We also need to specify the callback method which will perform the UI updates once the background worker has finished its job. This is achieved by subscribing to the RunWorkerCompleted event of the background worker. Once the background thread has completed its work it calls this method back on the main thread. This can be used to update the controls on the user interface in a real life application. In my case I have abstracted the view. When the long running task is completed I hide the hourglass symbol displayed on the view.



Next question you’ll ask me is when did we show the hourglass symbol. We would do this just before starting the worker thread using the background workers RunWorkerAsync method. The background worker spawns a thread only after we call the RunWorkerAsync method. 



The worker_DoWork mthod implimentation looks like



        private void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            e.Result = productRepository.GetAllProducts();
        }


We use the injected product repository to make a call to GetAllProducts on the service. We assign the result back to the DoWorkEventsArgs which gets returned to the method which subscribes to the RunWorkerCompleted event. This method is defined as



        private void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            ProductListView.DisplayHourGlass = false;

            ProductListView.Products = (IList<Product>)e.Result;
        }


The method is responsible for updating the product list on the user interface. Finally the Product is a domain object or the model which has few properties like



    public class Product
    {
        public int ProductId { get; set; }

        public string Name { get; set; }

        public string Description { get; set; }

        public int UnitPrice { get; set; }
    }


 



Unit Test Background Worker



Lets start with the unit tests. Here is the code which mocks the dependencies using Rhino Mocks and creates an instance of the presenter class which happens to be our system under test (SUT).



        private ProductPresenter presenter;

        private MockRepository mocks;

        private IProductListView mockView;

        private IProductRepository mockRepository;

        [TestInitialize]
        public void Setup()
        {
            mocks = new MockRepository();
            mockView = mocks.StrictMock<IProductListView>();
            mockRepository = mocks.StrictMock<IProductRepository>();

            presenter = new ProductPresenter(mockRepository) { ProductListView = mockView };
        }


I have created a mock view and a mock repository. I just need to test the presenter method.



        [TestMethod]
        public void GetAllProductsTest()
        {
            IList<Product> expectedProducts = new List<Product>
                {
                    new Product { ProductId = 1, Description = "Parle G Burboun Biscuit", Name = "Burboun Biscuit", UnitPrice = 15 },
                    new Product { ProductId = 2, Description = "Amul Ice Cream", Name = "Ice Cream", UnitPrice = 45 }
                };

            mockView.Expect(mv => mv.DisplayHourGlass).PropertyBehavior();

            mockRepository.Expect(mr => mr.GetAllProducts()).Return(expectedProducts);

            mockView.Expect(mv => mv.Products).PropertyBehavior();

            mocks.ReplayAll();

            presenter.GetAllProducts();

        }


In this test I have created 2 products which the service call will return to the presenter. I am expecting a call to the DisplayHourGlass property on the view and I have mocked it by setting the property behavior. I am also setting an expectation for the GetAllProducts method to be called on the mock repository which will return me the expected products.  And finally I am setting an expectation on the Products property of the view. If you execute the test now it passes as can be see from the screenshot below.



passed test without verify



But as per the TDD rules we are missing a point here. We haven’t verified the behavior of this test. After we executed the method we should have done an Assert as part of the AAA theory. Here I can do an assert on the view’s Products property to check that the expected products and actual products match. I’ll leave it to the readers to implement it.



But the other point we are missing here is that we haven’t verified that all our expectations have been met during the execution of the test. I can do it in the Teardown method as shown below



        [TestCleanup]
        public void Cleanup()
        {
            mocks.VerifyAll();
        }


calling VerifyAll on the mock repository will ensure that all the expectations have been met. Try running the test once again and you’ll most likely get the error as shown below



image with rhino mock error



If you look carefully it says that ExpectationViolationException. Expected #1, Actual 0. And the expectation under consideration happens to be IProductRepository.GetAllProducts. What could be the reason for this. We have set the expectation but its not getting called.



Any guesses? This happens because of the threading. If you go back to the presenter and see which piece of code calls the productRepository.GetAllProducts method, it happens to be the one which runs on the background worker thread. In our case we are calling this code from the test runner. Because the call to DoWork method is asynchronous, our test runner does not wait for it to complete its work. The test runner continues with the next statement. And the teardown method gets invoked. In the teardown we are verifying that all the expectations have been met. It is possible that the background thread did not execute the service call in this duration and the expectation is not met. Hence we get this error while running this multi threaded code.



The simplest fix for this problem is to purposefully introduce some delay between the calling of the method on the presenter and the teardown method. This allows the background thread to complete its work and the callback method gets executed on the presenter as expected. After a short delay the teardown or cleanup is also executed.  You can modify the test as shown below and rerun to see that it fixes the exception.



        [TestMethod]
        public void GetAllProductsTest()
        {
            IList<Product> expectedProducts = new List<Product>
                {
                    new Product { ProductId = 1, Description = "Parle G Burboun Biscuit", Name = "Burboun Biscuit", UnitPrice = 15 },
                    new Product { ProductId = 2, Description = "Amul Ice Cream", Name = "Ice Cream", UnitPrice = 45 }
                };

            mockView.Expect(mv => mv.DisplayHourGlass).PropertyBehavior();

            mockRepository.Expect(mr => mr.GetAllProducts()).Return(expectedProducts);

            mockView.Expect(mv => mv.Products).PropertyBehavior();

            mocks.ReplayAll();

            presenter.GetAllProducts();

            Thread.Sleep(TimeSpan.FromMilliseconds(3));
        }


Conclusion



It is always difficult to unit test the multi threaded code. It took us almost a day to find out what was causing this problem. Because in the debug mode things would work fine and after removing the breakpoint we would encounter exception. After putting the test runner thread to sleep everything started working fine.



Please note that I have used a delay of 3 milliseconds. But if you have complex logic it might take you a little bit longer to execute them on the worker thread. You might need to change that value to a different one based on trail and error method.



As usual I have uploaded the complete source code to dropbox which you can download BackgroundWorkerUnitTest.



There might be a simpler way of unit testing a background worker related code. I would love to know about it. Until next time Happy programming :)

How Travis CI saved my time?

Background Some time back I created an Ansible playbook to install software and setup my Mac Book Pro . I put the code for this on GitHub . ...