Skip to content

Instantly share code, notes, and snippets.

@buiquangduc
Created October 10, 2017 05:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save buiquangduc/9cd409dc49e32f1b98524c615f041826 to your computer and use it in GitHub Desktop.
Save buiquangduc/9cd409dc49e32f1b98524c615f041826 to your computer and use it in GitHub Desktop.
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