When a class is too simple, it can become an anemic class. This can lead to having other classes that handle the business logic for a class, which, according to Martin Fowler, is antithetical to the principles of Object Oriented Programming.
According to Fowler on his website, anemic classes are "little more than bags of getters and setters", and can be hard to spot as they often appear to be normal classes.
Anemic from Wikipedia
class Box
{
public int Height { get; set; }
public int Width { get; set; }
}
Non-Anemic
class Box
{
public int Height { get; private set; }
public int Width { get; private set; }
public Box(int height, int width)
{
if (height <= 0) {
throw new ArgumentOutOfRangeException(nameof(height));
}
if (width <= 0) {
throw new ArgumentOutOfRangeException(nameof(width));
}
Height = height;
Width = width;
}
public int Area()
{
return Height * Width;
}
}
If we are creating a class without business logic, it goes against the reasons for using the object oriented model in the first place.
By encapsulating all business logic in the class and making sure that classes don't perform the business logic of other classes. We also should take advantage of the core principles of object-oriented design by combining data and processing them together.