Posted on March 27th, 2009%
Yesterday, April 15, saw something that doesn’t happen often: thousands of people around the country participated in civil, voluntary, grass-roots protests that had no central organizer. (Eventually, the scattered groups did come together, but it’s far from a top-down organization.) If that’s not shocking enough, toss in the fact that the protests were largely in favor of personal liberty and freedom against a rapidly-growing interventionist government. Now you really know why history was made!
Now that it’s over, what does it mean for us, those Americans who feel that there is a great need to right the ship? If I was to speak for the group, this is what I’d say. My statements are followed by some historic quotes on the topics of freedom and liberty.
Nearly 50 years ago, an American President said, “Ask not what your country can do for you, but what you can do for your country.”
In that . . .
→ Read More: After the tea: Where do we stand?
Posted on March 13th, 2009%
A quote of Vice-President Joseph Biden from March 12 2009, via the Associated Press:
“Six months from now, if the verdict on this effort is that we’ve wasted the money, we built things that were unnecessary or we’ve done things that are legal but make no sense, then, folks, don’t look for any help from the federal government for a long while,” he said.
This was followed up by President Obama’s equally compelling statement during the same conference:
“If we see money being misspent, we’re going to put a stop to it.”
Mr. President and Mr. Vice-President, if you are honest about what is deemed wasteful and unnecessary and senseless, there is little doubt that significant portions of the $787 billion you reallocated will prove to be just that. This inconvenient truth (ahem) will hopefully stimulate you (ahem) to stop trying to have the federal government be everything to everyone.
However, after . . .
→ Read More: Do you really mean it, Mr. Obama & Mr. Biden? If so, I’m your biggest fan!
Posted on March 6th, 2009%
A coworker of mine (who just got back from the Microsoft MVP events in Seattle, congrats, Matt!) has turned me on to using Moq, which I must say is an impressive mocking framework that has made unit testing notably easier.
Recently I had the need to mock the IRequest interface of the Castle MonoRail framework – specifically, two properties: the indexed property and the QueryString property, both of which expose a NameValueCollection.
I found some guidance on mocking the indexed property via Stack Overflow, which turned me on to the following solution.
var request = new Mock<IRequest>();
request.ExpectGet(r => r[It.Is<string>(x => x == "someName")]).Returns(“someValue”);
To mock the QueryString property took a different approach: create a NameValueCollection, add my test data to it, and wire the collection to the mocked object.
var request = new Mock<IRequest>();
var query = new NameValueCollection();
query.Add(“someName”, “someValue”);
request.ExpectGet(r => r.QueryString).Returns(query);
With this, I can now pass my mocked IRequest to other classes, which will be able to access the following:
request["someName"] = “someValue”;
request.QueryString["someName"] . . .
→ Read More: Mocking indexed properties with Moq
Code comments: the best defense need not be offensive
I just wrote a line of code, then added a comment before it.
//these tests don’t bubble up, so…
test.Reset();
Then I thought, “Why am I commenting that? Isn’t the code’s intent explicit enough?” It is quite clear what the code is doing (resetting a test). However, the comment is necessary to give some insight into the business reason for the code.
The comment is useful because the instructions in the code may contradict the expected business logic. If the action (resetting the test) was expected, it would not be necessary to add the comment; that wasn’t the case for me.
This is an example of what I call a defensive comment. It helps avoid the situation where someone looks at code and wonders whether it is logically incorrect. That someone may be another programmer, or it may be yourself, months after you’ve forgotten why you wrote the code in the first place.
Lots of people say that . . .
→ Read More: Code comments: the best defense need not be offensive