Created
August 11, 2014 14:59
-
-
Save getify/80c8c68276dbda50bfc7 to your computer and use it in GitHub Desktop.
articulate the differences in these two snippets. which one is "easier"? which one is "simpler"?
This file contains hidden or 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
function XYZ() { | |
X(); | |
} | |
function X() { | |
// do X | |
Y(); | |
} | |
function Y() { | |
// do Y | |
Z(); | |
} | |
function Z() { | |
// do Z | |
} |
This file contains hidden or 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
function XYZ() { | |
X(); | |
Y(); | |
Z(); | |
} | |
function X() { | |
// do X | |
} | |
function Y() { | |
// do Y | |
} | |
function Z() { | |
// do Z | |
} |
The dependency graph is totally different in both.
In the first one X
is dependent on Y
, Y
on Z
etc.
In the second one X
, Y
and Z
are totally independent of each other.
I'll prefer the one which actually reflects the business domain correctly.
#1 makes me want to die.
(xyz (x (y (z)))
(xyz (x) (y) (z))
Both are wrong. In a true enterprise application, function XYZ would be written as
function XYZ() {
// do X
// do Y
// do Z
}
(Note: tongue planted firmly in cheek)
The latter!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I would prefer the second one, it gives the right picture when I look at XYZ and then summarize on what it does and how it does things..
Easy to understand and easy to explain ...