9/5/2010
LifeCycle Solutions - Home ( the software development blog )
 

<March 2007>
SunMonTueWedThuFriSat
25262728123
45678910
11121314151617
18192021222324
25262728293031
1234567

Subscribe to this feed:

RSS 2.0 | Atom 1.0 |CDF






Monday, March 12, 2007

Last month I mentioned a couple upcoming tools for "next generation unit testing", but it should come as no suprise that Microsoft is also working on a similar tool of their own. From the maker of MbUnit, Pex is a unit testing framework that auto-generates test inputs for you. So, if you write a test like this:

[PexTest]public void MyTest(string input){...}


Then Pex is smart enough to generate tests for the full range of values for "input":

MyTest(""); MyTest(null); MyTest("somevalue");


Add in auto-correction, and the result is a pretty impressive test-driven development story. Unfortunately, this is currently only a Microsoft Research project. Hopefully it sees the light of day sometime soon (and not just for Team System!).

Posted by Daniel Root

Tuesday, February 20, 2007

Simile TimelineA recent post over on Scott Hanselman's blog turned me on to Simile Timeline, a open source Javascript API for adding cool timelines to web pages.  Think Google Maps, but for timelines.  It features a brilliant UI, and very extensible, well written client code.  Following the directions on the site, it's pretty easy to get started using it from ASP.NET- simply add the javascript reference and a bit of code to wire it up and you're all set.  But moving beyond the simple demo, I encountered a few issues and solutions that may be helpful:

Reference the Script from the Page Header. Simile Timeline requires you to reference the script from an include inside the <head> tag of your page.  This is because it uses the script include's url to determine the location of other scripts, images, and CSS files used by the app.  It is also possible to set this prefix in javascript, but your script includes should be in <head> anyway.

When generating XML from a HTTP Handler or web page, set the content type to text/xml.   The example that comes with Simile uses a static XML file for the event data, but in many cases you may want to generate this XML from a database in .NET.  This is easy enough to do by looping through a DataReader and writing out XML.  However, if you do not set Response.ContentType = "text/xml", then in FireFox, it will not parse the result as XML, and the events will not display.  IE is more lenient apparently, but this is still a good idea.

Prevent IE XmlHttp from caching results by adding a timestamp to the URL.  Internet Explorer's built-in XmlHttp class caches data, so that after one request to mysimilexml.aspx, the data is cached until the browser is restarted.  This is a problem if your data changes frequently, and can be aggrivating when testing. There is probably a way to adjust this in IE, but why have your users modify their browser settings?  In the javascript, add a timestamp to the URL to force a new request each time:

var eventsUrl = "ScheduleSimileXML.aspx?preventCache=" + currentDate.getFullYear() + "" + currentDate.getMonth() + "" + currentDate.getDate() + "" + currentDate.getHours() + "" + currentDate.getMinutes() + "" + currentDate.getSeconds()

Eventually, I'd like to see a real ASP.NET control wrapping this, but for now this is a very usable and handy API.

Posted by Daniel Root

One of the most useful tools for .NET development is Lutz Roeder's .NET Reflector, now in version 5.  It uses reflection to peek inside .NET assemblies and disassembles the IL back into C# or VB code for those times that you need an in-depth look into any .NET library.  Ever wonder what the code for System.String looked like? This release adds some really nice features:

  • Formatted code comments- doubles as a documentation browser for XML code-commented members
  • 'Expand members' in disassembler lets you see code for an entire class at once- previously you had to look at each method separately.
  • New analyzer features shows where classes are instantiated and exposed.
  • Search Google or MSDN for a member

In addition to helping you debug code, this is also a great learning tool.  What better way to understand framework development than to peek inside The Framework itself?

 

 

Posted by Daniel Root

Tuesday, February 13, 2007

LifeCycle regularly uses FxCop to check our code for conformance to the Microsoft Patterns & Practices Design Guidelines.  This tool analyzes an assembly against rules governing good naming, security, and performance.  Where a problem is found, FxCop gives you a link to more MSDN guidance on the issue.  Not only a great quality assurance tool, but a good learning tool as well. 

But on the horizon are a crop of new code analysis tools that take the concept to the next level.  CodeIt.Right takes a similar approach- analyzing code and providing a list of violations.  However, CodeIt.Right also bakes in refactoring.  Not only does it tell you your Serializeable type should inherit ISerializable, but with one click, it will make the fix for you. 

NStatic analyzes code and reports on violations in an extremely readable graphical overlay displayed ontop of your code.  As far as I can tell, the violations it targets tend to be more subtle flaws in logic within procedures.

Neither is ready for prime time- CodeIt.Right is in beta and was a little buggy in my testing and NStatic isn't available to the public at all yet.  Still, if your interested in writing quality code, these are two products to keep bookmarked.

Posted by Daniel Root

Thursday, February 01, 2007

