Replace Record With Data Class

Described on page 110 of MartinFowler's RefactoringImprovingTheDesignOfExistingCode:
"You need to interface with a record structure in a traditional programming environment."
"Make a dumb data object for the record."

In traditional structured languages that directly support records (Pascal), struct-ures (C++), or user-defined Types (VisualBasic), one often finds dumb data structures to which you want to add behavior. Take the opportunity to convert them to first-class objects, encapsulate the member variables (EncapsulateField), and join the OO revolution!

	VisualBasic: VbClassicRefactorTypeToClass -- changing user-defined "Type" to a COM class.
	C++: CppRefactorStructToClass -- changing "struct" to "class" (a trivial exercise ;-)

Revolution? What demonstrable benefits does this "revolution" provide? --OO-critic

[Object oriented programming makes you more appealing to members of your preferred gender, gives your car improved mileage and performance, cures headaches, and walks your dog on those chilly mornings when you'd rather lie in bed. Furthermore, a significant number of developers have found object oriented languages preferable to purely procedural languages, for a variety of (mostly) subjective reasons.]

View edit of February 12, 2009 or FindPage with title or text search