Tag Archive for 'Advice'

Circular Dependencies in the real world

In programming there is a problem known as circular dependency, which you know is real because it has its own Wikipedia page and everything.  In summary the problem is that Class A needs to know about Class B, but Class B needs to know about Class A.  The problem arises because the compiler has to pick one to start with.

As an analogy let’s take Bob and Alice who have been married for many years and won’t go anywhere without each other.  Strolling through the park they find the bridge across a stream is out but they are in luck, someone with a two seater swan boat is willing to offer rides.  Since it is his boat (and no one is going to question why in the world he owns one personally) he must remain in it at all times.

Now since Bob and Alice, or Alice and Bob if you prefer, won’t go anywhere alone here is the problem.  The Cygnus captain only has room for one.  He points to Alice and says “I’ll take you across first” to which she responds “But Bob won’t be on the other side when I get there so I can’t.”  He turns to Bob and says ” if you go first then you will be on the other size and therefore she can cross right after.”  Bob replies “That sounds great but only if Alice meets me across the river when I get there.”  Exasperated, holding his face in his hands, the captain doesn’t see the iceberg coming downstream which proceeds to sink his swan.  Luckily the river is only a few feet deep but still he winds up wet and boat-less.

He hit an impass, there is no way to get one to cross without the other being there first.  Despite The Substitute teaching otherwise, sometimes the best solution is not to throw a boombox out a second story window.  Outside of programming this is known as the chicken or the egg problem.  Clearly one came first but there is no clear cut answer as to which is correct (the egg is the right answer btw).

Why am I talking about eggs?

Other than the fact that they are delicious, this problem comes up ALL THE TIME.  Just today I was listening to a cross discipline engineering project where the hardware people said they couldn’t finish without the software (true) but the software people couldn’t get started without the hardware it runs on (also true).  Think back and it shouldn’t take too long to come up with similar situations in your life.  Businesses (especially tech support) thrive on this.

“To recover your pin number, please type in your pin on the phone keypad now.”  Most cases aren’t this bad but stuff that stupid does come up now and again.  Sadly the people involved are likely alive and employed.

How do we fix this?

You’ve convinced me I hear you saying, now how do I solve these seemingly insurmountable cycles?  First I say: Get out of my house!  Secondly we have to take a look and see if we really need one before the other, if not hooray the problem just fixed itself.  The key to break the cycle is to do anything that breaks the cycle.  In the world of making things that depend on other things this would be a prototype.

Wait, did you say hardware Prototype?

Not exactly, you filthy word injector, but yes that is what was implied.  Certain situations make prototypes more than helpful, they become essential.  That situation would be any time you don’t know how to do something.  Since any interesting project will have at least some unknown aspect this covers 99.9999+% of all products.  People thought all vacuums were the same until James Dyson got tired of clogged filters and did something about it.

The way to  break the cycle is to build something, anything that gets you closer to the goal.  IT WILL BE WRONG  and that is okay.  Failing when you absolutely, 100% upfront intend to fail isn’t bad, it’s only bad if you don’t learn from the experience.

Say you are building a widget; I’ll wait until you finish speaking to continue.

This widget is revolutionary and will sell like hotcakes back when people used to buy a lot of hotcakes.  The only problem is like many products it requires hardware and software.  Damn, now we are really screwed because apparently programmers and engineers (not software engineers) have a fundamental mental disconnect in how they approach problems.

walrus and carpenter

The Engineer and the Programmer, one of which is about to get nailed in the bean with a hammer

The Hardware Engineer Says:

I have to design this perfectly up front, it is too expensive otherwise.   If I miss one detail it will take months to get the manufacturer to retool the assembly line, that will costs tons of money, hell it may kill the entire project.  Better take as much time as it takes to get it right the first time.  Wish that lazy Programmer would tell me the specifics he needs, then I could spec just enough power to make it work.

The Programmer Says:

I have never done anything like this before, there is no way I can get it right the first try.  Would love to make a quick prototype that supports the most important features of the product but the hardware to run it doesn’t exist yet.  What the hell is wrong with that Engineer wasting time on crap that will clearly be wrong the first time, if not multiple times?

Who’s right?

