Rick van den Bosch - Blog

... on .NET, software architecture, software development and whatnot

Recent Posts

Tags

News

  • Live space

    Photo blog

    Follow me at twitter

    Rick  van den Bosch

    LinkedIn profile

    Add to Technorati Favorites

    Disclaimer
    The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

Community

Email Notifications

Blogs I read

Interesting links

Archives

July 2005 - Posts

JetBrains ReSharper 2.0 - First impression

Dennis blogged about it earlier today, and as soon as I saw that I couldn't help myself: I had to try out ReSharper 2.0! Little did I know about the consequences...

I love ReSharper 1. There are some small weird things, but overall I just love it, despite its little quirks. So 2.0 had to be even better! Unfortunately, it doesn't seem that way. Visual Studio now takes forever to start, the second project I opened made ReSharper crash hard (VS had to be restarted to get life back into it), assembly-parsing is still done in a modal dialog in stead of in the promised background process, it keeps annoying me with two windows I definitely don't want to see and last but not least: the bar next to the scrollbar now displays an ugly 3D-attempted square.

My first impression of ReSharper 2.0 is not too good. I'm testing it for the rest of the day, but when this feeling stays I will be switching back to my previous installed version...

Did you know: Visual Studio help 'tabbed browsing'
Holding down the SHIFT key when you click a link in the Visual Studio help (using external help) opens the topic in a new tab in the help browser. So that's a form of tabbed browsing. Sweet.

And pretty helpful when you would like to keep open the previous help topic you were in...
Posted: Jul 20 2005, 05:27 PM by Rick van den Bosch | with no comments
Filed under:
The conditional operator (? :)

Every now and again I see a piece of code where the author has used the conditional operator ? : . It might be my tidyness or it might take some getting used to, but I don't like it. I don't like it at all! My gut feeling says it's nasty, because it's not easy readable code. Lets look at an example. Imagine you have a property getter for the count of a collection. When the ArrayList you use internally is null, you want to return 0, else you want to return the count of the internal ArrayList. With the conditional operator, this looks like this:

return (myArrayList == null) ? 0 : myArrayList.Count;

where 'complete' code writing would look like this, maybe even with an extra variable for the return value and just one return statement. (notice the brackets which you should always use imho):

if (myArrayList == null)
{
    return 0;
}
else
{
    return myArrayList.Count;
}

Although the first code sample is much shorter, you also loose a lot of clarity by using the conditional operator. The second code sample explains what is being evaluated and when what value is returned. In short: I think the conditional operator needs two or three times reading to be sure what is being returned when, where the other sample doesn't.

Sure, in this case the code might be simple to understand, but what happens when the expression being evaluated gets larger and more complex?

New: post rating
Since we upgraded to Community Server, visitors are now able to rate posts. This way you can let the bloggers here at bloggingabout.net know what you think about the things they post. Give it a go!

Find a post you would like to rate, open the comments of that post and then click 'Rate'.
DataSets vs Classes

Should I choose datasets or will classes do the trick? This is a question each developer probably asks himself (or herself) at the beginning of a project. And maybe even along the way…

If I had to answer that question, I wouldn’t now what to say because I think it depends on a lot of things which of the two will be better. Both of them have pros and cons. DataSets for instance are very easy to persist in a database. Classes on the other hand can enforce business rules more easily.

Barry Gervin started out with a list why datasets are so good, but in the comments there’s a big discussion going on about when to use datasets and when to use custom entities. I for one like datasets and classes. And I think we can use them both, even within the same system. On the other hand, that might get a bit complex.

Is Udi Dahan's comment right? Should dataset only be used in one-off situations, or can they belong in the center of a system’s architecture?

I don’t have a particular preference, although I seem to be inclined to start with classes more often. Do you have a preference? If so, drop me a line in the comments!

The importance of testing (or: The influence of a bug ...)

We programmers know about bugs. We fight them now and then, create them sometimes but most of all try to keep them out of our software. At least, I hope you do too ;). Trend Micro has been the victim of a bug, and this had some nasty consequences for them. April 23rd this year, Trend Micro offered the update 'Official Pattern Release 2.594.00' on their website. This update allocated almost all system memory, making it impossible to work with the computer. Within two hours (!) a new version of the update was placed on the website and the erroneous one was removed. That two hours cost Trend Micro 8 million dollars! Tens of thousands of computers were 'infected' by the bug, more than 28000 customers called the callcenter that was rapidly put together.

I think this illustrates the importance of a few things I think every release in a software development project must go through:

