I've been reading a lot lately (on Agile development, Domain Driven Design, Test Driven Design and a myriad of other OOAD topics) and for the most part have been left with more questions than answers.
In Robert Martin's excellent
Agile Software Development, just about all the classes in his code samples use read/write properties. No explanation is given for why this approach is taken.
This seems to run contrary to the idea of data integrity, which would seem to suggest that as few class properties as possible should be made writable. I don't want to expose my classes to the risk that clients will (out of negligence or incompetence) corrupt my object's state by making all properties writable.
I guess my ultimate question has to do with object creation. Before doing all this reading, my philosophy was to design classes with entirely read-only properties and a non-default constructor that took the parameters needed to create the object.
But this approach assumed that that objects were responsible for creating themselves. Robert Martin's book in particular illustrates a new (to me) approach in which objects are created by factories. This seems to require that many, if not all, of a class' properties must be read/write so that the factory class can set the object's various attributes. Given this pattern of object creation, what's the point of having non-default constructors, since class initialization is being orchestrated outside of the class in question?
I look forward to reading people's responses.