Instantly share code, notes, and snippets.

Embed
What would you like to do?
Improve routine with procedural cohesion
<?php
// Example of routine with procedural cohesion
// Imagine that you have a input screen that display the input fields in the order: email, name, address,.. of employee
function getNameEmailAddressInputEmployee() {
// Stuff to get the input name
// Stuff to get the input email
// Stuff to get the input address
}
// You can refactor the routine above for better cohesion, like this
function getInputEmployee() {
getInputName();
getInputEmail();
getInputAddress();
}
// Separate operations in their own routines and make sure that the calling routine has a single, complete job like getInputEmployee() above
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment