I've been thinking about the definition of "simple" for a while now, spurred by things like "Real Simple" magazine, which is essentially a vehicle for advertisements for more stuff to buy that clutter up your life.
Some people see doodads, like remote controls, as simplifying your life, while others see the remote control as something cluttering, requiring maintenance and another doodad, a locator when it's lost.
In trying to create my own definition for simple, I think of small programming examples like the samples below. While it's a very straightforward case, I've seen developers on both sides claiming one is more "simple" than the other:
A very clear, but verbose, chunk of code:
public bool IsGreaterThanThree(int x)
{
bool isGreaterThanThree;
if (x > 3)
{
isGreaterThanThree = true;
}
else
{
isGreaterThanThree = false;
}
return isGreaterThanThree;
}
A very terse chunk of code:
public bool IsGreaterThanThree(int x) { return (x > 3); }
My questions to you:
- Which do you find more "simple" and why?
- Is there an objective measure of simplicity, either in terms of development practices or in life? Is it fewer moving parts, or is it clarity?
Some nice nuggets from answers below:
- "Simplicity is achieved when nothing more can be taken away."
- "I define "simple" in terms of required net logical thought. Too much reading requires too much though. Being too terse requires too much different thought."
- "...if you didn't write it, and can understand it in about the time it takes to read it, it's about right..."
Some observations so far
- It's interesting that even here, there is disparity between opinions on these two method implementations; some thought the first was "simple", and some the second. Several of the rewrites are versions of the first, while many people liked the second better, with some reformatting; still others liked a "third way": some combination of the two (is this just in our nature to edit and find the solution no one's mentioned yet?)
- As some of you guessed, this code is trivial; I'm not looking for a better way to figure out if a given integer is greater than 3; it's just for illustration.
- I think this is the same question that Google, Amazon, Microsoft, etc. ask about their user interfaces: Google says "fewer features and clean interface to simplify for new or infrequent users" while Microsoft says "gobs of features to simplify power users' experience". This is similar to the comment below about remote controls being simpler for people who don't lose them, but not simpler for those who do.