Thursday, January 10, 2008

Static Code Analysis

There are many ways to test software. I was looking at one of the features of Microsoft Visual Studio and found that they have one that uses Microsoft's Intermediate Language(why? because it is not language specific) and Callgraphs(graphs of function calls in a program) to check for defects in the following areas:
  • Library design
  • Globalization
  • Naming conventions
  • Performance
  • Interoperability and portability
  • Security
  • Usage
When working on a project with other people it can be rather difficult getting people to stick to certain design rules your project has. I am looking over a tutorial for visual studio's code analysis abilities here.

Saturday, January 5, 2008

Useful way to calculate week of the month

I was looking at the date function in php to see if there was a method for calculating which week of the month a given date was. Example March 1st 2008 would be the first Saturday of March. Unfortunately there is no function that returns this information. However, I did find a reference in the discussion that followed the date function. Someone asked the exact same question. The following code is almost identical to what they posted.

$date = getDate(mktime(0,0,0,$month,$day,$year));
$days = $date['mday']-1;
$day = intval($days/7)+1;