Anyway have you ever seen a class like this:
Code: Select all
class Rabbit
{
public function __construct($age, $weight, $cuteNess)
{
$this->add = $age;
$this->weight = $weight;
$this->cuteNess = $cuteNess;
}
}
$flopsy = new Rabbit(1.2, 3.1, 0.86);
echo $flopsy->cuteNess;Firstly why is this so? And if so how the hell are you supposed to "move in behaviour".Design Smells wrote:Data Class
Description: Classes with fields and getters and setters and nothing else (aka, Data Transfer Objects - DTO)
Refactor: Move in behavior with Move Method
Back to the real world, I'm using a data class to store a bunch of properties about a video. URL, title, width, height etc. I'm using MVC so obviously the output is determined by a view. Given the fact that the only behaviour in this case is to be rendered to the browser and a view is going to handle that what am I supposed to do? I don't need any behaviour.
Discuss