Hi folks,
I'm thinking about an advice for better application design I recently read in a few blogs or articles, which I'd like to share with you. Of course I'd be happy to hear your opinions and experiences on this topic. The idea is to create an extra type, i.e. a class, for everything in the code which represents a meaningful concept in the problem domain. For example the authors write that you shouldn't even use a plain
String type but instead create a class which has a meaningful name in the domain even if it doesn't do much more than just encapsulate this String.
At first sight this seems to be a lot of work which doesn't add too much value to an application. This could mean to create a lot more classes which could possibly become confusing especially if you don't take care for reasonable naming conventions. Although I've not yet really thought about how much plain Strings I would have to replace because they are more meaningful for the domain than just a simple String.
On the other hand as I currently have to work with a typical legacy application. I can often see the benefit you would get from such a concept. In the said application almost everything is very generic and there are not very much custom types although the application is quite big. Basically everything is a String or even worse an Object. And maybe you have lists or maps to group some of these Strings and Objects. The rest of the application consists of relatively few but really huge "classes" (some are > 10.000 lines). As you might guess it's similar to large files of C code with just the file ending replaced with .java
To make things even worse a lot of parameters, members, methods or variables are named very badly. In part because some pieces of code where duplicated or moved with simple copy & paste in the past without adjusting identifier names to fit the new context. Then it often happens that you just see 3, 4, 5 or 6 parameters of type String or Object and even the names of identifiers can't tell you what's really meant with a particular String or Object, i.e. what could be valid values for these parameters, variables or whatsoever. Of course there is no documentation or
test which could clarify the meaning either.
Has anyone ever used the said concept in a real application? What are your thoughts about this idea? Is it worth the trouble? Maybe just to some degree?
Thanks in advance for your opinions!
Marco