August 2004 - Posts
I noticed today on Korby Parnell's blog he highlighted a comment I left in regards to a VSS Performance post he made. I actually copied and pasetd that comment straight from an article I had written on VSS a long time ago so, I figured I would post that VSS article in it's entirety for anyone that might like to read more about some useful feaures of VSS. I'll probably include this article with DevCampus content when I add content to the site too. I've personally found the items discussed to be useful to me in my everyday development tasks.
You can view the article here.
Last night I read chapter 6 of Pragmatic Unit Testing - In C# with NUnit which covered using mock objects. I found the idea of mock objects interesting but, despite the examples given in the book, had a hard time trying to think of some good cases for using mock objects. Sure, the network could become unavailable, hard drives can fail, memory failures can happen, etc. I'm curious what other NUnit and perhaps DotNetMock users have found to be useful cases for employing mock objects in their unit tests. Anyone care to share their experiences?
This post is for anyone curious about how my DevCampus project is coming along.
Personally, I've finished about 20 articles for the site. I'm not sure about other people that volunteered to write articles, maybe they would like to drop me an e-mail or leave a comment here on how they're doing. (Don't worry - I have a day job too and know how precious a resource time is) The "go live" goal of 50 articles actually looks possible now though, so that's good news.
As far as the site construction goes. I've written code here and there (mostly class libraries) as I get spare time and have some page layouts somewhat finished. I really want to do a CSS-based layout/design for the site but, unfortunately, my CSS skills aren't quite strong enough to do it by myself. I'm either going to have to go with a table-based design (yuck) or get someone to help me with a CSS design. It would be nice (of course) to have a CSS layout so that changing the layout down the road would be easier but, I'll have to make do with my current skills if I can't get help. I've asked a few CSS guru's if they'd have some time to help and of course, they're all busy into next year.
Here are a couple of links to anyone that hasn't heard about my DevCampus idea yet and would like to know more:
About DevCampus
DevCampus is looking for "Editor Experts"
I picked up a couple of new books recently that cover testing topics related to development.
1. Pragmatic Unit Testing - In C# with NUnit [Andrew Hunt and David Thomas]
Some of you might recognize the authors of this book if you've read "The Pragmatic Programmer". This book has served as my introduction to Unit Testing and I'm glad I chose to read this book first. It introduces you to NUnit and explains how to use the NUnit libraries (NUnit.Framework, NUnit.Core, etc.) to create test classes and test methods. It also introduces you to the NUnit GUI and the NUnit command line ways of testing those classes and methods once you've written them. Beyond using NUnit though, I really appreciate how this book helps you realize that there's much more to unit testing than just using NUnit. In chapter 4 they take you through the RIGHT BICEP concept and then in the next chapter take you through the CORRECT concept (both RIGHT BICEP and CORRECT are acronyms that stand for a particular series of checks to put your code through, just like ACID is to transactions). So far I'm about 70 pages through this book which believe it or not, is about half-way. I'll report back on what the second half of the book covers and how it further improves your knowledge of unit testing.
2. Test-Driven Development in Microsoft .NET [James W. Newkirk and Alexei A. Vorontsov]
I've been seeing this book endorsed all over the place, so I thought I'd give it a try. I haven't begun reading it yet but, glancing at the table of contents it looks like it should be a fun read. Especially after I've finished book #1. There's an NUnit primer including as an appendix but, I'm thinking I won't need it after finishing book #1. This book looks to get deeper into unit testing and steps outside the realm of simple examples to cover ASP.NET Web Services, transactions and other common development situations. I'll post again once I've read this book with my opinion/review.
These two books definitely seem like a good one-two punch if you're looking to learn about unit testing. The first book explains exactly what unit testing is, and how to do it with NUnit, while the second book assumes you're familiar with NUnit and goes through some more advanced unit testing scenarios.
Hint: Today's question is pretty easy if you understand which SQL Server data type are valid for which operations with user-defined functions. What you want to build is a scalar-value function named GetBooleanTextFromInt that returns a boolean text string based on an integer passed to it. So if you pass 0 (zero) to it, it returns the text 'False'. Any other integer value passed to it should return the text 'True'. For example:
SELECT GetBooleanTextFromInt(0) AS 'BooleanText'
returns a single field named BooleanText with the text value 'False' in it. while
SELECT GetBooleanTextFromInt(12) AS 'BooleanText'
returns a single field named BooleanText with the text value 'True' in it.
Here is the initial function, try to spot the problem(s):
CREATE FUNCTION GetBooleanTextFromInt (@num1 int)
RETURNS text
AS
BEGIN
IF @num1 = 0
BEGIN
RETURN 'False'
END
ELSE
RETURN 'True'
END
In an effort to increase my T-SQL skills, and possibly help others learn T-SQL better, I'm kicking off a series of posts today that will show a T-SQL batch that has a problem with it, and after people have had ample time to try to solve the problem, I will post the answer.
For today's T-SQL problem, you have a table named 'Positions' that has two fields. 'Id' which is an int and is the primary key and identity field, and 'PositionValue' which is also a standard int field. A procedure to update a specific value for a PositionValue field (based on the Id value passed in) is shown below:
CREATE PROCEDURE UpdatePosition
(@PositionValue int,
@PositionId int
)
AS
SET NOCOUNT ON
GO
UPDATE
Positions
SET
PositionValue = @PositionValue
WHERE
Id = @PositionId
GO
Can you spot the problem?
I came across some C# code today where a constructor had a few overloads, all of which contained about 10 lines of the exact same initialization code (for private members). The only difference was that some of the constructors allowed you to pass in values for some of the properties. I refactored the code to use constructor chaining, for example:
class Foo
{
public Foo()
{
\\ initialization code
}
public Foo(string bar):this()
{
this.bar = bar;
}
}
After doing this I was curious how I might do this in VB.NET. I consider myself pretty good with search tools like Google, but, I couldn't find any resources that explained how to perform constructor chaining in VB.NET. Is it possible? If so, how?
Next month, when Amazon's quarterly period for their Associates program ends, I'll be getting a gift certificate for about $70. I figure this is enough to buy at least 2 books, maybe 3. I'd like to get back in the habit of reading some technical books, so I figured I'd ask for some recommendations from my readers. Here are some titles I'm considering:
Essential ASP.NET by Fritz Onion
Coder To Developers by Mike Gunderloy
Test-Driven Development in Microsoft .NET
Coding Slave by Bob Reselman
Code Complete 2nd Edition by Steve McConnell
I'm open to suggestions. I'm also looking for some good "enterprise development" and "architect" books but haven't heard of or seen any lately.
I happened to be checking my blog url (
http://weblogs.asp.net/jamauss) tonight over at
Technorati (a bit of ego-surfing if you will) and noticed I had an inbound link from the man behind
VbCity.com and
DevCity.net,
Serge Baranovsky. Upon further inspection it turns out that Serge has set up blogs for the VbCity community
here, using
.TEXT. If you've done VB development with any regularity (like I have) I'm sure you've stumbled across VbCity while finding answers to your problems. Both
VbCity and
DevCity are great resources and both are part of the CodeWise Community of websites. Give them a look if you haven't already. And if you're interested in keeping up with the latest on VB, subscribe to
Serge's blog. I'm sure he'll be posting interesting VB information in forthcoming posts. (Don't worry Serge - no pressure!)
For those of you that worry about spam and your e-mail address being publicly visible on the internet, this one is dedicated to you.
Additionally, if you ever want to provide a really good service to people that input their e-mail address for display on a forum or comments on a site you build, use this:
<!-- Script to thwart spambot/e-mail address harvesters -->
<script language=javascript>
<!--
var linktext = “Bob“;
var username = “Admin“;
var domain = “website.com“;
document.write(“<a href=“ + “mail“ + “to:“ + username + “@“ + domain + “>“ + linktext + “</a>“);
//-->
</script>
I realize this trick has probably been in use by some clever JavaScript developers for years already but, hey, it's news to me.
More Posts