views:

219

answers:

11

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.

+1  A: 

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.

Samuel Carrijo
In POXO there could be logic too.
Jani Hartikainen
Have to disagree there. POCO in common use means Plain Old CLR Object, and a POCO may have methods. The implication (especially for persistent objects used with O/RMs) is that the class need not descend from a specified base class.
TrueWill
+1  A: 

In Java a class with only properties and getters/setters for each property is called a bean or POJO (Plain Old Java Object)

RMorrisey
True JavaBeans must implement `Serializable` and have a no-argument constructor. POJOs don't have these restrictions.
Pascal Thivent
+6  A: 

POD - Plain Old Data

JaredPar
+1, but wondering if it's still POD if it contains getter/setter methods
Daniel
+10  A: 

Sometimes these are called DTOs - Data Transfer Objects.

Matt Wrock
DTOs are meant to be **transfered** across layers, not sure it's the case here.
Pascal Thivent
+1  A: 

Data Transfer Object more commonly referred to as a DTO.

Noah Campbell
+1  A: 

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.

JasonTrue
A: 

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."

Tuples are usually immutable (in Python and F#, anyway). Also, they're actually not quite as rigidly typed as a class; only the order and types of each element matters.
JasonTrue
In the example the type called User is the cartesian product of three other types: string, string, and Role. The elements of a cartesian product are always tuples (in this case triples). So the type is called a "tuple type" because of this. Many languages (F#, Python, etc.) also have support for using a tuple but shouldn't be confused with the term 'tuple type' used here.
I can understand your point, but the semantics of a tuple type in a functional language generally mean that it's immutable; the getters/setters in the type described mean that there's behavior, even though it's rather minimal. Tuple types don't generally have behavior of their own, especially behavior that allows you to change the state of the object.
JasonTrue
+3  A: 

How about: struct ?

Mike Dunlavey
A struct in C# refers to something semantically different from a class. see http://msdn.microsoft.com/en-us/library/ah19swz4(VS.71).aspxIt is similar in the sense that it is just a thing that holds data.
L. Moser
A struct can have methods, too.
Rob Sobers
@Rob: Yeah I know, but to us C-dinosaurs it's a reminder of home :-)
Mike Dunlavey
A: 

Data Object, Data Transfer Object, DTO

Agha Ahsan
+1  A: 

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.

MusiGenesis
+1  A: 

"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.

George Jempty