As one of my professor’s says “it depends,” which is sadly almost always the correct answer for a complex situation.  Both the Engineer and Programmer raise good points.  It does cost money to make mistakes but it is hubris to assume that by working really really hard you can get it perfect the first time.  In the computer world contradictions this strong cause your compiler to lock up, machine to blue screen (even on Linux), and the cpu to burn itself to ash to avoid the agony.  The real world, however, thrives on this shit.  Those familiar with quantum weirdness know that Schrödinger’s cat is both alive and dead at the same time, at least until you open the box.  Chickens and eggs don’t care which one came first, they just keep doing whatever it is they do (being delicious).

Pictured: deliciousness

That wasn’t an answer at all!

Damn, you caught me.  So here is my opinion on how you solve the problem.  In building our widget you get the engineer to create a really cheap prototype that does the absolute essentials probably right.  But it is cheap and fast.  He then gives this to the programmer who can start prototyping while the engineer works on fixing obvious and not so obvious design flaws.  You know, the kind that make you slap your head and say “wow, wish I had known about that back in the design phase.”  The really important part is that they share feedback throughout the product life cycle.  If the engineer flings a circuit board over the wall then bit later a CD comes bouncing back it absolutely won’t work.  Close feedback is the key to making this work.  Note: you can have good feedback without being able to physically talk face to face, these days this thing called the internet solves those kinds of problems.  In the software world this form of management is called Agile Development.  In the engineering world it is called Blasphemy.

So we are starting out this supposed year long project.  Team A is using the old standby methods to build, Team B is trying out new, more radical thinking.  Suppose the deadline is absolute.  There is no reasoning with it, no extending it, no nothing.  Here is how these projects work out often enough.  Numbers may or may not be accurate, but they prove my point.

DateTraditional EngineerTraditional ProgrammerAgile EngineerAgile Programmer
Month 1Got lots of research to do!Lots of research to do!Finishing touches built on first prototype after week one brainstorming session.Been working with engineer to get prototype working.
Month 3Moved on to designing boards and actual engineering.Toyed around with a few ideas but not really sure what the hardware will be so can't write anything.Got lots of feedback from first prototype, started on next, more polished one.Got a pretty good idea where the hard parts are going to be, creating software prototypes of tough stuff.
Month 6 (of 12)Design 90% done but still a few kinks to work out.Playing solitaire as there is no real work to be done until have some device to test out.Last prototype nailed it, now polishing design and adding optional features.Testing of required features mostly done, minor bugs remain.
Month 890% done.Trying to look busy.Final polish being added.Minor features being coded.
Month 10Done with board, passed off to programmers.Coding franticly.More final polish, working with marketing to improve product launch.Optimizing code and working on documentation.
Month 11Waiting on feedback from lazy programmers.Code harder than first expected, putting in extra hours.Started work on new project while waiting for launch.Final cleanup and ready for release.
Month 12Yelling at programmers to get done.FUUUUUUUUUUCK!Enjoying work on second product while success of first happens.Started on code for second product, not burned out from first project.

Yes this is an extreme exaggeration, but it’s my blog so tough crap.  And many real world products move along exactly the same way as the first team.

Summary

If you want to break the chain of impossible dependencies you have to do something!  Planning gets you no closer to shipping when you cover the same ground over and over and over again.  Take a chance and build something that might work, or might not.  As long as you aren’t making life critical products (like a pacemaker) this is not only a good way to go, but in my opinion it is the best way.  Look for future posts on how waterfall design methods (that all engineers use) are crap and agile hardware development.

How to Give Advice

In a startlingly high level of hypocrisy I am now going to tell people to not give advice.  Let me explain before you completely tune me out as being mad.

Say you’re at work and someone does something in a way that strikes you as odd.  Maybe the code is indented different than usual, or not at all.  Perhaps they use #defines in your C++ project.  Whatever it is, you have an opinion and want to tell them “the right way” to do things.  Even if you can step back far enough to realize yours may not be the best way, but is instead something based on years of practical experience, they will still interpret it as “your opinion”.  Which of course it is.

What’s the worst thing that could happen if you spread some helpful advice?  I used to think the worst thing was that they would ignore you.  Ideally they can look past their own ignorance and see your brilliant idea for what it is.  This is wrong, and highly optimistic as it turns out.

The worst case isn’t that they ignore you.  Sadly ignoring your unsolicited advice is the BEST CASE scenario.  They listen, nod, say “uh huh” while you are speaking; then once you are gone blank it from their memories.  It can go so much worse.  They can get offended.  How DARE you try and tell them you are right and they are wrong?!  How DARE you say that they are dumb and you are so much smarter and better that you will guide them out of the caves?  Exaggerating a bit?  Not as much as you might hope.

There are several reasons people do the things they do.

1) They aren’t conscious of it ( how much attention do you pay on your commute to work every day, honestly? ).

2) They are conscious of it and choose to do it that way.

If you are talking to someone in group one, you probably are trying to help them.  Spare them your mistakes as it were.  But they don’t care.  If they cared, they would probably think more about how they were doing it.  These are the people who will ignore your advice.

The group two’ers are the troublemakers of the advice realm.  If you tell them they are wrong, they will fight you tooth and nail.  No matter how polite you are, how genuinely helpful you are or how long you have been friends they will object.  Because when you give unsolicited advice you are saying, in no uncertain terms, that you know more than they do.  And people generally don’t like being called stupid.

Telling a two’er how to do things will often not result in being ignored.  It won’t result in them following your advice either.  What it will do is piss them off.  From their perspective it is an attack on their person and they will do things about it.  Relations may become strained, feelings hurt, tempers flared.

So if being ignored or hurting feelings are the results of giving advice, how do you give advice?

The answer is, you don’t.  You can’t.  And you sure as hell shouldn’t try.

This applies to the forms of advice most people give and receive every day.  Hey you should blank.  Or why don’t you x instead of y?  There is one, and only one, category of advice that works the way you want it to.  That is when someone asks for it.

If someone sincerely asks “how would you do this” what they are really saying is “I appreciate and acknowledge your understanding of this topic and would be interesting in your approach to this problem.”  They are pushing down their ego enough to say that you are more experienced and ask for help.  But now isn’t the time to get big-headed.  This is the time to teach.  This is the only time someone will actually listen to your advice and possibly carry it out.  Heck with enough time they may pass it on to someone else.  And that is what you wanted to do the whole time, spread your knowledge to help others.

People can seek help without expressly asking for it as well.  If someone is distressed and you may be able to help, see if they want it before throwing it out there.  Often times it is difficult for someone to put their ego out of the way, so you have to help with that too.  Saying something like “I had that same problem last year, would you care to hear some tips that really helped me out?” is a good icebreaker, but only if you actually had that problem last year.  Groups like Alcoholics Anonymous are founded on the principle of shared empathy, you know what they are going through because it happened to you and they can feel that.  If they don’t want the tips, don’t offer them regardless.  People only hear what they want to hear, repeating yourself won’t change that.

Based on my ( limited ) understanding of psychology and people this is the way things are.  Think of how much grief is caused by unwanted advice, which to the receiver feels sarcastic and insulting.  Before you advise, empathize ( nice huh? ).  Think how you would feel if someone came over to your desk and said “Your layout is all wrong, idiot”.

Hopefully you wanted to learn something about advice before reading this entry, or were at least open to it.  But the people who think I’m an idiot will either ignore what I’ve said or post responses saying how dumb I am.   I didn’t write this article for them, I wrote it for the people out there who really wanted to learn something.  Hopefully they did.

Dreaming of clouds

Cloud computing is a somewhat nebulous term currently.  I interpret it to mean a way of writing code, it runs somewhere and just works.  You don’t care where the server is, what kind of database it uses or any of that.

IEEE has a wonderfully vague definition: “It is a paradigm in which information is permanently stored in servers on the Internet and cached temporarily on clients that include desktops, entertainment centers, table computers, notebooks, wall computers, handhelds, etc.”

Some examples that fit this definition are: Bittorrent, Facebook, Google Chrome, Grid Computing, Ruby on Rails; the list goes on.  That is sufficiently general as to be worthless.

One thing is certain, cloud computing is HOT.  It is flavor of the month of keywords.  People talk about using cloud computing for all kinds of things without knowing what it is ( it seems no one really knows either ).

But as it stands now, despite the continuous buzz, it will not work, because there is a fatal flaw.

Amazon has the Elastic Compute Cloud, Microsoft recently published they are planning a cloud based OS, Google has, well pretty much everything they do falls under cloud computing.  New companies every day say “I want a piece of that fat cloud pie!”  This will only accelerate the problem.  If the industry sees the problem soon enough, as I have, then cloud computing has a rich future.  If not it will join Web 2.0 in stagnation and, eventually, extinction. ( I know Web 2.0 is not dead but it certainly has a head start down the trail cloud computing is on. )

