You were just handed a strange DSL implementation, it does stuff, and it may be cool, but you have no idea how it works.
Craig Neuwirt recently did a major overhaul of Windsor ( I am going to post soon with the details of how cool it is now ), but I am now faced with the question, how do you grok such a thing? I thought that it would be useful to put a list of what I am doing to understand how the internals now works.
It goes without saying, but the nitpickers will ask, that a DSL implementation is code like any other, and as such, it can have good & bad implementations. I think that what Craig has done was amazing. It makes for an interesting reading, I actually had to take notes, to make sure that I will not miss any of the cool stuff.
- Understand the domain.
This is critical, because if the DSL is chicken scratching to you, you won't be able to get the implementation.
- Get the tests.
First things first, make sure that you have tests that ensure that you can understand what the DSL is supposed to do. In addition to that, it allows you to debug a simplified scenario repeatedly, so you can walk through that and figure out what is going on.
- Take the simplest scenario and run it, then open the resulting DLL in Reflector
This is important, because you need to be able to see what the differences are between the DSL and the actual executed code are. This allows you to understand in a deep level what the various elements of the language do.
- Identify a transformation, and follow how it is being built throughout the code
It will allow you to understand the concepts and patterns used through the code.
- Follow each transformation throughout its own code path only
Fairly often you can get side tracked by trying to put the entire program in your head, this is usually not possible, track a single path through the code to completion. After that, you can start tracking other paths, but it is important to have an understanding of the full cycle, and then expand from that.
Hm, not really that different from how I would approach an unfamiliar code base, come to think about it.