Raba - Defend your code RSS 2.0
# Sunday, February 18, 2007

Hi, so this is my first step in the TDD world, First read "TDD: from beginner to pro" introduction.

I Had to write a decision tree algorithm which has a special format (SVMLight format). The algorithm should run on this data and create the tree. I will focus on the SVMLightVector class.

I should also add that my examples for this session would be taken from the world of text mining.
our samples would be documents and we should classify each document to its subject.
for example if we hold a document D1 (bunch of words separated by spaces), the decision tree would help us to decide whether this document (D1) is a sport article or finance.

the SVMLightVector class holds:

  • Features - for example if we hold a document each word is a feature.
  • Classification - the subject of the features.

so I wrote this code, or if I'll be TDD-ly Correct: attend to write this code:

public class SVMLightVector
   private IList<string> m_classifications;
   public IList<string> Classifications
      get { return m_classifications; }
      set { m_classifications = value; }

   private IDictionary<string, long> m_features;
   public IDictionary<string, long> Features
      get { return m_features; }
      set { m_features = value; }

   public SVMLightVector()
      // do nothing.

   public SVMLightVector(string svmLightFormat)
      Classifications = new List<string>();
      Features = new Dictionary<string, long>();

So I thought to myself... Testing properties? isn't it wasteful? so I decided to stop wasting my time and start coding.
So why do I think it is good to right such tests:

  • because that this is what I read in all TDD books, test everything, do not have even one line not tested...
  • why not?! it is simpleasy (simple&easy)....
  • also, I must admit that I found it useful to write those tests for properties, how many times it happens that you copy&paste&change one property to another one, instead of using the snippet, this trick can cause strange bugs, believe me.

so here are my tests:

public void FeaturesProperty_SetProperty_GetTheSame()
   IList<string> classifications = new List<string>();

   IList<string> expectedClassifications = new List<string>();

   SVMLightVector vector = new SVMLightVector();
   vector.Classifications = classifications;

   //Assert.AreEqual<IList<string>>(expectedClassifications, vector.Classifications);
   CollectionAssert.AreEqual((IList)expectedClassifications, (IList)vector.Classifications);

public void FeaturesProperty_SetPropertyToWrongClass_GetDifferentClass()
   IList<string> classifications = new List<string>();

   IList<string> expectedClassifications = new List<string>();

   SVMLightVector vector = new SVMLightVector();
   vector.Classifications = classifications;

   //Assert.AreNotEqual<IList<string>>(expectedClassifications, vector.Classifications);
   CollectionAssert.AreNotEqual((IList)expectedClassifications, (IList)vector.Classifications);

Simple isn't it?
You can see my first Test-Bug. I tried to use the Assert.AreEqual<> which is not what I needed, because this one compares objects.
but I easily found this: CollectionAssert.

One Question to myself:

  • Why it(CollectionAssert) doen't use generics?!

Good night for now.

I should thanks to two people that don't even know that I've learned from them a lot.
1) Roy Osherove - I've been reading his blog and using his standards of naming test methods and some more standards.
2) Oren Ellenbogen - Which I read his code and start learning this stuff from their.
Sunday, February 18, 2007 1:06:37 AM (GMT Standard Time, UTC+00:00)  #    Comments [0] - Trackback
.Net 2.0 | TDD

# Saturday, February 17, 2007

Hi, This week I will give you a closer look to my daily coding project.

My project is an exercise in machine learning lecture.
The project itself not really matter, I would like to use it to learn some new stuff and have a lot of fun.

I must admit that I have some challenges in the next few days:

  1. Time is running out and I am not one of those that have spare time to code at home.
  2. ML - I don't understand this stuff.
  3. TDD - I code some samples but not a real project.

I hope it will be useful for some other readers.

Saturday, February 17, 2007 10:35:54 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] - Trackback
.Net 2.0 | TDD

# Tuesday, February 13, 2007

I am gonna present tomorrow to the managers about the geographical approach in my department.
I just finished creating scenarios to those products:

  • ESRI ArcGIS Explorer
  • MS Virtual Earth 3d
  • Google Earth

After more than 3 years developing GIS applications, I must admit that we have today good/solid SDKs, for a simple and further usage.


I would like to give some scenarios to the non-trivial GIS applications:

supermarket products:

  • can be mapped to a Geo-DB, and easily find in space.
  • think about customer who searches a product using Geo-DB application pressing the product name, and the screen will show him the best way to get there.

Library mapping:

  • Think about mapping your library using a geographic engine, each book can easily find in space.


  • we can find behaviors of diseases in different places in the world/country/city.
  • such task wouldn't so trivial before, but today it is in a daily basic.


My Tip:

  • Think about your applications today, you can easily move them one step further and give them a better UI.
  • Tomorrow you could easily earn the added value, from (Data)mining the geographic behaviors.

Wish me luck...

Tuesday, February 13, 2007 11:25:05 PM (GMT Standard Time, UTC+00:00)  #    Comments [3] - Trackback
GIS | Software Development