The problem stems from the fact that since no one knows what cloud computing is, everyone gets to form their own definition.  Definitions are only a symptom.  I feel the main goal of cloud computing is to write code and it will work.  You don’t care how, you don’t care where, it just works.  Really that is the goal of all code, I don’t really care that the file my program needs is located in My Documents in Windows or somewhere else in Linux and another place in Mac, I just want to open the damn file.

Stories help illustrate points, here is one about a devoloper named Dave.

Dave has a cool idea for a web app.  It has needs a database and some server space and Dave has no experience with either.  He hears Amazon has a cloud setup that allows him to just write code that works without knowing all the gory details.  Extra bonus: if his service takes off and gets thousands of users it will scale automatically.  Dave loves that and whats more he buys books from Amazon, so he knows they can be trusted.  Dave can’t sign up fast enough.  And for a time, things are good.  It does what he wants but isn’t everything he imagined.  One day while explaining his project to Joe at the water cooler, Joe nods and follows along.  He then says “Dave, that sounds good but all the problems you are having just don’t happen in Google’s cloud system, it really is a much better fit for what you are doing.”  This gets Dave thinking, he starts looking into it and Joe is right, it would be a better fit.  So he signs up for Google’s cloud computing to see the differences.  Lo and behold it really is perfect.  He decides to transfer immediately.  Now the problem happens: Dave has tons of fully functional code on Amazon’s Cloud and now it needs to work on Google’s Cloud.  The only way to do that is to re-write it from scratch.  Well not scratch per se, Dave knows everything it needs to do, he just needs to change all the API specific stuff out.  That could be easy or nigh impossible depending on a variety of factors.

This is called vendor lock in.  If you use one product for long enough your stuff tends to revolve around it.  This has the effect of cementing it into your foundation.  After a while the only way to remove it is to destroy the entire house and rebuild from scratch, something most people and companies will never do.

The solution to this is so simple it is scary.  Make a standard.  These are the functions that will be supported on all cloud server architectures come hell or high water.  They work the same no matter who is hosting it.  A vendor can make special non-standard functions and users can use them at their own portability peril but it doesn’t stop new ideas from happening.  Any sufficiently cool idea should be added to the standard.  This way Dave can take his code from Amazon to Google or Microsoft or any of the others and it will do what was promised: it will work.

Programming languages have been doing this for years.  They all come with a set of functionality ( how much depends on the language, compiler, etc ) and it works regardless of where you write that code.  C++ programmers can use the boost library but not everyone is guaranteed to have it, but int better damn well be declared and work the way I know it should in all my C++ compilers.

If cloud computing embraces a standard then it can save itself from death.  It would allow people to change vendors when it suited them, to not be locked in for all eternity.  More importantly it would allow the bad vendors to die, instead of leeching off of one group who is too entrenched to get rid of them.  Code portability is something that would elevate cloud computing to its place in the clouds, instead of wandering around buzz word marsh until it winds up rotting in forgotton bog.

Be kind to your rear

 

Crappy Desk Chair

Does this resemble the chair that you sit in when you code?

If you live in the same dorms as I do then odds are good.  It exactly resembles my chair, because it is my chair.  And I hate it.  Hate it so much.  Actually it isn’t the chair that I hate, it is the numb ass and sore back that come from sitting in it.  Laying on my bed to code isn’t much better, because I find it impossible to concentrate laying down.  If there was some way I could hook up my laptop to a treadmill and pace then my coding would easily improve two-fold.  But I digress (actually I have done nothing but digress, but that is par for my posts).

The point is: if you aren’t comfortable then it will affect your code and thinking ability. If you get pulled out of the coding zone because your leg fell asleep that is detrimental to your code.

If your workplace gives you crappy chairs then that should be a good indicator of how much they value you.  A good chair costs a few hundred dollars, lasts for years and can greatly affect your performance.  Any business that can’t put forth the cash to make you happy (well at least your butt) probably doesn’t care enough to hire quality coders.

Hint: you may want to do some self evaluation to make sure you don’t belong there.  Statistically speaking though half the programmers are in the bottom 50% of all programmers.  Perhaps obvious, but still worth considering.  Now a good chair won’t make a bad programmer a great one, but a bad chair will make a great programmer sore, irritable and less effective at his job.

Overall message: take care of your rear and it will take care of you, kind of.  It won’t distract anyways, as long as you stay away from Taco Bell.