I have question based on the following fragments of "Clean Code". Those have been cited before, but I wanted to ask more basic question.
(...) the difference between objects and data structures. Objects hide their data behind abstractions and expose functions that operate on that data. Data structure expose their data and have no meaningful functions. Go back and read that again. Notice the complimentary nature of the two definitions. They are virtual opposites. This difference may seem trivial, but it has far-reaching implications.
Procedural code (code using data structures) makes it easy to add new functions without changing the existing data structures. OO code, on the other hand, makes it easy to add new classes without changing existing functions.
The complement is also true:
Procedural code makes it hard to add new data structures because all the functions must change. OO code makes it hard to add new functions because all the classes must change.
(...) would be a lot less confusing if data structures simply had public variables and no functions, whereas objects had private variables and public functions. (...)
This confusion sometimes leads to unfortunate hybrid structures that are half object and half data structure. They have functions that do significant things, and they also have either public variables or public accessors and mutators that, for all intents and purposes, make the private variables public, tempting other external functions to use those variables the way a procedural program would use a data structure. Such hybrids make it hard to add new functions but also make it hard to add new data structures. They are the worst of both worlds. Avoid creating them. They are indicative of a muddled design whose authors are unsure of—or worse, ignorant of—whether they need protection from functions or types.
And the question is: according to Clean Code, is it okay to add a single constructor to a plain data structure?
I want to follow the advices very precisely, but I'm finding it quite tedious to initialize each field in a new line. On the other hand, adding a constructor is adding a method, which are unnatural to data structures. Maybe being forced to explicitly name each of the initialized fields also brings some value.