Created
October 10, 2017 05:17
-
-
Save buiquangduc/9cd409dc49e32f1b98524c615f041826 to your computer and use it in GitHub Desktop.
Improve routine with procedural cohesion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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