Wednesday, October 26, 2011

BodyEngine.com

Being a software developer, it is very easy to sit down in front of the computer for hours at a time and live a very sedentary lifestyle. I started looking for a way to get back into shape and a friend of mine suggested an app called BodyEngine. The app is very slick and easy to use -- I can appreciate good software when I see it. With only a few clicks I was able to see that I am currently overweight by 5 lb. I can also see how many calories I need to eat and how much to exercise to reach my goal weight of 175 lb. The app is free, so give it a try to see in what category you fall and create your own personalized fitness plan.  http://www.bodyengine.com

Saturday, August 27, 2011

How to ignore self-signed ssl certificate verification in maven svn scm


I was trying to prepare a release for a maven project with the command
mvn release:prepare but the maven scm plugin could not commit the updated pom file because the certificate is self-signed.
 
My setup is Window 7, Collabnet SVN Client 1.6.6, Maven 2.2.1 but the solution is not specific to Windows or collabnet svn client.


...
[INFO] Checking in modified POMs...
[INFO] Executing: cmd.exe /X /C "svn --non-interactive commit --file C:\Users\myname\AppData\Local\Temp\maven-scm-1429998188.commit --targets C:\Users\myname\AppData\Local\Temp\maven-scm-1933937231031554007-targets"
[INFO] Working directory: G:\Projects\my-project\
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Unable to commit files
Provider message:
The svn command failed.
Command output:
svn: Commit failed (details follow):
svn: OPTIONS of 'https://svn.mysite.com/my-project/trunk/': Server certificate verification failed: issuer is not trusted (https://svn.mysite.com)
...

...read on to see how to get around this problem...


Wednesday, May 18, 2011

Test-Driven Development - Are you doing it right?

Recently I have been doing test-driven development (TDD) exclusively in both Java and C#, and I have made great progress in doing it the right way. I was fortunate to learn the right way from Uncle Bob who my employer invited for a TDD in-house training course for our engineering team.

So how do you know that you are doing it right?

Here are the signs that you are on the right path:
  • You are writing more tests than ever before 
  • Your test coverage is creeping up to > 90%
  • You create a test class before creating the class under test
  • You write a failing unit test before making any code changes
  • Your test classes are longer (more lines) than the class under test
  • You start to feel itchy when you write a line of code that is not making a test pass
  • You are more confident in the code you are writing
  • You are refactoring your tests
  • You are not deploying and debugging every time you change the code
  • You are debugging tests rather than production code
Doing TTD is not easy and requires that you stop following old habits and force yourself to do it properly for a few weeks. For me it was a slow off-and-on process, but as I do more and more of it, I find that I am getting my development speed back, with an added boost of confidence provided by over 90% code coverage. Yes, I have tests to prove it!

Saturday, April 9, 2011

How to configure cygwin to use ctrl + arrow to move cursor forward / backward

If you have used Windows for a while, you probably feel more comfortable using ctrl + left arrow and ctrl + right arrow to navigate the cursor through words. The default behavior in bash however is to use alt+f and alt+b. If you don't want to train yourself to learn yet another shortcut, follow three easy steps below to configure cygwin key bindings to use ctrl + left and ctrl + right.

  1. Modify existing or create a new file called .inputrc under your cygwin home directory
  2. Add the following lines:

    "\e[1;5C": forward-word   # ctrl + right
    "\e[1;5D": backward-word  # ctrl + left 
    

  3. Save the file and restart cygwin

Configuring text editor in cygwin bash

In this post I will show you how to edit files with your favorite windows text editor from the cygwin bash command line. My favorite editor is notepad++ and to edit a file from cygwin, I type: ed myFile.txt


Here is what you need to do:

Friday, March 25, 2011

Maven aliases for bash

When I have to type more than 20+ characters on a command line to build an application hundreds of times a day, day after day, I look for a way to make my life easier by reducing the strain on my fingers; and at the same time increase my productivity by reducing typing time and errors. 

My tip today will be about developers that use Apache Maven, but you can apply the same method for any command that you are tired of typing. I have shared the method below with a few of my (lazy) colleagues and because everyone enjoyed it so much, I am now sharing it with you:

Saturday, February 26, 2011

Could not load file or assembly 'System.ServiceModel.Web, Version=2.0.5.0

Currently I am working on a Unit Test project based on Microsoft Testing Framework for .NET 4.0 which is testing a project based on Silverlight 4.0. So far everything has been fine but today I wrote a test that was exercising the serialization of a class to JSON and ran into the following exception. The class is using System.ServiceModel library and its fields are annotated.

Here is the error I was getting when running the unit test in Visual Studio 2010:
System.IO.FileNotFoundException: Could not load file or assembly 'System.ServiceModel.Web, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' or one of its dependencies. The system cannot find the file specified.WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].


I tried to get both the Project Under Test, and the Test Project to use the same System.ServiceModel library but was not successful. Visual Studio would not allow the Silverlight Project to use the same libraries as the .NET 4.0 Framework and it would also not allow the Unit Test Project to use the same libraries as the Silverlight Project. After trying different options, I found a very hacky solution.

The hacky fix is to specify the reference paths for the Unit Test project. Here is what you need to do:

Wednesday, February 23, 2011

Object-Oriented Anti-Pattern - Data Objects with Behavior

As software engineers we are all taught about the Object-Oriented (OO) paradigm  and make every effort to design according to OO rules and patterns. Most high level languages go as far as to forbid non-OO programming. Even so, it doesn't take long for any software engineer to tell you about many applications where OO is misused. I think one very good example where OO is misused is with Data Objects.

What is a Data Object?
Data Objects represent data pieces that are grouped together to form a single structure or entity. Two very good examples of Data Objects are ORM Entity Objects and Data Transfer Objects.

Attributes and Behavior
Objects are made up of attributes and behavior but Data Objects by definition represent only data and hence can have only attributes. Books, Movies, Files, even IO Streams do not have behavior. A book has a title but it does not know how to read. A movie has actors but it does not know how to play. A file has content but it does not know how to delete. A stream has content but it does not know how to open/close or stop. These are all examples of Data Objects that have attributes but do not have behavior. As such, they should be treated as dumb data objects and we as software engineers should not force behavior upon them.