tags:

views:

1254

answers:

23

Recently I tried to explain some poorly designed code to my project manager. All of the manager classes are singletons ("and that's why I can't easily change this") and the code uses event dispatching everywhere that a function call would have sufficed ("and that's why it's so hard to debug"). Sadly it just came out as a fumbling mess of English.

Whats the most difficult thing you've had to convey to a non-technical person as a programmer? Did you find any analogies or ways of explaining that made it clearer?

+22  A: 

Thread Synchronization and Dead-Locking.

Justin Niessner
+1 for this. Anything multi-threaded is hard to explain to a non-technical person in a manner in which they'd understand why the task will be "hard."
wheaties
Easy, imagine several hammers hitting the same nail, blindfolded, or put a set of nails close together an try to hammer them at the same time. Won't work, or won't be fast. You need some scheme/plan/arbiter to handle that. :)
Marcus Lindblom
Explaining it is difficult enough; debugging it requires an entirely new definition of "difficult" :P
Magsol
I used the analogy of writing directions for multiple people to simultaneously create the same food: how do you break it down, and organize it in a way that they don't all clobber each other's work? ;)
Mordachai
My impression is that the concepts themselves aren't difficult if explained well...but almost invariably the articles I read about multithreading are knee-deep in incomprehensible jargon.
Kyralessa
+14  A: 
OMG Ponies
And I assume that was followed by a WTF.
Matthew Whited
Well, they said they wanted it simple :). It's the 3-way handshake: http://www.inetdaemon.com/tutorials/internet/tcp/3-way_handshake.shtml
OMG Ponies
That's just brilliant. :)
Arnis L.
Did they realize you were speaking Martian?
outis
+6  A: 

1.) SQL: Thinking in sets, rather than procedurally (it's hard enough for us programmers to grasp!).

2.) ...and here's a great example of demystifing technical concepts:

How I explained REST to my wife

davek
+20  A: 

Spending time on design, and spending time on refactoring.

Refactoring produces no client-visible work at all, which makes it the hardest thing in the project to justify working on.

As a second "not client-visible" problem, unit testing.

Dean J
It'll be visible when you change something and it doesn't work anymore.
Cristián Romo
Oh, it's visible then, but the blame from management falls on the person who made the change, not on the lack of testing.
Dean J
+2  A: 

I sometimes really have hard time explaining the concept of covariance/contravariance and the problems related to them to fellow programmers.

DrJokepu
+1  A: 

Avoiding Dead-Locking in a multi-threaded environment.

I cleared confusion by explaining it visually on a white-board, drawing out two parallel lines and showing what happens when the reach the same points at the same time.

Also role-playing two threads with the person I was explaining it to, and using physical objects (book, coffee mug, etc) to show what happens when we both try to use something at once.

Mike Clark
+4  A: 

How recursion works...

Jason Punyon
http://stackoverflow.com/questions/1627018/most-difficult-programming-explanation/1627060#1627060
Dan Diplo
You should start by explaining how recursion works
Tim
@Dan, that one ain't new anymore. :P
Arnis L.
@Dan, Your comment links to the answer. It should link to itself. And btw, now, the answer links to itself.
Martinho Fernandes
While clever, I think this answer is a sad misrepresentation of recursion and recursive functions. To be a *good* recursive function, it should have a base case, and terminate. This example is a better illustration of coding error, and technically incorrect snarkiness. ;)
Zak
Unless you are master foo, and the base case is enlightenment(implied) ;)
Zak
+1  A: 

Convincing a friend that the Facebook application I developed really doesn't store her personal data (e.g. name) even though still displays it.

Gergely Orosz
It does store it, at least in memory. And if it gets paged out, it is on disk... Now go and try to explain that...
Martinho Fernandes
+4  A: 

Why code like this is bad:

private void button1_Click(object sender, EventArgs e)
{
    System.Threading.ThreadStart start = 
        new System.Threading.ThreadStart(SomeFunction);
    System.Threading.Thread thread = new System.Threading.Thread(start);
    _SomeFunctionFinished = false;
    thread.Start();
    while (!_SomeFunctionFinished)
    {
        System.Threading.Thread.Sleep(1000);
    }
    // do something else that can only be done after SomeFunction() is finished
}

private bool _SomeFunctionFinished;
private void SomeFunction()
{
    // do some elaborate $#@%#
    _SomeFunctionFinished = true;
}

Update: what this code should be:

private void button1_Click(object sender, EventArgs e)
{
    SomeFunction();
    // do something else that can only be done after SomeFunction() is finished
}

private void SomeFunction()
{
    // do some elaborate $#@%#
}
MusiGenesis
Why is it bad ?
Liran Orevi
Just needs a few dozen locks in there (exaggeration).
C. Ross
I'm curious why a non-technical person was asking your opinion on this... (or is this a subtle knock on a "non-technical" coder?)
Austin Salonen
Would love to see the corrected code, if someone kindly will...
Liran Orevi
@Liran: I added what the code *should* be. Note how much simpler it is without the threading nonsense. Not only did I have trouble explaining this to the non-technical people, I was unable to get the original author of the code to understand why it was so bad and pointless. He kept insisting that multi-threaded apps are better than single-threaded apps.
MusiGenesis
Many thanks @MusiGenesis, maybe multi-threaded would be useful if it would let go of the GUI while doing SomeFunction() (instead of sleeping), assuring the GUI won't "freeze" during a long SomeFunction(), I assume the upper code actually freezes the GUI, at least for one second?
Liran Orevi
@Liran: both versions above freeze the GUI. `Thread.Sleep(n)` blocks the current thread, which in the example is the UI thread because it's initiated by a button click. Performing some long-running task on another thread *can be* useful, assuming that there actually *is* some other task the user can do while waiting. In 95% of the multi-threading code I've inherited, there's nothing else for the user to do anyway, so the extra complexity of the threading is utterly pointless.
MusiGenesis
Also in winforms BackgroundWorker should be used in order to get rid of locking problems assuming the task is long enough to be annoying
Esben Skov Pedersen
A: 

