Skip to content

Instantly share code, notes, and snippets.

@getify
Created August 11, 2014 14:59
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save getify/80c8c68276dbda50bfc7 to your computer and use it in GitHub Desktop.
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"?
function XYZ() {
X();
}
function X() {
// do X
Y();
}
function Y() {
// do Y
Z();
}
function Z() {
// do Z
}
function XYZ() {
X();
Y();
Z();
}
function X() {
// do X
}
function Y() {
// do Y
}
function Z() {
// do Z
}
@gs-akhan
Copy link

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 ...

@neebz
Copy link

neebz commented Aug 11, 2014

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.

@nickgiardina
Copy link

#1 makes me want to die.

@evrim
Copy link

evrim commented Aug 12, 2014

(xyz (x (y (z)))
(xyz (x) (y) (z))

@readysetmark
Copy link

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)

@AmaanC
Copy link

AmaanC commented Aug 16, 2014

The latter!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment