Tim has been working on a large C++ project which has been around for many, many years. It’s a tool built for, in Tim’s words, “an esoteric field”, and most of the developers over the past 30 years have been PhD students.
This particular representative line is present with its original whitespace, and the original variable names. It has been in the code base since 2010.
Assignment::Ptr ra = Assignment::makeAssignment(I,
addr,
func,
block,
RA);
The extra bonus is that Assignment::Ptr
is actually an alias for boost::shared_ptr<Assignment>
. As you might gather from the name shared_ptr
, that’s a reference-counted way to manage pointers to memory, and thus avoid memory leaks.
The developers just couldn’t tolerate using the names provided by their widely used library solving a widely understood problem, and needed to invent their own names, which made the code less clear. The same is true for makeAssignment
. And this pattern is used for nearly every class, because the developers involved didn’t understand object lifetimes, when to allow things to be stack allocated, or how ownership should really work in an application.
This is hardly the only WTF in the code, but Tim says:
Preceding the 98 standard, there is a LOT of C-with-classes code. But this representative line speaks to the complete lack of thought that has gone into much of codebase. That whitespace is as-is from the source.
Utilize BuildMaster to release your software with confidence, at the pace your business demands. Download today!
Source: Read MoreÂ