Programming Languages – What Do You Call Classes Without Methods?

classdata structuresnamingprogramming-languages

What do you call classes without methods?

For example,

class A
{
  public string something;
  public int a;
}

Above is a class without any methods. Does this type of class have a special name?

Best Answer

Most of the time: An anti pattern.

Why? Because it faciliates procedural programming with "Operator" classes and data structures. You separate data and behaviour which isn't exactly good OOP.

Often times: A DTO (Data Transfer Object)

Read only datastructures meant to exchange data, derived from a business/domain object.

Sometimes: Just data structure.

Well sometimes, you just gotta have those structures to hold data that is just plain and simple and has no operations on it. But then I wouldn't use public fields but accessors (getters and setters).