So, our Action Pack came this week, and I installed Office 2007.  I'm loving the sleek new ribbon UI goodness, but one thing was bugging me in Outlook 2007's email editor.  When composing a new email, the font size looked way too big.  It was set to Tahoma 10, and when I sent the message, it looked fine.  Not a huge problem, but I want WYSIWYG!  I Googled, but apparently I'm the only one picky enough to care.

It turns out it's zoomed to 200% by default, but the zoom tool isn't there!  To fix:

Outlook -> New -> RT Click top of ribbon -> Customize Quick Access -> Customize -> All Commands -> Zoom -> Add

The zoom button should appear in the top left. Then click inside the message, click the zoom button, and choose 100%.

Seems like this could be a problem if users crank their font down when composing, and send tinsy little hard-to-read emails. 

Posted by Daniel Root

Monday, January 29, 2007

Scott Guthrie has a new post with a nice 25 minute video introduction into the next version of Visual Studio, showing off the almost fully-baked LINQ-to-SQL functionality with an ASP.NET example.   I can't wait to code this way!

Posted by Daniel Root

Friday, January 26, 2007

Microsoft Office SharePoint Server 2007 utilizes the "master page" concept familiar to ASP.NET 2.0 developers -- a big improvement in the latest SharePoint release.  Developers wishing to create a custom look and feel for a SharePoint site will probably first open SharePoint Designer and begin dissecting, changing and discarding parts of the default master page ("default.master"); however, it doesn't take long to discover that this is not a trivial process and that removing the wrong ContentPlaceHolder tags renders some of the default pages inoperable.  This is due to the fact that pages inherting the "default" master page expect certain ContentPlaceHolder tags to be available in the base page.
Microsoft has published a How-To document with a code sample that provides a minimal master page which contains all the basic pieces need to have a functioning site.  While this code snippet is a good start, it appears that MS left out the following ContentPlaceHolders:

<asp:ContentPlaceHolder ID="PlaceHolderBodyRightMargin" runat="server"/>
<asp:ContentPlaceHolder ID="PlaceHolderTitleRightMargin" runat="server"/>


If you experience error messages with the standard SharePoint pages after using the "minimal" template, try adding these placeholders. 

Posted by Brian Parks

Thursday, January 04, 2007

One of the reasons I prefer C# to VB.Net is for its brevity (not true in every case, but generally so).  Adding to the list of its syntax shortcuts, C# 2.0 introduces a new operator:  "??", dubbed the "null coalescing" operator.  For you SQLServer gurus out there, it is somewhat analagous to the COALESCE() function in Transact-SQL...it evaluates a single value and returns a second value if the first value is null (note, the type involved must be nullable).  

string
customerName=null;
string newCustomerName=null
;

// a long way of assigning newCustomerName
if (customerName == null
) {
   newCustomerName = "Empty"
; }
else
{
   newCustomerName = customerName;}

// a slightly shorter approach, using ?: "ternary operator"
newCustomerName = (customerName == null ? "Empty"
: customerName);

// much more concise, using the new ?? operator
newCustomerName = customerName ?? "Empty";

More information here
.

Posted by Brian Parks

Friday, December 22, 2006

FogBugz is a great web-based project management and bug tracking application that we use to keep track of our customer's projects.  I'm often suprised by the quality and modern feel of this app, despite running in classic ASP*.  So I was pleasantly suprised again when I found they'd come out with an API and Visual Studio 2005 Plugin.  Installation was simple, and the result is a very Team System-ey integration between our helpdesk and development environment. 

*As a side note, it's actually written in a proprietary language, Wasabi, which has driven some to (perhaps rightly) question the owner.

Posted by Daniel Root

Thursday, November 30, 2006

Here's one feature of ASP.NET 2.0 you may not have heard of- I certainly hadn't until it hit the blogs again recently.  If you drop a file named app_offline.htm in your web application's root folder, then all requests to that application will only return that file.  

Very handy for scheduled downtime, bringing down your app for updates, etc.  Scott Guthrie mentions the trick here, as well as a minor issue to be aware of when designing your app_offline page.

One novel way to implement this is to integrate it into your deployment process.  For example, a simple batch file like this:

copy C:\MyCompany\app_offline_updating.htm C:\InetPub\wwwroot\Demo\ProjectName\app_offline.htm /y

xcopy C:\MyCompany\ProjectName*.* C:\InetPub\wwwroot\Clients\Demo\ProjectName\ /s /q /y

del C:\InetPub\wwwroot\Clients\Demo\ProjectName\app_offline.htm

The batch file can be run manually, or even better- as part of your continuous integration process.  With a little javascript or meta-tag to do automatic refreshes, this is a great way to avoid errors and communicate downtime to users.

Posted by Daniel Root

© 2006 LifeCycle Solutions, LLC | All Rights Reserved