I, for one, would be happy to contribute to a fund to hire professional engineers to produce a spec.
Same here - question is, if someone started such a fund, would BF and the volunteer developers even pay attention to it? That is to say, if we crowd-sourced money to get a few full-time engineers to run all the versions on a test network and develop a protocol spec - in the end, would anyone be remotely interested in it? Esp. since we have a main dev. who is opposed to having a protocol specification (or at least so I've read.) And other devs just don't seem too keen on the whole idea.
Note that I have nothing against the devs, not here to spank them or whatever; just being realistic about their opinions regarding developing specs. I know they work hard. I just want more direction, focus, a cleaner approach to development that encourages alternative clients operating via a well-defined protocol.
On the other hand, maybe BF would eventually hire more full-timers to do that - work on cleaning code, writing protocol, testing, etc. The boring stuff that no one wants to do but is essential to not doing this whole ad-hoc thing with spaghetti code filled with magic numbers. Or maybe someone will start their own foundation that will perform this function and work with BF and the current developers.
Oh yeah, and magic numbers, another pet peeve of mine. Someone posted an IRC paste of Gavin just yanking a projected yearly % increase in broadband out of his butt (based on past numbers, so of course will be accurate in the future) and suggesting basing one of our "magic numbers" in the code on that. Not picking on Gavin, but there's a bigger problem that is illustrated by that kind of thinking.
This thread has some great thoughts and ideas; we need to figure out what to do to make some of these things happen. I could donate more money to BF but for all I know, they aren't even remotely interested in developing a spec or de-tangling the code so who knows, maybe I'd just be contributing to the problem.
I don't like the sentiment that if you don't know how to code, don't complain - there are dozens of other ways one can take action. Organize a bounty/fund, donate to a fund, raise awareness via discussion, donate to BF, install & test patches and alt. client for people who do code, etc.
It would be great if I didn't have to run bitcoind behind armory... their reason for relying on bitcoind basically boils down to "It's spaghetti with no defined protocol spec, what the heck do you expect us to do?" although they explain it nicer than that.
On spaghetti code, I would venture some advice that has worked for me over the decades. Upon "inheriting" some "old code", that "just has to work", I work on a "parallel" version, keeping the original for "current production" and the new for "eventual replacement".
The "parallel" version is not a "refactoring" or rearranging of the code in any fashion, at least not initially. I worked in C and before that assembler, but I see a lot of C in the bitcoind code!
First one must have all the code "in view" and as much in one's head as possible. And using the best IDE and tools one has, begin to first name things properly. This means everything, from class definitions to instance names, methods, member variables. And very important, no magic numbers, like method_name( argument_variable, 0 ). What is the 0? What does it represent?
For example, I am looking at db.h, ~line 117 in the CDB.Read template area. And there is a magic ssKey.reserve(1000);
OK what does the 1000 represent? Is it important? Does it matter? Shouldn't it be a
const intergal_type Meaningfully_named_Value = 1000;
I know how it is when one is "in the zone", and coding. Documentation is superfluous and slows one down! And in the 1970s, especially, less so in the 1980s, and basically no more in the 1990s and on, variable names were no longer restricted to 8 or 16 characters, or 32 characters (of significance), etc. And [floppy] disc storage didn't force a lot of "vertical" compression (read K&R style here). Nor horizontal compression (read no spaces between operators and operands here). I see a lot of that "residue" in the code.
Just renaming things doesn't change the executable, AFAIK, in a release build. So I would globally, with a careful global search and replace, acknowledging each replacement, names that are obviously too terse, obscure or no longer even representative of what they are, with more meaningful names.
I have done this with some God awful C chess code, to good effect some time ago. One finds dead code, duplicate globals, etc. etc.
It is tedious but neccessary, and the result will be the same .exe file but the code will start to look readable.
I have had many an argument with "upper management" about spending the time to make a code base readable and where the names truly reflected what they are. Otherwise I am constantly translating with a symbol table in my head, what everything means. I hate that, and I hate having to remember things that I know I shouldn't have to! Example, what is the instance bitdb, see line 29 in db.cpp rally a class of? Then what is the Class CDBEnv{} really? Is it a BerkeleyDB or a LevelDB, or a ? Of what? Wallet, block chain info? I keep digging, hoping to find a comment or some "action" that might nail it down to something definite. Then I can rename it from bitdb to something more meaningful.
I propose that style of renaming, rearranging, etc. that leaves the executable, byte for byte identical. Maybe then we can see the beauty of the forest thorough the ugly arrangement of the trees. I think the .h files especially need a lot of "work". I see hodge podge lines of extern this or that sprinkled in .h and .cpp files!
I would propose this sort of "one to one transformation" of the code to start with, and then it may become easy to: find the bugs that are there, add new "stuff", enhance old "stuff", etc. etc.
BTW, I am doing it myself, off to the side anyway, since I hate K&R style, and all the stuff mentioned above, and more (LOL)
Ron