Tips for ensuring quality in complex code
#1 Members - Reputation: 1862
Posted 23 February 2012 - 10:10 AM
I've gone through and done many of the best practices I am aware of where possible.
- There are decent error messages where errors occur.
- I've made the code pessimistic towards errors (even if we might continue through an error, just die).
- I've automated unit tests.
- I've focused on having something that works, and then incrementally adding functionality, verifying regression during each step.
- I've kept things relatively isolated so that changes are similarly isolated.
- I've got debugging symbols in the code generation so that I can debug through that as needed.
...and a number of others that I can't think of since I take them for granted...
I understand that the nature of the problem will cause the work to be difficult, but I suspect that I'll need to learn/develop new techniques since most of the ones I have for different sorts of programs are unusable. Advice?
I'm the only one working on the project, and it's in C# with MSVS if that matters.
#2 Members - Reputation: 1031
Posted 23 February 2012 - 11:18 AM
Here's a few ideas for improving debug performance:
- Memory allocations are a whole lot slower if you start the program with the debugger attached, because that makes Windows enable the debug heap. Try starting it normally and attaching afterwards.
- Turn off the "basic runtime checks" in the project settings. They kill the performance of small functions for little benefit. Edit: I think this only applies to C++ and not C#.
- Turn optimizations on / off with more granularity than the whole solution. Do it per file or function if need be.
#4 Members - Reputation: 1862
Posted 23 February 2012 - 12:35 PM
Adam_42, on 23 February 2012 - 11:18 AM, said:
Eh, no. The 'don't profile debug builds' guideline prevented me from thinking through that. The majority of the runtime is likely in a big nasty recursive generator that does a number of small allocations. I'll look into the other options, though stepping through the thing isn't exactly the nicest thing in the world either.
SiCrane, on 23 February 2012 - 11:45 AM, said:
Indeed. What sort of things have you used/do you recommend? I'm not using anything at the moment. We use FxCop here at work and it does a good job at enforcing consistency, but maybe not so much at providing product quality as opposed to nice source code. I'm not sure that would fall into this category.
#5 Moderators - Reputation: 2382
Posted 23 February 2012 - 01:02 PM
#6 Moderators - Reputation: 3314
Posted 23 February 2012 - 02:18 PM
I'm not just trying to be a smartass here, either; I'm serious. One of the killer traits of most painful code bases is that they tend to be very complicated beasts. If you can reduce that complexity in any way, debugging and optimizing both become much easier.
For instance, if you have a hand-written parser, try replacing it with a table-driven one based on a known-good generation tool. Write code in terms of generic operations instead of inheritance and virtual dispatch. When in doubt, change implementation techniques or even languages if you think you can reduce the amount of code that is involved.
The Epoch Release 12 candidate code is smaller, faster, and much easier to understand than R11 ever was. It's a huge pain to recompile the parser because it's a complicated piece of code, and templated code generation is very slow and memory-intensive at that level - so it remains one of the few areas I don't touch any more often than absolutely necessary.
Code generation, though, has become almost trivial, since it's basically just a traversal of the semantically-decorated IR tree and a lot of simple data transforms. Even though I'm working in C++ and don't have real language features like pattern matching/decomposition, it's still pretty compact and clean code. Semantic analysis itself is a lot simpler, since I'm now working in terms of a genuine AST instead of a mongrel demon-spawn conglomeration of weirdness.
I guess what I'm getting at is, if at all possible, find ways to rearchitect your code so that it is simpler. This almost always means it will get more powerful and faster at the same time, assuming you're generalizing correctly.
[Work - ArenaNet] [Epoch Language] [Scribblings] [Journal - peek into my shattered mind]
#7 Members - Reputation: 330
Posted 23 February 2012 - 06:08 PM
If you're at the point of asking how to simplify, picture how you'd start from scratch.
#8 Members - Reputation: 1862
Posted 23 February 2012 - 07:22 PM
return0, on 23 February 2012 - 06:08 PM, said:
No it's great advice, my 'don't rewrite, refactor' guideline prevented me from thinking much about that; especially for something I've already mostly re-written a half dozen times. I need to stop that behavior, but there is some opportunity to be had. Better to take a few steps back then a few longer steps forward than sitting here with an idle project like I've had I suppose.
Good advice all around; keep it coming.
#9 Members - Reputation: 796
Posted 29 February 2012 - 11:57 AM
Telastyn, on 23 February 2012 - 10:10 AM, said:
Have you considered writing your own debugger for tangent?
#10 Members - Reputation: 118
Posted 29 February 2012 - 05:01 PM
#11 Members - Reputation: 618
Posted 01 March 2012 - 07:14 AM
[EDIT]
I read the topic at work where I could not reply and then replied many hours later at home. I forgot it was C#, and my reply may not be relevant.
[/EDIT]
L. Spiro
L. Spiro Engine: http://lspiroengine.com
L. Spiro Engine Forums: http://lspiroengine.com/forums
#12 Members - Reputation: 1862
Posted 01 March 2012 - 08:11 AM
RobTheBloke, on 29 February 2012 - 11:57 AM, said:
Telastyn, on 23 February 2012 - 10:10 AM, said:
Have you considered writing your own debugger for tangent?
I've not. Since it compiles down into CIL, visual studio actually does a good job of debugging compiled Tangent code with minimal effort on my part.
The issue in the original post is debugging through the C# the compiler is written in. (not sure if that was clear)
#14 Moderators - Reputation: 2382
Posted 01 March 2012 - 02:03 PM


