# Tuesday, December 19, 2006

ESRI Just released the 9.2 version, which holds pretty much cool features, but still has a lot of stuff to work on till the next release.

IMHO, ESRI should work much more like MS when planning the next release (talk to their clients),
One way to do this is to free the beta on the net to whom it may concern, and open more official blogs and forums to the crowd, so we will help doing better product together.
I think that it will help them learning more new stuff\old habits.

This are my highlights, (I am still learning the 9.2 so I'll keep updating this list):

  1. Performance - They have today better performance than ever (I have a doubtful honor to write code using the map-objects and the ArcIms products, which were both terribly bad products {3.1 Version})
    But still, a lot to improve: build pyramids and calculate statistics still take hours even on good machines and therefore we cannot use this regularly on real time.
    The "simple" AGX, which should be used on each client, need better machine which not all of our clients can afford, and not to talk about the bandwidth.
  2. Prices - I honestly think that it is not reasonable to pay per CPU, I hope that there would more competitors (Google, Microsoft) so the price for the next version will be lower.
  3. Better Design - the code examples and the design patterns (no DP at all) are everything we learn not to do at school.
    Please take some lessons in usability (at MS School) because it is hardly to read and not intuitive.
    Not to mention the code in the Web Controls which always placed in the wrong method at the control life-cycle,(for example: load data in pre-render, Ajax stuff mixing inside simple renders)(I saw this in the beta, I didn't check it in the release, yet).
  4. WPF - It is about time that finally ESRI will work with MS step by step, I should ask why won't we use the Xaml for this version (which released almost at the same time as the FW3.0).
    ESRI should take care that the next version should be FW3.0 certified, using the Xaml.
    Not to mention the Orcas Enabled.

Please add your suggestion, hopefully to find someone in ESRI to listen to my requests.

Tuesday, December 19, 2006 12:06:30 AM (GMT Standard Time, UTC+00:00)  #    Comments [3] - Trackback

# Saturday, November 11, 2006

At work I have two computers, one with VS2003 (the older one), and on the other one I've installed VS2005, they both share the same user-profile (network profile, I guess).

When building my solution I got this warning:
   CS1668: Invalid search path 'C:\Program Files\Microsoft Visual Studio\VC98\mfc\lib'
   specified in 'LIB Environment Variable' -- 'the system cannot find the file specified.'

This warning has occurred on each project build.

My first step was to try finding the path, which of course wasn't there.
My next step was to search the Environment variables and there it was the LIB variable was pointing on the given path.

As a conclusion, the VS2005 try to load the LIB variables at each build operation, and cannot find it.
Just delete the unrecognized paths from the LIB and your VS2005 will stop showing annoying warnings.

Moreover, this is a 1-0 to the VS2005, this is a good example for descriptive error.

* I've heard that this problem happen for others when installing the VS2005 on a computer with VS2003 that has been deleted.

Saturday, November 11, 2006 5:07:56 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] - Trackback
.Net | .Net 2.0 | Software Development

After a long period of testing and customizing the Team foundation Server to our needs, We can finally say that we have a great results.

First, I would like to invite all of you: use the TFS it is a great tool and it will help you being more productive.
Second, Matan1 and I thought about useful feature for the next release:

Inheritance in process templates (VSTS)
   We have two different systems: StandardWorld, AmazingWorld.
   We want to customize the bug work-item, for example, so each programmer\tester will not forget 
   writing important details.
   (for example: the user's profile which caused the error.
   Why? because in our system we would like to know the user's profile which produced the bug).
   But Hey, it is system-based, in StandardWorld, for example, we don't have profiles at all.

How do we gonna implement this today:
   Today we just create two different process templates (AmazingWorld-ProcessTemplate and 
   StandardWorld-ProcessTemplate) which are the same, but with different additions for each 
   system. For example: in AmazingWorld-ProcessTemplate we would add the special field to the 
   bug work-item.

The Problem:
   All the  known copy&paste errors, from the Software development, each minor change will reflect
   on two different places, and so on. 
   Think about your code, we always try to prevent the copy&paste operation.

Our Solution:
   Lets define inheritance between process templates.
   For example: StandardWorld will use the default template (the base template), and the 
                     AmazingWorld will use the extended template (the one with added features).
   The logic should be like this:
      For each new template we could choose if we want to inherit from other class/template or not.

  I opened a lady bug at microsoft:
  Vote for it.

   We think that it will help us create more generic templates!
   Let me know what do you think about this?
   Is this a good feature for the next version?

1A few words about Matan: he took this mission with his two hands (strong and big I might say) and lead the team to a better process. If you would like to ask more questions about the TFS do not hesitate.

Saturday, November 11, 2006 4:09:12 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] - Trackback
Software Development | Team Foundation Server

Omer Van Kloeten check the opportunity to invite the Israeli Bloggers to Dinner (I think that it gonna be in his house :).

But hey, I think that this is a great idea, so raise your hand if you think like me, or just leave a comment here.

Saturday, November 11, 2006 3:26:08 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] - Trackback

