DEV Community

Discussion on: Why test POJOs?

Collapse
 
aminmansuri profile image
hidden_dude • Edited

Are we using terminology correctly here?

I always understood "POJO" to mean "Plain old java object" and first saw it with the introduction of Spring where Services were just "POJOs" ie. they didn't inherit from some weird framework but used inversion of control to get other services injected. So POJO to me meant just plain old java objects without weird framework dependencies. (en.wikipedia.org/wiki/Plain_old_Ja...)

What is being discussed here is a "Value object" an object that just has getters/setters that stores data, and in that sense is nothing more than a glorified struct. (en.wikipedia.org/wiki/Value_object)

Am I getting my terminology wrong?

Collapse
 
scottshipp profile image
scottshipp

It's more that people commonly misuse the term POJO so that in common slang usage it really could mean any of POJO, JavaBean, value object, or more.

Collapse
 
moaxcp profile image
John Mercier

I always thought of value objects as immutable (no setters). A POJO can have setters. I think lombok's @Data and @Value provide good standards.

Thread Thread
 
aminmansuri profile image
hidden_dude

It may be a good practice for a value object to be immutable but it's not required.

POJO just means any Java object that doesn't depend on a weird framework.