Monday, June 29, 2015

My thoughts after 10 years of software maintenance

I have been paid to maintain software systems for the last 10 years now. I've rarely started developing a system from scratch, so I guess we could say I've mostly maintained existing systems. This is probably the norm. Also, thanks to the open source movement, I've also seen the source code to at least as many systems I've worked on professionally, and I believe my conclusions still hold for those systems as well.

Managers often push for features first, and quality attributes later. This is understandable, and I don't think changing that focus would be a good idea, except :

- Improving software attributes first (such as speed, reliability, resource consumption, usability, maintainability) might open the door to new features which wouldn't have been possible before. If the system can calculate its results quickly, we may be able to provide feedback to the user quicker, in a more user-friendly way. If its UI is resizable, it may be usable on tablets. 
- A lack of focus on the system quality attributes will lead to a costly rewriting from scratch.

I have seen both cases first hand, and often times, because of a lack of leadership in programming conventions, speed standards or testing, programs slowly degrade to the point of having to be rewritten. That's a no-brainer. The new program might have a slightly different feature set, but the development team will have to prove itself to the client and develop quickly, at the risk of having the project cancelled. As a result, quality becomes once again an after-thought. It's something left for the maintenance team to deal with. This vicious circle repeats itself over and over, and good programmers often move on before they can make a lasting impact on the health of the program. 

My advice would be to continuously maintain standards in the code as well as in the development lifecycle, and have managers allocate time for working on the quality attributes of the system as well, probably as a percentage of the feature development time. Use that time to 
- correct things that have been left for later, 
- write unit and integration tests, etc.

Wednesday, June 17, 2015

.Net assembly loading problem

So I had a problem at work today. I built my .net winforms application in visual studio, copy the bin/ and 
make sure I can start the application locally without issue. Then I hand it over to someone else, and 
boom, the application won't even load, with this dialog box popping up.


I didn't have the option to debug the program, and I couldn't reproduce the problem where I was. 
So I had to find another computer, change the application build mode to Console, so my 
Console.WriteLine would actually show up. I've traced the problem to a missing DLL.

The issue was that a certain library wasn't deployed in the bin/ directory Visual studio built, but it 
So the solution was easy, once the problem was identified.
But this got me thinking, how can I detect this sort of problem ?
I've started playing with DebugDiag, and build my own little application which throws an Exception 
Since now I know beforehand what the problem was, I could focus on which tools allow me to debug it. 

was in the GAC for me.

when clicked. I've managed to generate dumps, and load the actual exception. But I couldn't get it to 
work with my real program. Debug simply didn't recognize my application crashing.

So I found three tools/solutions :

Method 1 : FUSLOGVW.exe (Assembly Binding Log Viewer)
C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\x64

The tool itself is horrible. It won't log anything unless you set up the custom log path. Once that is done,
 here we go :

Method 2 : Ilspy.exe : (
  1. Simply load the main .exe file, and explore each referenced DLL. Here, The Krypton 
  2.  library just won't show up.

Method 3 : Process Explorer
This one is tricky. Add custom load rules in process explorer as follows

And look for failed dll lookups in the application directory :

Bonus points :
The event viewer was my key to success in this case :

But it didn't mention which file and why.

On some other computer, I didn't even get the famous error dialog box, so
I had to enable it :

Saturday, June 13, 2015

Jiu-jitsu and weight training

About half a year has passed since I've injured my knee badly enough to require surgery.  I remember a very sharp and sudden pain following a pretty loud pop : the sound of my medial meniscus giving up as I was playing open guard.

To be fair, a white belt kicked me hard a few weeks back as I was standing to pass, and I had pain for a few weeks before. On the day of the second injury, I remember my body needing a rest, and I didn't listen to it. In the BJJ community, we are used to minor bruises, and that's what I thought that was. Bit big bruises can turn into big ones, that was my first lesson.

Thinking back, I am actually not angry anymore, and I don't regret it having happened to me. I've  learned that my quadriceps muscles needed to be strengthened post-surgery, as a way to delay the onset of osteoarthritis. They say that a 10% increase in knee extensor strength reduces the onset of OA after 25 years by 20%. So far, I've probably increased my strength by at least 50%.

I therefore had to change my training a little bit. I had to sacrifice two days of jiu-jitsu in order to hit the gym. Since I've learned the value of using my whole body when working out, I naturally gravitated towards free weights, and compound exercises specifically. This, despite the fact that a mixed of open and closed cycle exercise rehabilitates after a knee injury faster (machines and weights). I've discovered the deadlift, squat and clean and press, and I'm very thankful that I did.

The deadlift felt odd at first. I was surprised by how little weight I could support. My back was definitely weak. As the weeks went by, I've increased the weight gradually, and to be honest, I have never had such a stable core in my entire life. Almost gone also is the pain I had between one of the vertebrae in my lower back. The squat gave me significant increases into my leg power, and I could feel the difference when I skated just today. I know also understand why my passing has improved so much with so little training. Sweeping me got a little harder than it used to.

Finally, the clean and press, is for me, the exercise I feel the most beneficial. I use low weights and high reps, and since it's basically a combination of deadlift, upwards pull (clean) and a shoulder press, it works pretty much every muscle I care about, while also giving me a solid anaerobic cardio workout. It's hard to complete four sets without going out of breath.

All in all, I have changed my perspective about training jiu-jitsu. I strongly feel one should complement it with some other sport or activity in order to protect against injury. I recommend everyone to evaluate their body, and strengthen it accordingly if participating in full contact sports such as jiu-jitsu, judo or wrestling.