# Monday, September 04, 2006

For the next post I'll split our world into two parts:
Architect - the one who creates those guidelines
Programmers - those who get the guidelines and should follow the directions.

Tools Vocabulary:

  • GAX - Guidance Automation Extension:
    This Part of installation should be installed on all your programmers' stations, this installation is working as a run-time environment on your computer. Once you installed the GAX you can download tons of guidance installers (MSI\Setup.exe), you can find those on the net or ask your architect to create some for you(read GAT bullet for further info).
  • GAT - Guidance Automation Toolkit:
    This part of the installation will be used by the Architect (The one who writes those guidelines).
    After installing the GAT, you can insert your VS2005 and create a new solution : go to Guidance package and see your new sample packages.

Here are your first steps in the GAT world:
(From now on (this post, only) I am the Architect and you are my enthusiastic-gifted-lovely programmers).

  1. Download the GAX,  run the MSI, in this point there is no visible difference in your VS2005. 
  2. Download my sample project: GatLectures.Lec1Setup.msi (592.00KB) and run the installer, this sample project creates a sample solution. In this solution you can find more options on your context menu (Fig1), you can also see the new snippets(Fig 3 & Fig 4) I've inserted.
    Here are some screen shots samples:

Create Customized class
Fig 1. Add Your custom made class, instead of copy&paste from others class.

         Custom made property screen
Fig 2. Custom made screen for inserting the class parameters and generating the class data.


Projects snippets
Fig 3. Choose your current snippets by moving between the existing projects


Your Project Snippets
Fig 4. I've added two snippets samples, and you (the programmer) can use it without installing 
        anything else. (all programmers will use the same snippets in the whole project)

        Stop Here, Please try those two steps by yourself!

        After you've finished playing with this package yourself you can simply remove the package by going 
        to your: Control Panel -> add/remove programs -> remove the GatLectures.Lec1Setup.

  1. Now you can play the architect role yourself:
    * Step 1 - Download the GAT and install it.
    * Step 2 - Open your VS2005
    * Step 3 - Open a new project -> Guidance Packages, 
                   here you can see the Guidance Package Development.
    If your fingers are dancing on the keyboard, like mine were in this installation, you can try this out or you can wait a little bit.
    On my next lectures I'll give a full explanation on how to do this right.

The First two steps will be a common behavior for programmers, the third step will be done by the architect or the guidelines creator.

* Special thanks to Gil for assisting me in the programmer's side (phase 1 and 2 of the installation & the screenshots).

* I would be glad to receive any question\remarks either by comment or by mail, it will help me understand your point of view and where my explanations are insufficient.
* If you want to see something else (either simpler or complicated) just send me a comment or mail.
Monday, September 04, 2006 12:20:22 AM (GMT Daylight Time, UTC+01:00)  #    Comments [0] - Trackback
.Net 2.0 | Guidance Automation Toolkit

# Friday, August 25, 2006

Gat is an acronym for Guidance Automation Toolkit, this name is a self descriptive.
The first big example I can think about GAT usage is for all the big guidance docs in our office, every programmer wrote at least one guidance document.

For example, document that holds your team standards, such as: all of our web-pages will inherit from MyTeamMasterPage.
For example, in my team we always open new web-page which inherit from the same page, which holds some helper properties.
Another example is in our Dal & BO which both sitting in COM+ they both inherit from the same class and implement the same interfaces and so on.

This guidance docs are pretty good, because they force the same standards between the team members, but the big problem that new programmers will need more time before they could learn and use all those specific standards, and also this is a waste of time for the programmer.
When we change those standards we should learn everyone those new standards and it take some time to get used to this new standards.

The Gat is giving you whole new world to automate this process and to stop the monkey copy-paste.

For example instead of adding new empty WebForm.aspx you can cause your programmers to add the special MyTeamWebForm.aspx which holds inside the logical stuff we describe before.

I know that some of you might mumble to yourself: Merlin did the same or I wrote such Add-ins, but it is more powerful than you can think about it right now, so stay tuned for the next days I'll post here my tutorial for the Gat newbie.

Friday, August 25, 2006 9:13:40 PM (GMT Daylight Time, UTC+01:00)  #    Comments [0] - Trackback
.Net 2.0 | Guidance Automation Toolkit

# Wednesday, August 23, 2006
Shani's presentation about Microsoft Buzz-Words & dotnet in the future.
Wednesday, August 23, 2006 9:45:39 PM (GMT Daylight Time, UTC+01:00)  #    Comments [3] - Trackback
Microsoft Products

<February 2007>

The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2014
Shani Raba
Sign In
Total Posts: 146
This Year: 0
This Month: 0
This Week: 0
Comments: 97
Cool Stuff
Add to Technorati Favorites
Pick a theme:
All Content © 2014, Shani Raba
DasBlog theme 'Business' created by Christoph De Baene (delarou)