So I can only imagine how it seems to the rest of my team, for whom automated unit testing is a new concept. The level of drudgery involved in retrofitting a legacy app with a test harness rivals the chore of waxing Mr. Miyagi’s deck. All I can tell my teammates is that it’s good practice. Soon, writing unit tests becomes a habit, and then, eventually, it becomes pure instinct. Attack from the right? Wax On! Attack from the left? Wax Off! Add a new feature? HTTP-Unit! Change a business rule? JUnit! Keep it up, and that black belt will arrive in no time.
Ahoy, mateys. Gather ye 'round the scuttled water butt and I'll tell yer a tale or two. My name is Craig Jones, and this is my personal weblog. I also blog in two other places: For computer producity tips, see my posts on codejacked.com. For my thoughts on software development and business, see my company weblog.
Wednesday, June 29, 2005
Wax On, Wax Off – Red Bar, Green Bar
So I can only imagine how it seems to the rest of my team, for whom automated unit testing is a new concept. The level of drudgery involved in retrofitting a legacy app with a test harness rivals the chore of waxing Mr. Miyagi’s deck. All I can tell my teammates is that it’s good practice. Soon, writing unit tests becomes a habit, and then, eventually, it becomes pure instinct. Attack from the right? Wax On! Attack from the left? Wax Off! Add a new feature? HTTP-Unit! Change a business rule? JUnit! Keep it up, and that black belt will arrive in no time.
Wednesday, June 22, 2005
Copying SQL Records within the Same Table
You may or may know that this can be done with a single INSERT INTO statement if you use an embedded SELECT statement in place of the VALUES clause. The hard part is that you cannot just use SELECT * FROM table WHERE ... becuase the * would pick up the key field (e.g. DepartmentID) along with all the rest. So, you have to list every field in the table by hand, except DepartmentID. You would specify the new value as a constant ("B") instead.
The "trick" is that you can probably find a tool that will generate the INSERT and SELECT statements for you. In my case, I'm using the Query Analyzer that comes with Microsoft SQL. In the explorer pane, navigate to the table. First, right-click and choose the option to generate an INSERT script and send it to the clipboard. Paste it into your favorite editor. Next, right-click and choose the option to generate a SELECT script and send it to the clipboard. When you paste this snippet into the editor, do it so that it replaces the VALUES... part of the INSERT statement. Finally, change the field name of the key field in the SELECT statement to the appropriate constant.
Labels:
programming
The Cobbler's Children Have No Shoes
Subscribe to:
Posts (Atom)