Reputation: 21145
I'm looking for a standard way to communicate to another programmer that a class is a essentially just a data container.
Take this simple User
class for example:
class User
{
public string userName { get; set; }
public string passPhrase { get; set; }
public Role role { get; set; }
}
"That component makes use of the User class, which is just a (insert here) class."
I want to say "data model", but I think that's too broad. Classes described as data models often have logic.
Upvotes: 4
Views: 824
Reputation: 19634
Data Transfer Object may be correct, depending on the intent. It's essentially a container, but "container" is overloaded and generally refers to collection types.
Value Objects can have behavior, but if you have two independently created value objects with the same field values, and they can be treated as equivalent (e.g. the identity of the record doesn't matter), you could say that what you have is a value object. But usually Value Objects are best when immutable.
When there are a lot of Data Transfer Objects in a design, the design is sometimes pejoratively referred to as an Anemic Domain Model.
Upvotes: 1
Reputation: 12561
"Value object" is more precise in this case than is "Data Transfer Object". A value object contains just values; a Data Transfer Object additionally should implement a method for transferring that data to or from itself to or from some other entity. "Bean" is also an accepted term particularly within Java circles.
Upvotes: 2
Reputation: 75336
This isn't standard, but I often attach the "Info" suffix to a class name to indicate that the class is just meant to store and transfer information. So I would change your User
class to UserInfo
.
UserData
would work, too, as would a "don't add any methods to this damn thing" comment at the top.
Upvotes: 1
From A Gentle Introduction to Haskell
"A type like this is often called a tuple type, since it is essentially just a cartesian product of other types."
Upvotes: 0
Reputation: 7739
In Java a class with only properties and getters/setters for each property is called a bean or POJO (Plain Old Java Object)
Upvotes: 1
Reputation: 17939
POXO - Plain Old X Object, where X is the language of your choice. Your case, seems like C#, so that's a POCO: Plain Old C# Object.
Upvotes: 1