Agile Adoption in Geospatial Industry?

Posted by Dave Bouwman | Posted in Agile, Scrum | Posted on 20-09-2007

7

I’ve been talking to a number of people around the GIS industry lately, and when I bring up our use of Agile methods and Scrum, most people have had a pretty blank look on their faces. Once I explain the idea and the methodology most seem genuinely interested, and the most common response is – “that makes sense”.

Throw in the that that since adopting Scrum, our team has become more productive and focused that ever, and this seems to be a very common outcome. So I’m surprised that more people are not familiar with agile. 

In an attempt to see if anyone else in GIS is talking about agile and/or Scrum, I did some searching, and found this…

 agile-gis

Apparently these guys have had 6 conferences on “AGILE” and GIS. Unfortunately this has nothing to do with the wider “Agile” concepts as applied to software development (see the Agile Manifesto for more on this).

Anyhow, I continued searching. With the exception of my occasional post, Chris Spagnuolo’s blog, and some job postings from our company which note the use of Agile methodologies, I found only a few other things:

  1. A post on the MapButcher blog re: Managing GIS Projects which talks about Scrum
  2. A post on Human-Debugger (Shani Raba)’s blog about some Scrum experiences
  3. Paolo Corti has some posts on Test Driven Development (TDD), but they are related to his excellent series on MonoRail and the Castle Project.
  4. A description of an agile methodology used by Dynamic Ventures (off-shoring group) for all their project – including GIS.
  5. Infinity Solutions (also an off-shoring shop) also came up, but I could not actually find anything GIS related on their site.

There may be more, but was 5 pages into the search results and things were getting pretty far off base.

Development Trends outside of GIS

This lack of discussion about GIS and Agile is very interesting because in the broader software industry we are seeing a much different story. Anecdotally, I can say that the Certified Scrum Master classes we’ve looked into for other team members have been pretty full. The Scrum classes I’ve attended have been full and had a wide range of people in them – from senior “PMI” project managers to video game designers. We hear that there are many teams in Yahoo!, Microsoft and Google which have adopted scrum and other agile processes with great success. But lets look for some numbers to back some of this up…

Last year Scott Ambler did a survey about agile adoption (here’s Scott’s PowerPoint with all the data and some charts etc). He used the Dr Dobbs Journal (a long-running software development magazine) mailing list, and got 4232 responses.

Two questions were particularly interesting:

Have you adopted any agile techniques? – 65% Yes

Have you adopted an agile methodology? 41% Yes

So – assuming that this is a somewhat representative sample, 65% of the software industry have adopted some agile techniques and 40% have adopted an agile methodology. 

So why are we not seeing more discussion of agile in the geospatial industry? Is the GIS industry still caught in the waterfall? Thoughts?

Using MSBuild to Package Visual Studio Templates

Posted by Dave Bouwman | Posted in .NET, ArcDeveloper, Devt Tools | Posted on 20-09-2007

0

I’m in the process of creating a set of Visual Studio templates to share with the community – pretty simple stuff, but can be quite a time saver. In the past I’ve posted about how to streamline coding using templates, and while the process for packaging templates outlined in that post works, it’s pretty manual, and that’s not going to work if I’m going to maintain and grow these things. Enter MSBuild. But before I go into that, lets review how I’ve organized the solution.

The solution is called “ArcDevelper.Templates” – and it simply contains a bunch of other projects that contain the template files, as shown in the following graphic.

Template Solution Contents

Each project simply has the template file (class.cs for example), an associated icon, and the vstemplate file that tells Visual Studio how to transform the file. It’s important to note that I’m are just using Visual Studio as an editing environment, and the solution as an organizational scheme – we do not actually “build” anything in the traditional sense.

First off the projects would not compile because the still have string parameters in them that get replaced when the templates are run (see my previous post on templates for more). What we want to do is package the files so they can be used as “templates” – this is where MSBuild comes in.

The MSBuild Script

