Wednesday, June 04, 2008
Posted on Wednesday, June 04, 2008 7:28:43 AM (Mountain Daylight Time, UTC-06:00)  Comments [4] | 
Categories: .NET | Devt Tools | Fundamentals | Unit Testing

This is the third and final part of a three part series summarizing the results of the 2008 Geospatial Developer Survey. For further information, be sure to check out read part one and part two

 

Use of Source Control Systems

This is where we start to see some divergence from the larger developer community.

 scc

Source control is as much a part of most developers lives as the language they use. It should be automatic and used by default. Subversion is good, and free. It's not trivial to setup, but with free subversion hosting services like Assembla.com, there is virtually no reason not use it. (btw - although I have an "Assembla" badge in my sidebar, I am not paid to endorse them - their service is solid and so I promote it).

Automated Build Tools

With more than half of the respondents not doing automated builds, we are seeing more of the separation from main-stream development.

autobuild-tools

All the choices on this question were .NET, but I also compiled the "Other - Please specify" results into a chart.

 autobuild-other

Unit Testing

There were 3 questions on unit testing, mainly because I see this as a key element raising the quality of GIS software projects. Unit testing is as much a philosophy about how you develop software as it is the actual writing of tests. Committing to doing unit testing really says you care about quality, and that you realize that manual testing, while valuable, is never as consistent as automated tests. So, with that we start with a look at what percent of projects are using unit testing.

Using_Unit-Testing

I don't know how this stacks up to other industries, but I'd say there is room for some growth here. Everyone talks about GIS getting on the "service bus", but we need to make sure that when we get on the bus, our code does not fail!

The next question basically asked why you were not doing more unit testing.

why-not-unit-testing

This is actually pretty good. I'd have to question the 14% who don't think it's valuable, but I'll chock that up to them not knowing what's really involved.

I've heard the "not-enough time" thing before, but the problem is that you will have bugs. And someone will find them. Better the developer finding them sooner than a client finding them later. Also, in terms of time, on big projects, I think you actually save time.Having automated tests, helps you prevent regression. Think about all the stuff that breaks between a big ArcGIS releases - that's regression, and that's what good automated tests can catch.  

Difficulty. This is true. Writing good unit tests is hard. Using good design patterns help, and good tools can ease the pain, but even still it's not easy. Writing unit tests for ArcObjects code is very difficult, but not impossible. In these cases, I focus the tests on the most critical parts of a system - basically putting the effort where it will payoff the most. For these areas, I shoot for 100% code coverage - if they are the most complex, I want to make sure that my tests cover all possibilities. Again, difficult, but if you are writing a complex spatial rule engine, that works with relationships between multiple layers, business workflows, and user permissions, there is no realistic way to manually test it on any sort of a regular basis.

The next question was "If tests were easier to write, would you write more of them?"

unit-tesing-easier

So, a resounding YES on that. This is great, because as a community we can actually make this happen. 

A couple years back I threw some code out there under the umbrella of "ArcUnit" - the files referenced in those posts are now gone, but it was some demo code that showed how to unit test geometry operations, by serializing geometries and storing them in the unit test assembly. The code is now on Assembla in the ArcDeveloper project, under TestingUtilities. Seeing as there is interest in this, I'll likely write some more articles on this.

Unit Testing Frameworks

Ok - the Java people really ripped on this question. After adding an "Other", I did tabulate the results for all that as well.

unit-testing-frameworks

This gets somewhat interesting - 60% of people said they are not using any tools, but back in the "What percent of your projects use unit testing" only 38% said "None". I guess some "homegrown" unit testing could explain a few percent, but... anyhow. Interesting that MBUnit and MSTest are so low. MSTest is baked into Visual Studio 2008 (Professional and above), and MBUnit is both free and awesome.

As for the "other", here's how that stacked up.other-ut-frwk

Apparently I could have saved myself a heap of greif if I'd just added jUnit to the list!

