Naked programmer ponders values

In an e-mail, Garth Patil writes:

I just read your Linux Magazine article on the Naked Objects framework. ... I've been dinking around in their source, and I can't figure out why all of the Java primitive data types need to be duplicated in the framework. Do you know of an example of why these duplicates are necessary? For example, looking through the source, I can't figure out what the advantage/necessity of using TextString over String. Anyway, I'm probably missing something huge, and I was hoping you could help me out.

That was a big question for me also -- it seemed redundant. Creating new objects for values such as currency, dates, and text hooks them into the framework and expose these objects and their methods to users, which isn't possible with String and the wrapper classes for Java's primitive types.

In a "How Naked Objects works" article included with the Naked Objects download, developers Richard Pawson and Robert Matthews explain it this way:

The reason for introducing these new types, specific to the Naked Objects framework, is that they allow these value objects to be exposed directly to the user. The programmer could add other classes of naked value-object specific to a business need, for example Temperature, or Length. (It is considered good object programming practice to encapsulate a value with its unit of measurement e.g. Metres). From the user's perspective these values appear as formatted text.

Add a Comment

All comments are moderated before publication. These HTML tags are permitted: <p>, <b>, <i>, <a>, and <blockquote>. This site is protected by reCAPTCHA (for which the Google Privacy Policy and Terms of Service apply).