The other thing I have in the solution is a build.xml file that actually extracts out the files, puts them into zip files and moves them to my “ItemTemplates” folder. With this in place, I can easily make changes to my templates, re-run the build script, and have the updated templates immediately available.

In order to make this work, I had to use MSBuild “batching”, which is not exactly intuitive. Without getting into too much about MSBuild (Google it – there’s ton’s of info around), when creating the itemgroup that will be fed into the target (the actual zip & copy), you need to create some metadata for the items, and then use the Outputs attribute of the Target to subset the items by some of the metadata. As an old client of mine used to say - clear as mud. Maybe this will help…

  <ItemGroup>

    <Projects Include=$(SolutionDir)\csclass>

      <path>$(SolutionDir)\csclass</path>

      <zipname>CSClass</zipname>

      <itemname>Class</itemname>

    </Projects>

    <Projects Include=$(SolutionDir)\vbclass>

      <path>$(SolutionDir)\vbclass</path>

      <zipname>VBClass</zipname>

      <itemname>Class</itemname>

    </Projects>

  </ItemGroup>

This is the Item Group that lists the templates (projects) that we will be working with. The path, zipname and itemname sub-elements are the metadata I was talking about. This is then used by the target…

  <Target Name=Build Inputs=@(Projects) Outputs=%(Projects.ZipName)>

    <!– Create a list of the files in the output folder–>

    <CreateItem Include=%(Projects.path)\%(Projects.itemname).*>

      <Output TaskParameter=Include ItemName=FilesToZip /&gt
;

e="margin: 0px;">    </CreateItem>

    <!– Zip the files–>

    <Zip Files=@(FilesToZip) ZipFileName=$(BuildFolder)\%(Projects.zipname).zip  Flatten=true/>

  </Target>

The target specifically notes the inputs and the outputs. Apparently by specifying a metadata item in the outputs forces MSBuild to group / subset the items (depending on how you want to think about it) by that item. In my case, the item is unique – so I get the effect of simply looping over the list.

Anyhow – now I’ve got this all working smoothly, so I’ll add some more stuff into the templates, and then load it up into the ArcDeveloper.net Subversion repository over at SourceForge. I’ll post about the actual templates when they are up there.

Windows Live Writer Publish Date Weirdness…

Posted by Dave Bouwman | Posted in Blogging | Posted on 19-09-2007

0

Windows Live Writer is a pretty good off-line blog editor in most ways, but one thing that just does not make sense to me is the setting of the publish date.

I can understand that you may want to publish something at a future date, and that’s great – but it seems like there is something amiss in it’s defaults.

When you start a post, the publish date is not set…

wlw-pub-date1

If I use the pull down to expose the calendar to set the date…

wlw-pub-date2

it does not seem to re-set the TIME – note 7:15pm is still set. Ok – so what – the time is off by a few hours. The issue comes in RSS and aggregation, where the time stamps will control the order in which posts appear. So, my post on Visual Studio Memory Use (posted about 10 minutes before this one) may actually appear to be pinned to the top of aggregators like PlanetGeospatial and ArcExperts until the post date & time pass.

Anyhow – if you are using WLW, this is something you may want to be aware of.

Visual Studio Memory Use…

Posted by Dave Bouwman | Posted in .NET, Visual Studio 2005 | Posted on 19-09-2007

2

My system was acting kind of slow, so I popped up Task Manager to see this…

dev-env-memory

This is a new personal best in terms of memory use by Visual Studio 2005 (devenv.exe) – 900 Mb.

Granted, I have 26 projects open but this is out of hand.

sol-exp

When I’ve looked into this in the past I have not seen any info on memory leaks etc, but if that’s not the issue, then how how how does this process expand to this size? I re-started Visual Studio and now I’m back at a much more manageable 400Mb. Sigh.

Sneak Peak: ArcDeveloper.net…

Posted by Dave Bouwman | Posted in ArcDeveloper, Community | Posted on 17-09-2007

1

I spent some time this weekend re-tooling the ArcDeveloper.net web site. Here’s a quick look…

arcdev-peek