The final Unit Testing question went out to the edge - "What do you think of Test Driven Development"

tdd

So at least one zealot in the crowd aims pretty high! For the "No opinion" crowd, TDD is the practice of writing your unit test before the implementation. The intent of this is to essentially define the desired behavior in the test, then make the software behave in that way. No doubt this is difficult, and requires you to be a total unit testing & pattern guru. I *think* this is possible, even on complex projects like GIS, but you'd need to be working with a test friendly GIS framework (as in don't come asking me to build you an ArcGIS Server .NET ADF site using TDD!)

 

Code Refactoring

As you write code, there are times when you need to change it's structure - usually to conform to a pattern, to facilitate extensibility, or just because your function got long and messy (i.e. you're making maintenance easier!). This is called refactoring. The first question was related to how often you refactor your code.

refactoring

The second question related to the use of .NET Refactoring tools. I appologize again to the non-.NET people, but I don't know of any Java Refactoring tools.

net-refactoring

What's interesting here is that the "Not Refactoring" people are not even using the tools in Visual Studio. When we were doing a lot of desktop development, we used RefactorPro - mainly because they had good Visual Basic.NET support. Now that we're using C# and doing 99% web development, we are finding that the IDE tools / manual refactoring is sufficient.

Code Documentation Generation

This was a quick question on the use of automatic code documentation generators. They are pretty common in the larger developer community, and relatively easy to bring into the mix, and spit out some good API documentation. Worth the effort in my opinion.

doc-tools

 

Comments

Fifty-Two respondents left comments at the end of the survey. Most were constructive, and others... well... lets look:

WTF, no C++ on the list of languages? What language do you think the bulk of geospatial software (from GDAL to ArcGIS) is written in? C# is just a evil marketing ploy from MS to try to deflate Java's market; nobody is expected to actually _use_ C#.

Reply: Not having C++ was an oversight. As for your issues with C#, can't help you there.

Summary:

Overall, this was an interesting experience. Clearly I could do a much better job on the questions, and have a much wider range of options on the answers. I think it does show that geospatial developers are adopting main stream techniques and tools, just at a somewhat slower pace. Thoughts?

Download the results (Excel 2007 format)

Thursday, June 05, 2008 1:29:33 AM (Mountain Daylight Time, UTC-06:00)
You can also try to use Data Collection Portal for your surveys.
It has some nice features like conditional questions, dynamic tables (respondents can fill as many rows as they wish), attachments. Also XML export for local data processing is available.
In addition, printable PDF can be downloaded to fill the survey on the paper.
Friday, June 06, 2008 2:23:13 AM (Mountain Daylight Time, UTC-06:00)
Dave, you did a remarkable job. Congrats!. I completely agree with you that geospatial developers just started to use main stream tools and techniques. It takes some time to adopt these practices and procedures in thier process. ESRI can come up with good testing tools atleast for thier products considering having huge market under their belt. Anyway this survey surely helps us to review ourselves and for better startergy management.

Cheers
Friday, June 06, 2008 2:35:18 PM (Mountain Daylight Time, UTC-06:00)
I have to admit I almost never write unit tests. It really is a hassle when dealing with arcobjects. I've found a good technique guaranteeing correctness for your "most important" code is to write it in a manner that minimizes the amount of variables and uses recursion in place of loops. This usually makes writing a proof by induction easier then writing unit tests. It's not perfect because it doesn't catch future changes that break things and it's impractical if the code in question depends on a lot of different variables, but I've found it too work for a lot of cases, and it leads to higher quality code because it requires more forethought.
Brandon N
Wednesday, June 18, 2008 4:55:46 AM (Mountain Daylight Time, UTC-06:00)
Dave, this is a unique survey I can say..targeted at Geo-Developers.

Can you tell us the geographical distribution of responders.. if you have and can tell about region wise distribution (this might give the idea of geo-flavour of your readers)..
Comments are closed.