Started working with Ruby on Rails

For a current project that I am working on I had to start working with Rugy on Rails. My first impression of both Ruby and Rails has been quite nice, although still lacking the good debugging capabilities like visual studio provides, but I hope that slowly and gradually I will be able to manage that better as well.

The tip of the day for Ruby is to use .blank? to check if an object is null rather then using .nil? or .empty? , this approach is suppose to be much better to use and suppose to be the prefered choice going forward with ruby.

Tip picked up from the forum post http://www.railsforum.com/viewtopic.php?id=18292

 

Reblog this post [with Zemanta]

CSharp Templating Engine investigation

    In order to render html from our C# REST service we had to look into templating engines available in C#, since we wanted our generated html to be altered on the fly.

    We came across the following

    4 View engines exist in

    MVCContrib project

    Which are

  1. Brail
  2. NHaml (NHaml has been moved from MvcContrib into a separate project)
  3. NVelocity
  4. XSLT
  5. In addition we found the following two engines

    Spark

    StringTemplate and StringTemplateMVC

    Asp view from Castle project

    Each engine aims to keep the focus on the generated html, and the dynamic contents are inserted into the html.

    Our decision about which language to use was based on the following conditions

  6. Be able to use the same templating / view engine in asp.net MVC.
  7. Do not have to learn a new templating language if possible.
  8. Be able to keep the business logic separate from the view templates.
  9. Have the least learning curve to implement a basic use case.
  10. Has enough capability to be able to use advance features and capabilities.
  11. Should be extendable if needed.
  12. Should have a very strong developer community to support and sort out the bugs with.
  13. Should be in use for sometime to be able to determine its stability.
  14. After doing quite some investigation we decided to go for Spark templating engine, primarily because of the capability of being able to use c# like syntax in templates, and the initial configuration and setup was very simple and easy.

Reblog this post [with Zemanta]

Visual Studio 2008 Internal Web Server stopped working in Vista

I have been debugging perfectly fine using Visual Studio 2008 using visual studio internal web server, but suddenly today it stopped working (maybe due to windows update, but still not sure about the cause of this suddenly not working), On starting the debugger IE came up with a blank page saying the page could not be opened, same happened in firefox when I tried to use that for debugging, It took me sometime to realize that this was due to a vista Issue, IPv6 gets installed with Vista and cannot be un-installed or disabled easily, and that creates the problem. I followed this post to sort out my issue.

The main action that sorted this out for me was to edit the hosts file in C:\Windows\System32\drivers\etc

and change the localhost entry from

::1             localhost

to

:::1             localhost

one more Collen.

So if you are having this issue as well, do not pull your hair out but follow the post linked above or change your host file entry for localhost as explained above.

MovableType Invalid login error on XML-RPC call

I have worked with XML-RPC calls in the past to interact with MT in the past but after release of version 3.2 onwards I did not get a chance to work with it again, until recently. I used the Argotic Syndication Framework to interact with the MT XML-RPC. However I was constantly getting ‘Invalid login’ error even when I used the MT administrators details. I even tried using Fiddler to make sure that it was nothing in my code that was creating the issue.  The method mt.supportedMethods returns all supported methods perfectly fine, however metaWeblog.getRecentPosts returned invalid login error.

After doing a lot of debugging I finally found out this documentation which indicates that each user has got a separate password for remote API.  Once I changed the password for the user I was using to connect through the remote API, all started to work okay.

The way to alter this password is as under.

1. Log into MT
2. Click on your username in the top navbar to go to your profile
3. Scroll down to the bottom where you see “API Password”
4. Input the password of your choice and save. For security reasons, it should be different from your normal password
5. Use that password in your client software

Integration testing In .NET

According to Wikipedia

‘Integration testing’ (sometimes called Integration and Testing, abbreviated I&T) is the phase of software testing in which individual software modules are combined and tested as a group. It follows unit testing and precedes system testing.

Integration testing takes as its input modules that have been unit tested, groups them in larger aggregates, applies tests defined in an integration test plan to those aggregates, and delivers as its output the integrated system ready for system testing.

Strategies