I’m building it on top of the open-source, ASP.NET based, ScrewTurn wiki engine, with a few custom pages and a forum package thrown in. I’m still tweaking some of the CSS, some graphics and a few pages, but I hope to have it up for some beta testers later this week. If you are interested in kicking the tires, use the Contact link at the top of this page to let me know.

I’m also looking for people who may want to post some articles on the site (kinda like a stripped down, GIS-centric CodeProject). These will be kept in a separate secure sub-wiki, so you don’t need to be concerned about someone else messing with your stuff.

How To: Communicate Between ArcMap Commands/Forms/Tools

Posted by Dave Bouwman | Posted in .NET, ArcGIS Devt, ArcMap | Posted on 11-09-2007

3

A couple of times I’ve seen people asking about how to share information between forms/commands/tools etc. in ArcMap and I thought I’d create a simple example of how I’ve been doing it.

Problem

At a high level, the problem is pretty simple – one part of your application needs to know about the state of another part. One example could be a combo box tool control that allows the user to select an Active layer, and you have other tools/controls/forms etc that need to know what the active layer is, and need to be informed when the active layer changes.

Solution

This is an obvious case where custom events are going to come into play, since they are the standard way to provide notification of a state change to a set of “subscribing” or listening classes. In standard .NET applications, you’d create an event right on the actual source – in this case the tool control. However, since we are working in ArcMap, we have a slightly different situation. Since we (developers) do not control the load order of tools/commands etc in ArcMap, it’s rather difficult to effectively sink up event handlers and sources if they are all located in your customization classes (ICommand/ITool etc). This is because we don’t really know when either class is actually instantiated during the load process, and once it’s instantiated, it’s a pain to actually get a pointer to it.

The way to solve this is to route the events through something that’s always loaded, and easily accessed – such as an application extension (IExtension).

Since application extensions (with the exception of JIT Extensions) are always loaded when ArcMap is starting up, we know it’s always present. Regardless of when the event source tool / form / command is initialized, it will always be able to call a method on the extension, which then raises an event. The same it true for the classes handling the event – since the extension is loaded and accessible, they can wire up an event handler during their initialization, or any time after that.

ex-event1

While there are other ways to pass “state” around, using an event allows a whole set of classes to then subscribe to the event and be notified when changes occur.

ex-event2

Once you think about it, this is quite obvious, and it is a small scale mirror of much of the ArcObjects customization API – write a class, wire it into ArcMap, and have it respond to ArcMap events. Except in this case, it’s our own custom event.

Sample

The sample is in C#, and is kept very simple, so the focus is on wiring the events.

Extension:

The extension has a public SetSelectedItem method, which in turn raises the SelectedItemChanged event.

Commands:

There are two commands – EventSourceCommand and EventSinkCommand. In the onCreate function, both commands get pointers to the event extension, and pass this into the IntializeUI methods on the forms. The Event Source Form has a simple combo box listing 5 fruits. In the OnChange event of the combo box, the form calls SetSelectedItem on the extension. The Extension raises the SelectedItemChanged event, to which the Event Sink Form has  subscribed, and a label is updated to show the currently selected fruit. Although it’s a bit complex when you read it, this is very simple when you look at the code, and run it.

Since the sample is in C#, it uses event wiring involving delegates. If you are new to delegates, O’Reilly has a good article – Writing C# Custom Events, which I would recommend. The syntax is much simpler in VB.NET, and here’s a CodeProject article on that. Of course you can use delegates in VB.NET if you want to, so for completeness sake, here’s an article on events using delegates in VB.NET. Moving on…

To run the sample, download the code, compile it, and run ArcMap. You should get a pop-up box as ArcMap is loading which tells you that the Event Extension is loading. Once ArcMap is started, open up the Customize dialog, and look in the DaBo.Samples category.

event-tools

Drag the Event Sink and Event Source command onto a toolbar, and then run them. Both commands open forms. Use the pulldown on the Event Source Form to update the label on the Event Sink Form.

event-sample

When you dig into the code you’ll see that I’ve used the out of the box templates for the commands and extension. The only other “cool” thing I threw in was the ArcMapWindow class I wrote about previously.