- Unit testing
- Testing new features
- Testing old features
- Testing the influence of changes
- Regression testing
- TESTING!

Although testing is beginning to get more important in software development, I think a lot of companies are not up to par in that department. Where design and development of software have reached maturity puberty, testing seems to be strugling to get out of its diapers. Of course, there’s someone who is pushing the buttons and looking at the results, but that’s not enough. These days, software is very important. Like with Trend Micro, errors in software can cost you lots of money. I think the problem is that people don’t like to spend money for something when it’s hard to see if it pays off.

Maybe the problem is that good testing doesn’t show itself. When an error is found in a system through testing, that’s what the test was there for. But there’s no (easy) way to estimate what the influence (or the cost) of that error would have been if it wouldn’t have been found. Maybe what happened to Trend Micro was a good thing, because it illustrates the importance of testing.

I mean: it’s better to spend thousands of dollars more on testing than 8 million on repairing the trail of a bug later on, right?

Posted: Jul 15 2005, 09:51 AM by Rick van den Bosch | with 2 comment(s) |
Filed under:
ASP.Net 2.0
If you're interested in Visual Studio 2005, and especially ASP.Net 2.0, visit this site: http://beta.asp.net/ It's an official Microsoft beta site running ASP.Net 2.0. Including forum, a control gallery, tutorials, starter kits and many more!
Trying to find the right new look

We finally made the change to Community Server here at bloggingabout.net. Because of this, some stuff will change. One of them is the appearance of all the blogs. And I'm not entirely happy with the way my blog is looking right now. I guess it takes some getting used to. Maybe I'll switch a little the next days. If you think I should keep a certain skin (or loose it!): drop me a comment...

CoolToolList.Add(CLRProfiler);

Microsoft's CLRProfiler is a tool you can use to analyze the behavior of your managed applications. I've used it a number of times and it can be pretty helpfull in profiling your apps. According to Microsoft, these are its strengths and weaknesses:

Highlights

  • CLRProfiler is a tool that is focused on analyzing what is going on in the garbage collector heap:
    • Which methods allocate which types of objects?
    • Which objects survive?
    • What is on the heap?
    • What keeps objects alive?
  • Additionally:
    • The call graph feature lets you see who is calling whom how often.
    • Which methods, classes, modules get pulled in by whom
  • The tool can profile applications, services, and ASP.NET pages.
  • The tool can control profiling:
    • You can add comments that can also serve as time markers.
    • You can turn allocation and call logging on or off.
    • You can trigger a heap dump.
  • The log files produced are self-contained – you do not need to save symbol files and the like to later analyze the log file.
  • There is also a command-line interface allowing log files to be produced in batch mode.

Lowlights

  • CLRProfiler is an intrusive tool; seeing a 10 to 100x slowdown in the application being profiled is not unusual. Therefore, it is not the right tool to find out where time is spent – use other profilers for that.
  • Log files can get huge. By default, every allocation and every call is logged, which can consume gigabytes of disk space. However, allocation and call logging can be turned on and off selectively either by the application or in the CLRProfiler UI.
  • CLRProfiler cannot “attach” to an application that is already running.

Internals overview

  • The tool uses the public profiling interfaces that the CLR exposes. These work by loading a COM component that then gets called whenever a significant event happens – a method gets called, an object gets allocated, a garbage collection gets triggered, and so on.
  • The COM component writes information about these events into a log file (such as “C:\WINDOWS\Temp\pipe_1636.log”).
  • The GUI (Windows Forms application) analyzes the log file and displays various views.

I also found this video about the CLRProfiler, but I haven't had time to watch it yet...

Posted: Jul 12 2005, 01:04 PM by Rick van den Bosch | with no comments
Filed under:
Hair
Last weekend I went to see the musical Hair at the Stadsschouwburg in Eindhoven. It was played by an allmost all American cast: only the male lead was a Dutch guy, if I understood correctly. (Normally the female lead was Dutch too, but that role was played by someone else last saturday.) And I have to say: it was really great! Unbelievable vocals, great play and a pretty cool way to bring all those long forgotten beautiful songs back to life (Aquariuuuuus). Unfortunately last sunday was the last performance, so I would say 'go see it' but that's not possible. It was their last performance in The Netherlands last sunday.

To the entire cast: great show guys!
Howto: present a Crystal Reports report as a PDF in an ASP.Net web application (without using temporary files)
This one is actually quite simple: Crystal Reports supports exporting to a PDF. Exporting can be done to disk, or to a stream. And a stream can be written to the Repsonse property of a page. And there you go ;)

// Variable declaration
   CrystalTest crystalTest;
   MemoryStream memoryStream;

// Create a new instance of the report you want to display as a PDF
   crystalTest = new
CrystalTest();
// TODO: Add some stuff here to fill the report with data

// Export the report to a stream with the PDF format
   memoryStream = (MemoryStream)crystalTest.ExportToStream(ExportFormatType.PortableDocFormat);
// Set the ContentType to pdf, add a header for the length
// and write the contents of the memorystream to the response
   Response.ContentType = "application/pdf";
   Response.AddHeader("content-length", Convert.ToString(memoryStream.Length));
   Response.BinaryWrite(memoryStream.ToArray());
//End the response
   Response.End();

Developers! - Steve Ballmer on channel 9

View the interview Channel 9 had with Microsoft's CEO: Steve Ballmer. The interview in short:

Why does Microsoft care about developers?
01:11 Why does Microsoft have an evangelism team?
01:48 What is your call to action for developers right now?
02:44 Microsoft is a leader in transparency and blogging. Why did you allow blogging?
03:38 Time for some tough questions. On the blogs there are those that say that Microsoft doesn't innovate, can you give us some examples of where Microsoft is innovating?
05:42 Coming up with tough questions for you is hard. If you were in my position what tough questions would you ask Microsoft's CEO?
07:22 Since a lot of Microsoft employees watch Channel 9, what would you say to all the Microsoft employees around the world?
08:48 What do you want to be remembered as?

And of course ........ DEVELOPERS!

Online ClearType tuner
This Microsoft sites makes it possible to enable ClearType fonts in Windwos XP from a web interface (using Internet Explorer). Neat! There's a powertoy available also...

ClearType is a special way of displaying fonts that makes fonts stand out more on LCD screens. It's almost as if you're looking at a piece of paper with the words printed on it. Click here for more information on ClearType.
ASP.Net - Configuration error. Parser Error Message: Access is denied: somename.dll
My last message was about this strange error I received. Today I got it again, which led me to believe a hardware failure was not the reason. So after some more investigation I found out Index Server was to blaim. Taken from support.microsoft.com (click here for full article):

If you run Index Server (Cisvc.exe), then Index Server may rescan the Temporary ASP.NET Files directory while it requests a Microsoft ASP.NET page. Cisvc.exe then holds a lock on the Temporary ASP.NET Files directory for one to five minutes. The length of time of the lock depends on the size of the directory that causes the Aspnet_wp.exeprocess (or W3wp.exe process for applications that run on Microsoft Internet Information Services [IIS] 6.0) to not load the particular DLL.
ASP.Net error concerning referenced DLL

I've been using skmmenu for quite a while now, and I think it's great! But last Friday I was fooling around in Visual Studio, trying to make some fun stuff in ASP.Net, when I got a strange error about a reference. The information part:

 === Pre-bind state information ===
LOG: DisplayName = skmmenu
 (Partial)
LOG: Appbase = file:///c:/inetpub/wwwroot/Site
LOG: Initial PrivatePath = bin
Calling assembly : (Unknown).
===

LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Post-policy reference: skmmenu
LOG: Attempting download of new URL file:///C:/WINDOWS/Microsoft.NET/Framework/v1.1.4322/Temporary ASP.NET Files/site/5dd0cccf/c5f19367/skmmenu.DLL.
LOG: Attempting download of new URL file:///C:/WINDOWS/Microsoft.NET/Framework/v1.1.4322/Temporary ASP.NET Files/site/5dd0cccf/c5f19367/skmmenu/skmmenu.DLL.
LOG: Attempting download of new URL file:///c:/inetpub/wwwroot/Site/bin/skmmenu.DLL.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Post-policy reference: skmMenu, Version=2.2.1882.16908, Culture=neutral, PublicKeyToken=null


I tried a lot of things: iisreset, rebooting the machine, throwing away controls from pages, but to no avail. When I tried to clear my Temporary ASP.NET Files, all the directories seamed to be willing to be deleted, except for the one I was having trouble with. Even after a reboot and closing down IIS it was not removable. Explorer kept saying it couldn't read from the source... Finally, I ran a diskcheck on my hard drive, and it looked like that solved my problem! I'm guessing it had bad sectors.

I don't want to go so far as to say Visual Studio or the .Net framework mashed up my hard drive: that seems a bit much ;) But: when receiving errors you can't trace to (your) software, you should consider the source of the error may be somewhere in the hardware...