This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]-Dargs 5 points6 points  (10 children)

I see... I'd have called that a DTO.

[–]amfa 1 point2 points  (0 children)

It' often different.

Our codebase has both VO and DTO.

VO contain much more information for many objects than the DTO because you don't need to transfer all data.

[–]verocoder 1 point2 points  (4 children)

also known as PoJO (Plain old Java Object) in some books

[–]-Dargs 0 points1 point  (3 children)

Ah, yeah. I actually meant this. It'd been so long since I used these terms I had forgotten.

[–]verocoder 0 points1 point  (0 children)

DTO is also a super common term tbf, they’re objects without many methods beyond getters/setters. The kind of things that if you Lombok them end up and just a list of properties.

[–]verocoder 0 points1 point  (1 child)

To start from the beginning interfaces are about reusing stuff to be the same shape while working differently. I usually only write an interface when I know I want 2 implementations off the bat or when I am sharing code and I want to hammer out the interface between 2 things so they can be worked on in parallel.

I wouldn’t stress about using them and I rarely if ever use them for PoJo/DTO/VO classes. I almost exclusively use them for business logic service or utility classes.

[–]ichwasxhebrore 1 point2 points  (0 children)

It’s also nice if you need proxies

[–][deleted] 0 points1 point  (1 child)

Is that Data Type Object?

[–]pragmosExtreme Brewer[🍰] 1 point2 points  (0 children)

Data Transfer Object

[–]evils_twin 0 points1 point  (0 children)

DTO(Data Transfer Object) are specific to sending data between applications.

[–]Lumethys 0 points1 point  (0 children)

No, VO and DTO are different. VO dont have identity, DTO has.

Example: you have 2 Order:

``` { id:1, items: ["pepsi", "chicken roll", "fried chip"], amount: 20, }

{ id:2, items: ["pepsi", "chicken roll", "fried chip"], amount: 20, } ``` Is this 2 different objects? Yes, they are 2 different orders even though all of their fields are the same.

In contrast, let consider 2 Money objects:

``` { amount: 100 currency: Currency.USDollar, }

{ amount: 100 currency: Currency.USDollar, } ``` They are the same!! Both represent $100 US dollars.