Have fun wiring up your events!

Download Sample

Scripting SQL Server Databases

Posted by Dave Bouwman | Posted in .NET, ArcSDE, SQL Server | Posted on 07-09-2007

1

I ran across a very handy open-source tool today that I thought I’d share… but first some background…

Our current project requires that we support 4 simultaneous run-time configurations – Development, Testing, Training and Production. The application has the capability to switch between these on the fly, via  a convenient pull-down menu. 

dbp_switch_config

Changing the configuration is actually somewhat simple – we just close the current map document, set a new “repository connection” and refresh the UI. From there, the application will start using the configuration in the active repository. Great.

Well, today I needed to actually create these 4 repositories. More specifically I needed to create 4 databases with the same schema AND the same data (as a starting point anyhow). In the past I had used a CodeSmith template that would write out both the schema and all the insert statements to re-populate it, but that was a pain to use. I did a little searching and found the Database Publishing Wizard which is a part of the SQL Server Hosting Toolkit on CodePlex (you can get the source!).

From the site…

The tool supports two modes of deployment:

  1. It generates a single SQL script file which can be used to recreate a database when the only connectivity to a server is through a web-based control panel with a script execution window.
  2. It connects to a web service provided by your hoster and directly creates objects on a specified hosted database

For me, I just needed the SQL script that would re-create the entire database with data. What’s nice (besides being free) is that this integrates into Visual Studio’s Server Explorer…

dbp-vs-integration

The the output is a text file with all the SQL to re-create the tables, views, stored procedures etc. and their contents. I was able to just drop this into SQL Management Console, and run it against the other 3 databases. Since it’s just T-SQL, I can also upload it to our client’s site, and run it there to populate their databases as well.

Command Line

A final gem in this tool is that it can be run from the command line – thus allowing you to effectively source control a database schema and data. While you would not want to do this for spatial data, it would work very well for configuration data. You could write a simple MSBuild script that would check out the copy from source control, use this tool to dump the database to that file, and then check it back into source control. Then you could execute this script anytime you want to update the copy in source control. Anyhow – the command line give you lots of options for integrating into your development process.

Parenting Forms to ArcMap the Easy Way…

Posted by Dave Bouwman | Posted in .NET, ArcGIS Devt, ArcMap | Posted on 05-09-2007

1

While I was at home, away from my source tree at work, I was looking to correctly parent a form to ArcMap. By parenting a form to ArcMap, it will be minimized with ArcMap, and will always stay in front of ArcMap – important if you want to have multiple forms up at the same time, and what them all to be visible!

In the past we’ve always used the Win32 API ’s SetWindowLong function – which we wrapped up a little in a helper class. Not having the source to look at, or the helper class to use, I needed to figure out the syntax. To complicate things, I was also writing the code in C# – it’s those subtle changes that will always mess you up. After finding the PInvoke site, and locating the SetWindowLong function there, and being somewhat confused about how to get an IntPtr from Application.hWnd, I did a search in the ESRI forums. Low and behold I found this recent post (July 31, 2007) by Berend Veldkamp in which he provides a very simple way to parent a form to ArcMap.

In .Net 2.0 it’s possible to pass a parent window to the Show method of your form. This should be an object implementing IWin32Window, here’s a basic example of how to do that in VB.Net 

Doh! Amazing what you overlook because you’re used to doing things the old way – I had no idea that Form.Show had a parent option. Anyhow, I’ll let you get the VB.NET version from the forum post – here’s the C# version: 

 public class ArcMapWindow : System.Windows.Forms.IWin32Window

 {

    private IApplication m_app;

 

    public ArcMapWindow(IApplication application)

    {

        m_app = application;

    }

 

    public System.IntPtr Handle {

        get { return new IntPtr(m_app.hWnd); }

    }

 

 }

Now, to show a form parented to ArcMap, all I need to do is…

form.Show(new ArcMapWindow(m_application));

This is much simpler and avoids the Win32 API call. Thanks Berend!