Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Improve routine with logical cohesion
<?php
// Example of routine with logical cohesion
function update($name, $input) {
switch($name) {
case 'person':
// Stuff to update person with input data
break;
case 'car':
// Stuff to update car with input data
break;
case 'building':
// Stuff to update building with input data
break;
}
}
// You can separate this routine to three routines like this
// If the operations above use some of the same code or share data, the code should be moved into a lower-level routine
updatePerson($input);
updateCar($input);
updateBuilding($input);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment