CodeSOD: Universal Stream

This post was originally published on this site

The Daily WTF

Twenty years ago, Stefano Z worked with some Very Smart Very Senior Engineers. These Very Smart Senior Engineers liked to find all sorts of “interesting” solutions to common problems.

For example, they had a module in C++ that needed to send data to other systems. To formalize this messaging, they needed a set of Data Transfer Objects (DTOs). Now, there are many libraries that might make generating these kinds of objects easier, but the Very Smart Very Senior Engineers didn’t want to use a library. So they started out with just large piles of hand coded:

class Book : public DTOCommonBaseClass { private: string _title; string _author; //many more fields public: //Constructors, and getters and setters for all fields //and one big serialization method };

Then, to use them, you’d have to write the tedious:

Book myBook; myBook.SetTitle(title); myBook.SetAuthor(author); //more properties

No, none of them had a constructor

To read the full article click on the 'post' link at the top.