Sacramento Software Development

C# Verbatim Strings

Posted by John Lockwood on June 29th, 2006

Just doing a bit of hacking with the C Sharp mono compiler this evening. (I’m waiting for Visual Studio to ship — what else?). Meantime I may have found my first error in Donis Marshall’s Programming Microsoft Visual C# 2005: The Language — which doesn’t bode incredibly well given that I’m only on page 23 or so.

Looking at verbatim strings, Marshall neglects to point out that to escape a string inside a verbatim string you use double quotes, not backslash quote.

Here’s a braindead example of the right way to do it. Mono users use mcs VerbatimString.cs to compile.


using System;
using System.Text;

public class VerbatimStrings
{
  public static void Main()
  {
  String verbatim =

@"This is a
verbatim string, and it can go
on and on, using ""quote"" characters
etc but everything else
is not escaped, like tab characters, \t
and so forth."

  System.Console.Write(verbatim);
  }
}

You know, it took about three times as long to write the blog post as it did to figure it out to begin with. I love trying to write code in HTML. There should be a wordpress plugin or the like for that…

Posted in Software | Add a comment »

.NET Contract in Sacramento Going Well

Posted by John Lockwood on June 28th, 2006

The ASP.NET contract I’m doing in Sac is going quite well so far. It’s a small and really congenial team, and in less than a week I started to make some good progress on some of the code.

There are some minor hiccups — development anti-patterns, if you will — but it doesn’t look like anything too dire. Some of this involves existing code written by a now-missing contractor, which is always a delicate matter. Everyone likes the guy and he’s clearly very sharp in his work, but some of the underlying framework of his that we’re coding too may have a bit of architectural gold plating (which is not so bad in itself except in insofar as it may violate the Pragmatic “DRY” rule). A little more of a concern is that it may drive our efforts in the wrong direction as far as being fat / difficult to fix (which IS so bad in itself). Must learn more…

But that’s just code, which can always be fixed or tossed. The really tough job — good management and a team that gets along well — is already in place. Without that no amount of code will save you anyway.

Also, being in Visual Studio again is a treat. It’s always had a fairly competent debugger — and let’s face it, as a programmer, that’s home. I keep a SlickEdit window open for the heavy editorial lifting, of course. The new SourceSafe integration is flawless so far, too, and that’s quite nice. I’m starting to get a pretty good feel for ASP.NET.

Posted in Software | Add a comment »

ASP.NET 2.0 Programming: Hooray, New Gig!

Posted by John Lockwood on June 24th, 2006

I’m grateful to my good friends at Robert Half for the exciting gig we’re working on now, developing in ASP.NET 2.0 using Visual Studio 2005 and SQL Server 2005. I’m very excited to be stepping back into the contract software labor force after a few years putting up web sites and selling houses, and getting back into using Microsoft’s tool set is exciting as well since many of my last major contracts were either Java (which is fine too) or ASP using Delphi — which is a bit too exotic and unmainstream for my taste. I like a little job security.

Actually, after real estate, I wouldn’t mind a LOT of job security, which is why I’m seriously considering just doing .NET alone for the foreseeable future. Java’s cool enough, but I don’t think it would hurt my current prospects to maybe do some certifications — and it would certainly help my current client if I threw myself into some spare time .NET hacking in preparation for those certifications, even if in the end I decide the certifications themselves are a superfluous expense.

So don’t be surprised if a lot of what you read here in the months ahead ends up being about the Road to .NET 2.0 Certification.

Stay tuned.

Posted in Software | Add a comment »

Saying Goodbye to the Legacy Stuff

Posted by John Lockwood on June 19th, 2006

Goodbye.

General
Author’s Blog

Legacy
Archives

Admittedly that was a bit perfunctory, but what the heck. Happy belated birthday.

Posted in Miscellaneous | Add a comment »

Using Ant and XDoclet with JDO

Posted by John Lockwood on June 3rd, 2006

One of the simple joys in programming is trying out new little hacks designed to prove a concept or try out something previously unfamiliar.

When I last used Java, Ant was a fairly new thing, and for some reason I had a lot of resistance to learning it. Now, Ant and Maven are fairly ubiquitous. Also, I’ve been wanting to take on some work in XDoclet, since it seems like almost everywhere you look — whether in EJB or in “lightweight” POJO tools like hibernate or JDO, there’s still some heavyweight XML configuration or metadata that needs to either get generated or maintained. (No wonder Java 1.5 adds support for attributes — and no wonder again that Ruby on Rails finds “favoring convention over configuration” to be a perfectly legitimate marketing strategy).

Anyhow, I do have some working code hacked together for using Ant and XDoclet and JDO — here’s the Zip File. src.com.particlewave.apps contains the java code, and build.xml is of course the Ant script. To run it, you’ll need ant and junit and you’ll need to have a lib directory with the unzipped jars from the XDoclet libraries available to ant on it’s classpath. For my first hack I was just working on getting XDoclet working to create JDO configuration files. Some good help in that direction came from JPox’s excellent XDoclet JDO example. Another sample I discovered later is here.

The jpox sample helped me debug a nasty and obscure problem with my own code. It turns out that — for jdo at least, I haven’t tried xdoclet in general on this — you need to have your comments in the form:


/**
   *  Double asterisks on first comment line.
   *
*/

not


/*
   * See the single asterisk on first comment line.
   *
*/

Using a single asterisk will create a JDO file, but even if your @jdo.whatever tags are all correct, the file will be empty. This was a bit cumbersome to track down, so I point it out in case someone else puts their leg in the same bear trap.

Enjoy!

Posted in Software | Add a comment »