The truth about software design.....
Posted: Wed Jan 17, 2007 6:04 pm
> p.s. Thanks everyone for all the help with how C++ works. I understand
> much better now. (And, I feel your pain...
So, I'm reading this thread and laughing my ass off. Why? Because it was a detailed analysis by some smart people who obviously know C++ very well of hobocopy. And I wrote hobocopy, and I don't really know jack shit about C++ - I just barely remember enough from when I used to write it to keep myself out of the worst kinds of trouble.
This was my favorite comment:
> This code is demonstrating a principle of API design (for
> which surely there must be a name, but I don't know it)
> which says the type of [in] parameters should be as generic
> as possible, while the type of [out] and [ref] params should
> be as concrete as possible.
Because what that code was actually demonstrating was that Craig started out working with LPCTSTR, got annoyed by how hard it was to use the CRT string manipulation routines, switched to wstring briefly, couldn't figure it out, then found CString which looked more System.String-like, then had all sorts of horrendous allocation problems and decided "fudgie it - everything gets allocated on the stack", then spent a few hours wrestling with C++ reference semantics until he got the program to run without crashing and without leaking. And never bothered to change the parameter from LPCTSTR to CString because I was too lazy and the damn thing worked anyway.
So the whole thing sort of reminded me of a bunch of literature professors analyzing the diary of an eight-year-old.
Not that the advice you guys gave wasn't useful - I certainly learned something!
> much better now. (And, I feel your pain...
So, I'm reading this thread and laughing my ass off. Why? Because it was a detailed analysis by some smart people who obviously know C++ very well of hobocopy. And I wrote hobocopy, and I don't really know jack shit about C++ - I just barely remember enough from when I used to write it to keep myself out of the worst kinds of trouble.
This was my favorite comment:
> This code is demonstrating a principle of API design (for
> which surely there must be a name, but I don't know it)
> which says the type of [in] parameters should be as generic
> as possible, while the type of [out] and [ref] params should
> be as concrete as possible.
Because what that code was actually demonstrating was that Craig started out working with LPCTSTR, got annoyed by how hard it was to use the CRT string manipulation routines, switched to wstring briefly, couldn't figure it out, then found CString which looked more System.String-like, then had all sorts of horrendous allocation problems and decided "fudgie it - everything gets allocated on the stack", then spent a few hours wrestling with C++ reference semantics until he got the program to run without crashing and without leaking. And never bothered to change the parameter from LPCTSTR to CString because I was too lazy and the damn thing worked anyway.
So the whole thing sort of reminded me of a bunch of literature professors analyzing the diary of an eight-year-old.
Not that the advice you guys gave wasn't useful - I certainly learned something!