There's really no right or wrong answer-proper for this... it's all experiences.

The hardest thing I have had to explain to a non-tech person was why he couldn't get to his website when traveling abroad but his family member that lived there (with a totally different provider) could get to it. Somehow, "Fail in Finland" wasn't good enough.

Deverill
+1  A: 

The most difficult concepts to explain to people I would label programmers as opposed to developers are some of the most core paradigms of object orientated design. Most specifically abstraction, encapsulation and the king, polymorphism and how to use them correctly.

Expanding on that is the level of complexity of explaining what Inversion of Control is and why it is an absolute need and not just extra layers of code that doesn't do anything.

Chris Marisic
+2  A: 

The concept of recursion - some people get it really hard.

Gergely Orosz
In order to understand recursion one must first understand recursion
Esben Skov Pedersen
I could never grasp the difficulty of recursion. I feel at a loss.
Martinho Fernandes
+4  A: 

The importance of unit tests.

Ewan Todd
It's always hard to explain lack of something. :)
Arnis L.
+11  A: 

I had a fun case of trying to explain why a program wasn't behaving as expected when some records in a database had empty strings and some were NULL. I think their head just about exploded when I told them empty string is just a string with 0 bytes in it while NULL means unknown value and so you can't actually compare it to anything.

Afterward I had one nasty headache.

Kenny Drobnack
+1... I've had this one before, especially with SQL -- "they're both null so why aren't they equal?"
Austin Salonen
+13  A: 

My most difficult question began innocently enough: my girlfriend asked how text is rendered in Firefox. I answered simply with something along the lines of "rendering engine, Gecko, HTML parser, blah blah blah."

Then it went downhill. "Well how does Gecko know what to display then?"

It spiraled from there quite literally down to the graphics drivers, operating system, compilers, hardware archiectures, and the raw 1s and 0s. I not only realized there were significant gaps in my own knowledge of the layering hierarchy, but also how, in the end, I had left her (and me!) more confused than when I began.

I should've initially answered "turtles all the way down" and stuck with that. :P

Magsol
+1 for "Turtles all the way down" - it's the best answer for most computer problems.
Adam Davis
You have a girl friend who asks about text rendering in Firefox? Geek!
Amarghosh
+4  A: 

"Adding a new programmer a month to this late task will make it ship later. Never mind, read this book." (The Mythical Man-Month.) Managers still don't quite get it.

Alex Feinman
A: 

Trying to explain why code was executed sequentially at all. Seemingly this is not at all intuitive for some non-programmers (i.e. my girlfriend).

Mikael Ohlson
really? I don't think I've ever run across this before... I think most people assume the computer does things sequentially because they actually see it happening when they use the computer (most notably in the case of progress bars with explanations flashing by about what it's doing)
rmeador
Mm. Except people don't necessarily pick up on such things. It's sort of like cooking recipes. They appear structured and sequential, but in reality, a lot of things are going on at once. Unless you know what you are looking for, things can probably seem quite chaotic.Mind you, I was trying to explain actual code, which is quite far from what my girlfriend normally gets in touch with when it comes to computers. This was what we got stuck on.
Mikael Ohlson
Do you mean sequentially, or synchronously? I can imagine non-techs thinking like 'ok well whilst its running that line of code it moves on to this line of code..'
PaulG
My previous comment does seems slightly confused. I mean sequentially, but the comment seems to say I meant the opposite. The real question, when trying to explain it to my girlfriend was on the lines of "how come those lines, that you say just do one little thing after another, cause all these things to happen at once?" which (after a while) led to a discussion on the fact why most programming languages specify things in a sequential format, which of course brought up things like instructions, how a processor or micro-controller works, how instructions are read, et cetera.
Mikael Ohlson
+2  A: 

Why it'll take another four weeks to put this app into production. After all, it only took a week to do the rapid prototype. It "works" (or at least looks like it does) so I should be pretty much finished, shouldn't I?

Explanations that involve security, code quality (maintainability), normalized DB schemas, testing, etc. usually come off as a list of abstractions that don't have any visible effect on the app, so it's hard to explain what they really contribute to the project and why they're necessary. Sometimes analogies can only take you so far.

Matt
+7  A: 

A lot of statements starting with "It's because in Oracle, ..." come to my mind.

ammoQ
+7  A: 

The biggest hurdles are around "technological debt", especially about how the architecture was correct for this version but needs to be changed for next version. This is similar to the problem of explaining "prototype versus production" and "version 1.0 versus version 2.0".

Worst mistake I ever made was doing a UI mockup in NeXT steps UI Builder. It looked exactly like the end product would look and had some behaviour. Trying to explain that there was 6 months of work remaining after that was very difficult.

Rob Osborne
+1  A: 

I was going to comment on Mikael's post, that some people just take the sequential programming and unfortunately just stay with that.

But that really means: two seriously hard to explain concepts:

  • monads in haskell (usually starting with: "That's like a function that returns a function that does what you really wanted to do, but ...")
  • deferreds in twisted/python ("That's like... ehhh... Just use it for a year or so and you'll get it" ;) )
viraptor
+2  A: 

C pointers

*i

&i

Yada
A: 

Why you do not need character correct index handling in most cases when you use UTF-8 strings.

Lothar