Sunday, March 21, 2010

How to improve the code readability/maintenability

After reading this thedailywtf-Unit-Tested article.
I thought that i can add my knowlege how switch from bad code to readable code.

The main concept of the article that i read, that if you add code coverage and a lot of unit test, its great way to improve the software project. And this is only half of the true.

The true is, that when you upgrade to testable code , you just change some code metrics .
This metrics can be calculated by your IDE, the name of the metrics is Coupling and Cyclomatic Complexity.
After that i am play with this metrics (in this game, you need to reduce as much as possible the coupling and CC), the readability of my code is improved drastically and the bugs start to disapear.

Saturday, February 27, 2010

How to boostup the netcf development

Last month i worked on relatively large netcf application.
The problem begins when the executable of program start to be larger then 2 megabait (mostly because of graphics).
The application start to take more than minute of startup time.
So i can't change the program on the fly, as in my usual dotnet development.

Solution: i created new empty project. the project was with same dotnet version, but worked on full dotnet (non netcf).
And add all sources of original project.
Then on "project property"->build-> "conditional compilation symbol" i add DESKTOP.
In every place where the dotnet doesnt work like netcf if added compilation time "#if ,#else, #endif".
(Other possibilty is to use Environment.OSVersion.Platform (that contains PlatformID.WinCE))

There it is, I receive project where i can work as usual, and only when i am done with all small tasks, i am starting with the real netcf work.