Tuesday, April 28, 2009

LoC and FxCop

I was curious on how many lines of codes we are working. There were only nebulous guesses of around 100.000 locs – but no official ones. So I googled a bit and found CLOC, a counting tool for lines of code. I ran it on my ActiveX- and DotNet-folder and it calculated:

·         80,000 loc VB.NET and 40,000 lines of comments in VB.NET

·         410,000 loc VB6 and 310,000 lines of comments in VB6

·         20,000 loc C++ and 5,000 lines of comments in C++

The good number of comments in VB6 might result of the huge header we gave each file and a rather big header for each method. In VB.NET this is more dense.

 

Another tool on my way to a great developer is FxCop. This program can examine a dll if certain rules are broken. You can select and deselect single rules or whole rule-sections. The rules are made by Microsoft but you can build your own rules and add them. When you run the program, it lists all violation and you can either try to fix them or if you disagree, you can exclude them with a comment.

FxCop

Wednesday, April 22, 2009

Moving to blogger

I decided to move this blog outside of the MCC-wiki. The content isn't MCC-specific (actually, I deleted the 'hot'-company-stuff) at all and I want to write something about my private projects too.

So, here it comes: after working a bit with WPF (approx 4 months) and trying ASP.NET (approx 1 month), I started a ASP.NET Silverlight project with the brand new Virtual Earth Silverlight Control. You can add UIElements to the map and give them coordinates so that they will move with the panning of the map. This means a way of possibilities:

'todo: upload Picture

Monday, April 20, 2009

Unit tests and how to trick ExpertsExchange

I'm glad I got accustomed to writing tests. It's not fully TDD, but I try to write a test as soon as possible (at least I'm not doing test-last). To never forgot writing a test I divided my IDE into two codeviews:



In the upper view is the productive code, in the lower view the corresponding unit tests. If a tests fails, I open the test result in the lower section and can navigate through the error-proven code easily.

One word on testing events (as I stumbled over it last week): with C# and anonymous methods it's quite easy to write tests for throwing events. With VB.NET not supporting anonymous methods, you have to find another way: I'm using TestContext.Properties(TestContext.TestName) = True at the moment. This code is in my event-handler and changes a TestContext-Property. I think it looks better as using a global variable.

You know ExpertsExchange? Every time I search something related to coding via Google, I get a hit for ExpertsExchange. But unfortunately, you have to pay for an answer: you only see empty boxes instead of the answer if not being a member. But thank god there is Google cache which has access for a free answer: just scroll down all the way and voilá, the boxes are filled:



By the way: I know now how to embed pictures. Google chrome doesn't show the 'upload picture'-frame immediately :/

Thursday, April 9, 2009

Public Property Get IntValue() As Long


I'm reading Framework Design Guidelines from Microsoft at the moment. Great book, similar to Code complete, but one layer above. All brilliant people of Microsoft have contributed to these guidelines, among them are Anders Hejlsberg (Mr. C#), Paul Vick (Mr. VB.NET) and Phil Haack (Mr. ASP.NET MVC). Anyway, as I'm reading it, I get a different look on our sourcecode. For example, I stumbled over:

Public Property Get IntValue() As Long

Great, isn't it? The more you think about it, the more abstruse it gets. I'll better stop it, I almost feel dizzy ;)

Thursday, April 2, 2009

TimeSpan and EDF

I noticed two things while playing with EDF. TimeSpan.TotalSeconds is inaccurate on some computers. Probably the value is calculated by using the ticks-property. Unfortunately, this leads to a double which can have the wrong number. I made a t = TimeSpan.FromSeconds(3.2) and got t.TotalSeconds = 3.1999999999997. When using that in a calculation and casting the result to an Integer, you can get a wrong number - like me...

Speaking of wrong numbers brings me to my 2-day-EDF-problem. I desperately tried to create a sup-file made of dummy-EDF-files. The code is actually quite simple: new clsAufzeichnung, Meas_Sections.Add(dummy-EDF-file), SaveAufzeichnung, done. This works when you have set the HeaderLength of the EDF-file - unlike me...