Skip to main content
  1. Tags/

Dotnet

Design guidelines – again

·1 min

I saw a presentation monday to explain the basics of .NET to some starting developers. In that presentation, I saw a piece of code design I don’t think should be showed. Ever. Especially to people who are about to enter the .NET world. In one cs-file, I saw a base class, two inheriting classes and then again two classes which inherited from on of the former mentioned classes. So there were 5 public classes in one file. A shiver ran down my back …

The conditional operator (? :)

·2 mins

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:

DataSets vs Classes

·1 min

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 …)

·2 mins

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?

ASP.NET 2.0

·1 min

If you’re interested in Visual Studio 2005, and especially ASP.NET 2.0, visit this site: https://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!

CoolToolList.Add(CLRProfiler);

·3 mins

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:

        <LI class="MsoNormal">
          <SPAN lang="EN-US">Which methods allocate which types of objects?</SPAN><br /> <LI class="MsoNormal">
            <SPAN lang="EN-US">Which objects survive?</SPAN><br /> <LI class="MsoNormal">
              <SPAN lang="EN-US">What is on the heap?</SPAN><br /> <LI class="MsoNormal">
                <SPAN lang="EN-US">What keeps objects alive?</SPAN>
              </LI></UL>
              <br /> <LI class="MsoNormal">
                <SPAN lang="EN-US">Additionally:</SPAN><br /> <UL type="circle">
                  <br /> 
                  
                  <LI class="MsoNormal">
                    <SPAN lang="EN-US">The call graph feature lets you see who is calling whom how often.</SPAN><br /> <LI class="MsoNormal">
                      <SPAN lang="EN-US">Which methods, classes, modules get pulled in by whom</SPAN>
                    </LI></UL>
                    <br /> <LI class="MsoNormal">
                      <SPAN lang="EN-US">The tool can profile applications, services, and ASP</SPAN><SPAN lang="EN-US">.NET</SPAN><SPAN lang="EN-US"> pages.</SPAN><br /> <LI class="MsoNormal">
                        <SPAN lang="EN-US">The tool can control profiling:</SPAN><br /> <UL type="circle">
                          <br /> 
                          
                          <LI class="MsoNormal">
                            <SPAN lang="EN-US">You can add comments that can also serve as time markers.</SPAN><br /> <LI class="MsoNormal">
                              <SPAN lang="EN-US">You can turn allocation and call logging on or off.</SPAN><br /> <LI class="MsoNormal">
                                <SPAN lang="EN-US">You can trigger a heap dump.</SPAN>
                              </LI></UL>
                              <br /> <LI class="MsoNormal">
                                <SPAN lang="EN-US">The log files produced are self-contained – you do not need to save symbol files and the like to later analyze the log file.</SPAN><br /> <LI class="MsoNormal">
                                  <SPAN lang="EN-US">There is also a command-line interface allowing log files to be produced in batch mode.</SPAN>
                                </LI></UL>
                                <br /> <P class="MsoNormal">
                                  <SPAN lang="EN-US"><A name="_Toc54579204"><STRONG>Lowlights</STRONG></A></SPAN>
                                </P>
                                
                                <br /> <UL type="disc">
                                  <br /> 
                                  
                                  <LI class="MsoNormal">
                                    <SPAN lang="EN-US">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.</SPAN><br /> <LI class="MsoNormal">
                                      <SPAN lang="EN-US">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.</SPAN><br /> <LI class="MsoNormal">
                                        <SPAN lang="EN-US">CLRProfiler cannot “attach” to an application that is already running.</SPAN>
                                      </LI></UL>
                                      <br /> <P class="MsoNormal">
                                        <SPAN lang="EN-US"></SPAN><SPAN lang="EN-US"><A name="_Toc54579205"><SPAN lang="EN-US"><STRONG>Internals overview</STRONG></SPAN></A><SPAN lang="EN-US"></SPAN></P><br /> 
                                        
                                        <UL type="disc">
                                          <br /> 
                                          
                                          <LI class="MsoNormal">
                                            <SPAN lang="EN-US">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. </SPAN><br /> <LI class="MsoNormal">
                                              <SPAN lang="EN-US">The COM component writes information about these events into a log file (such as “C:WINDOWSTemppipe_1636.log”).</SPAN><br /> <LI class="MsoNormal">
                                                <SPAN lang="EN-US">The GUI (Windows Forms application) analyzes the log file and displays various views.</SPAN>
                                              </LI></UL>
                                              <br /> <P class="MsoNormal">
                                                <SPAN lang="EN-US">I also found <A href="https://msdn.microsoft.com/msdntv/episode.aspx?xml=episodes/en/20030729CLRGN/manifest.xml">this video</A> about the CLRProfiler, but I haven't had time to watch it yet...</SPAN></SPAN>
                                              </P></p>
      

ASP.NET error concerning referenced DLL

·2 mins

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: