KevinUp

real world programming

Archive for October, 2008

code coverage

Posted by kevinup on October 20, 2008

I was recently talking to another developer about code coverage and it made me re-think about code coverage.

I had asked him what his code coverage was on this project, and he replied it was probably pretty bad, but that coverage didn’t matter. The quality of the tests mattered. His argument was that if you had good tests that is all you need. 

At first I agreed, I love high quality tests. I like the idea of having 2 high quality tests over 10 medium to poor quality tests. Depending on the quality of your developers that isn’t always possible to have high quality tests.  I’d rather take over a project with 70% coverage with average quality tests than one with <20% coverage with high quality tests. A high coverage number gives you a lot more confidence about your source code, and any potential changes.

I recently was on a project where we were adding items to a shopping cart. There were around 150 tests built around adding items to the shopping cart, and it broke all the time. The team was around 10 developers, and the issue was that developers didn’t have the time to run all 150 tests, which could take up to 5 minutes. So they would check in and move on without running the tests. (Yeah I know, not a good practice)

I went through and identified 3 tests which captured most of the base functionality. I asked all the developers to at least run those tests before checking code in. Coverage-wise they were probably only hitting 60% of the shopping cart logic. But because they were higher quality tests, and could be run in <30 seconds, we were able to have the best of both worlds.

Posted in .net, C#, Uncategorized | Leave a Comment »

Follow up : Case of the Mondays

Posted by kevinup on October 9, 2008

thought I’d follow up briefly to my Case of the Mondays post.

I’ve got some other pics which I might add to Picasa later, but this is probably the best one. The cop said the damage didn’t look so bad, once they put the car right side up. He thought a lot of energy was expended lifting our car up and turning it during the collision. The crater in our car was probably 20 inches at the deepest part. Part of the other drivers license plate was embedded in the crater as well.

The other driver was sited for ‘Failure to Yield’. When the cop was taking her statement she insisted that she had come to a full stop before accelerating again. The cop tried to explain to her that it was impossible to be at a full stop accelerate 20 feet, collide with another car and flip it. Some people are just stupid, ignorant or both. He estimated that her 2003 Impala was going at least 45 MPH, and due to the lack of skid marks, he felt she didn’t even try to stop.

After looking through the court records online, I found she had to pay a fine of $80 dollars. Eighty freaking dollars! Are you freaking serious!??. She could have killed the three of us. She had a Indiana license. I thought initially that she was from out of town and unfamiliar with the area. . But through the court records I found that she lives less than a half mile from our house. Give her no excuse for her reckless driving.

Of course she was unemployed and uninsured, so our insurance is covering our medical expenses, and car replacement. State Farm has been really good to us, so I’m probably a customer for life now. State farm is planning on going after her for the money its cost them so far, I estimate its probably almost 20k. I doubt they’ll get anything. One state farm rep suggested that they could help us sue her for ‘pain and suffering’. I think I’m just happy that we’re all ok, so we’re going to pass on that.

We bought a new Rav42008 last weekend. So in my mind we’ve been made as close to whole as possible.

Posted in Uncategorized | 5 Comments »

How do you implement a feature?

Posted by kevinup on October 7, 2008

I just got off an interesting interview with a potential client. It went ok. We had some intelligent conversations about WCF, Link, web services, a general work up. One questions that he kept circling around too left me baffled and struggling to understand what he wanted to here. He kept asking ‘How do you implement a feature.’

Typically I like the vague, open-ended questions. I felt like I could see where he was coming from. Some developer he’d probably worked with would over think a solution, gold plate it, and deliver it, and the end result was nothing that satisfied the specs. I know I’ve seen that happen to projects I’ve been on.

My answer, while I didn’t think was wrong wasn’t the answer he was looking for. I would write some unit tests that satisfy the requirements for the feature as best that I could. I would then create the classes that would be needed to pass those tests. I would then create and DB tables or fields as needed, or mock out any other dependencies that my code depends on. And wolah, feature implemented. Obviously there are some things you would do differently depending on your architecture or UI changes. But I think you could follow that methodology 80% of the time.

He didn’t like my answer. ‘Yeah but how would you implement a new feature?’ he would reiterate. I tried to rephrase or expand on what I was saying, but it didn’t seem to satisfy him. He rephrased his question a couple times and each time I couldn’t come up with something significantly different than what I had already told him.

So my question to anyone out there is ‘How do you implement a new feature’. What should I be doing differently? What am I missing?

Posted in Uncategorized | Leave a Comment »

vb

Posted by kevinup on October 6, 2008

I recently finished a seven month assignment. It wasn’t anything glamorous. It actually was somewhat miserable at times. The worst thing about it was the client wanted their solution in VB.net. At first I was thinking, that’s ok, I’m a multi-lingual kind of guy. I prefer C#, but I’ve done some VB.net in my past, so it shouldn’t be that big of a deal. The assemblies are the same, it always compiles down the same or similar IL right? While that’s all true, I could never be so wrong about being multi-lingual.

Let me start of complaining about the IDE. In C#, when I was creating a class, I would drop in my private properties first. Then traverse back through and simply right click on the properties, and select ‘encapsulate method’. The IDE would code out my public properties. This would allow me to create my classes pretty quickly. In VB.net you get nothing. I thought initially it was a mistake. I checked on a couple other developer machines, and I got the same result. So instead of it taking 30 seconds to create a class, it took 5 minutes of boring copying and pasting.

Next: There is no extract method. Like any good developer I like my methods to be short, quick, and concise. A good method will usually start out around 5-10 lines. As the code matures, it might get to 15-20 lines, which I consider the max a function should be. Above 20 lines, its time to refactor your code. At this point I like to evaluate the method and try and isolate a couple lines that are specialized enough to be its own method. At that point you can highlight those lines, right click, select ‘extract method’, and BAM!. Done. In VB, not so much.

Next: Nullable types. I love nullable types; I don’t know how I used 1.1 without them. In C# a nullable type is declared as: ‘int? myInt’. In vb you can to say: ‘dim myInt as Nullable(of Integer)’. If you do that a couple times it will make you want to shoot yourself. The same applies to generics. A generic list in C# is just: ‘List<int> myList’ in VB its ‘dim myList as List(of Integer).

Those are my main gripes about VB.net. I found it so frustrating that I went to the client multiple times to try and convince them that C# was better, with no luck. The application had been in production for 4 weeks and generated 2.5 million in revenue by time I left. They were impressed enough that they offered to hire me away but I had to turn them down with my number one reason being VB.net. Ironically the week I was leaving they decided all new development would be in C#, and re-offered me the job again. C’est la vie. Too little to late in my book.

Posted in .net | 2 Comments »