You can do integration testing in a variety of ways but the following are three common strategies:

· The top-down approach to integration testing requires the highest-level modules be test and integrated first. This allows high-level logic and data flow to be tested early in the process and it tends to minimize the need for drivers. However, the need for stubs complicates test management and low-level utilities are tested relatively late in the development cycle. Another disadvantage of top-down integration testing is its poor support for early release of limited functionality.

· The bottom-up approach requires the lowest-level units be tested and integrated first. These units are frequently referred to as utility modules. By using this approach, utility modules are tested early in the development process and the need for stubs is minimized. The downside, however, is that the need for drivers complicates test management and high-level logic and data flow are tested late. Like the top-down approach, the bottom-up approach also provides poor support for early release of limited functionality.

· The third approach, sometimes referred to as the umbrella approach, requires testing along functional data and control-flow paths. First, the inputs for functions are integrated in the bottom-up pattern discussed above. The outputs for each function are then integrated in the top-down manner. The primary advantage of this approach is the degree of support for early release of limited functionality. It also helps minimize the need for stubs and drivers. The potential weaknesses of this approach are significant, however, in that it can be less systematic than the other two approaches, leading to the need for more regression testing.

Finding a Tool


While trying to find a good framework for integration testing I came across FIT framework for integration testing , but considering the amount of support and documentation available for the framework I decided not to investigate it further. So using Nunit for Integration testing seems to be the best way to go about doing integration testing at this time.

In order to use Nunit for Integration testing I found one good blog post here and another one here however it does not give a definite answer of what’s the best way to go about Integration testing.

Spring framework gives some guidance how to use integration testing for the database objects and spring objects but I think for the moment if we mock up the spring framework tests then we should be fine.

In case of using Nunit to do integration testing , and keep the tests separate there are two suggested methodologies

1. Categories the Integration tests and Modular tests separately and then one can use Nunit to test each category.

2. Keep two projects separately one, for Unit tests and one for integration tests.

http://www.testdriven.net/ is a useful .net tool that allows to integrate nunit within visual studio.

A quick comparison of the testing frameworks for .net are listed here

A good checklist of unit testing practices to consider for doing Unit testing is listed here.

Conclusion :

It seems that at this time the best way to go about Integration testing is to use Nunit or Xunit whatever one prefers as a testing framework, and adopt either one of the ways listed above to separate your unit tests from integration tests.

Getting Started With Windows Azure Development

In order to start working with Windows Azure Development following components are required

Windows® Azure™ Software Development Kit

Windows Azure Tools for Microsoft Visual Studio

Login to Windows Azure services

Windows Azure Consists of following four main components

  • Windows Azure: Provides a Windows-based environment for running applications and storing data on servers in Microsoft data centers.
  • Microsoft
    .NET Services: Offers distributed infrastructure services to cloud-based and local applications.
  • Microsoft
    SQL Services: Provides data services in the cloud based on SQL Server.
  • Live Services: Through the Live Framework, provides access to data from Microsoft’s Live applications and others. The Live Framework also allows synchronizing this data across desktops and devices, finding and downloading applications, and more.

    In order to develop a hello word web cloud service I installed the SDK and found the following Visual Studio templates installed in my VS 2008.

    In order to run the Service Bus Echo sample I compiled the sample placed at C:\Program Files\Microsoft .NET Services (Nov 2008 CTP) SDK\Samples\ServiceBus\GettingStarted\Echo\CS35

    Which is a simple Echo application. On running the application I was able to connect to my Windows Azure online Service bus end point by providing the solution name and the password for the solution set in the service Credentials interface. Similarly I was able to connect to the Service using the client application and the resulting echo sent from the client application was Echoed on the Server application. So in short the client and server where able to talk to each other through an intermediate service bus provided by windows Azure services. If this client and server live in separate data centres behind firewall or whatever, as long as they can access the internet they will be able to communicate to each other.

    This all looks very interesting and I am inclined to look into it in more detail and utilize my windows Azure account to develop applications against it.References :

    the excellent White Paper by David Chappell

    Blog post by Mike Ormond

    MSDN Azure Services platform

