Many times I experience that if I want to make a not-tight coupled system, it helps to be independent but also hurts the cohesion. Example:
model:
$record = Doctrine::getById(1);
// $record is now a bean: UserClass with getters
view:
<body>
<?php echo $record->getName().'; '.$record->getId(); ?>
</body>
this is bad since now this view is coupled to UserClass
. I can refactor it to be independent:
model:
$record = Doctrine::getById(1);
$name = $record->getName();
$id = $record->getId();
view:
<body>
<?php echo $name.'; '.$id; ?>
</body>
now view is maximum independent - but also loses its cohesion. At the first solution, the data are in one place (UserClass
) and cannot be scattered - unlike now. We can easily introduce a but which may cause that $id
is a from another record while $name
is from another?