1

What is the benefits of using Java Field<String> vs String except for the cloneable possibility?

We have a system that seems to use Field<String> here and there for no obvious reasons (into which I also put "we have done like that before").

4
  • 2
    Which Field do you mean? Specify the fully qualified path. Or is it a custom one? Commented Feb 16, 2012 at 10:52
  • You mean the reflection field vs a normal String? I don't get the question. Commented Feb 16, 2012 at 10:56
  • 3
    Are you allowd to use Field directly or do you have to Field<Field<String>> ... ouch, recursing into deep space ;) Commented Feb 16, 2012 at 10:56
  • Some kind of property effort? Commented Feb 16, 2012 at 11:17

1 Answer 1

3

This Field<String> is a field (concept) that can hold a String type value, while a String is just a String.

To understand the why, you'll have to look at the code (the oldest parts of the code base, where this class has been used). Maybe, they wanted to handle database fields via a common interface or base class. I wouldn't look for technical benefits (cloneing, performance, ...), there should be a design decision (at least, I hope, there is one).

Once you found the real reason, you can start to fighting all abuses of the concept (aka - "we always did it that way")

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.