First Look at LINQ

I have been wanting to look into LINQ for quite sometime and finally last week, due to the requirements of our current project I had to quickly get into it and use it.
My first impression is that although a bit tricky to get your head around terms like Expression Tree’s , Lambda Expressions, and Extension Methods etc, once your understand the tricky notations it really is fascinating what you can do with it.

Last week I attended a London.net user group meeting on DSL and realized how much Domain Driven Development is being utilized in LINQ , and that is surly one of the upcoming development methodologies , so one thing is for sure that I need to spend much more time understanding LINQ and the related technologies.

A simple LINQ to Object example looks something like this

string[] presidents = {

“Adams”, “Arthur”, “Buchanan”, “Bush”, “Carter”, “Cleveland”,

“Clinton”, “Coolidge”, “Eisenhower”, “Fillmore”, “Ford”, “Garfield”,

“Grant”, “Harding”, “Harrison”, “Hayes”, “Hoover”, “Jackson”,

“Jefferson”, “Johnson”, “Kennedy”, “Lincoln”, “Madison”, “McKinley”,

“Monroe”, “Nixon”, “Pierce”, “Polk”, “Reagan”, “Roosevelt”, “Taft”,

“Taylor”, “Truman”, “Tyler”, “Van Buren”, “Washington”, “Wilson”};

IEnumerable<string> items = presidents.Where(p => p.StartsWith(”A”));

foreach (string item in items)

Console.WriteLine(item);

The LINQ Project is hosted here

Highlights of FOWA 2008 day 2

Thanks to my colleague Christoph Schmaltz I was able to go to FOWA on day 2. It was an interesting experience, I have not been to such a big technology conference before, and it was a good learning experience , I attended most of the presentations in the developer tack, however the most interesting talk was from Kathy Sierra on “how to grow and nurture your community”, the main idea that Kathy stressed was about creating a culture of passion among users to solve their tasks, its all about making the “users kick ass” rather then getting the “product to kick ass”, hand holding users to be champions is the only way to gain adoption and to maintain it. I have had Kathy’s book “Head First Design Patterns” for sometime but had not read it as yet, however after listening to her I came home and the first thing I did was to start reading her book :)

The most interesting stall was from Microsoft because of Microsoft Surface, it was my first look at this futuristic invention, very very interesting, viewing the demo of Microsoft surface I am quite sure that we will be seeing more of them pretty soon. Considering that it costs 15,000 dollars a piece I don’t think its going to be a big investment for hotels, pubs etc to use it as a customer attraction.

Since I have been working with REST in WCF now a days and have had some issues getting the required information, I discussed it with Mike Taulty at microsoft and he was very kind to guide me towards Astoria Data Services to sort out our requirements.

Listening to QA with Mark Zuckerberg, founder of Facebook was interesting and made me think the possibilities that the internet holds today.

Return Newely Created ID of Record using Typed Datasets

When Using ADO.net typed datasets, Visual Studio Automatically creates the Update, and Insert Methods, however the return integer value indicate if the record was added successfully or not, in order to get the ID of the newely created entry one can access the ID field of the original dataset that was used to add contents to the database.

In order to make this happen one needs to enable “Refresh the data table” in Advanced Options

once done, on update the source datatable contents will be updated with the inserted Id of the new record.

[System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select, true)]
public int AddModule(dsDomainModules.tblDomainModulesRow Module)
{
int nResult = 0;
try
{
dsDomainModules.tblDomainModulesDataTable objModule = new dsDomainModules.tblDomainModulesDataTable();
objModule.AddtblDomainModulesRow(Module);
if (_dsDomainModulesTableAdapter.Update(objModule) == 1) //update was successful
nResult = Module.nModuleId;
}
catch (Exception ex)
{
//do something with exception
}
return nResult;
}

REST in WCF

While reading Joe Stagner’s blog I came across a very interesting screencast series about using RESTful services using WCF, after going throw few of them I realized how easy it was to put a RESTful service infront of your existing API, The list of screencasts from Rob Bagby can be found on his blog or at Joe Stagners blog post.