How my stand up comedy class instructor made me a better coder

Years ago, while I was still serving as a military medic my sergeant asked me why I hadn’t signed up for a unit golf tournament.

“Well sergeant,  I don’t like to do things that I do not excel at.”

Her facial expression upon hearing this was very memorable.

As I grow older I’ve started to realize that my drive to find better ways to do things sometimes gets in my way.

 

I was working on a function to recursively parse a string with multiple delimiters into an associated array.

I had it working,  but thought that I could make it more efficient.

That worked,  but thought I could make it ever more efficient.

…you get the idea.

It was getting to the point where I was getting frustrated.  There was an issue with recursive function calls weren’t returning the proper data.

I couldn’t figure it out.

I took a break and saw an email from Jim,  the instructor of the Stand-Up Comedy class I’m taking at Second City in Toronto.

The email contained some notes on a 3-minute set I’d delivered at the last class.

Jim gently pointed out that I was striving for perfection right off the bat and that it was getting in my way.

He talked about how even seasoned comics work to avoid that trap.

He was right.  I had practiced bits of the set for hours working on every nuance of delivery and wording.

I turned back to my code a few minutes later and realized that seasoned programmers and seasoned comics have some things in common.

73 lines of code became 127 lines, and done!

 

 

 

 

CSS Calc Function

 

Have you ever had a problem getting a div to center?   There are times that for some reason the margin: auto;  just doesn’t work.

Its situations like this that get old timers like me poking around Google where we discover new and cool things.   (the whole having a job, and being expected to produce results thing can make that difficult at times).

This led to the discovery of the calc()  function!

Calc allows you to use math to size elements without having to resort to scripting.

In the example below,  I set up a lightbox div with a width that is 100 pixels less than half the width of the parent div  (calc(50% – 100px);).

In order to center this (because margin:auto wasn’t working for some reason),  I used (calc((100% – (50% – 100px))/2);)

 

.lightbox {
margin-top:20px;
 width:calc(50% - 100px);
 left: calc((100% - (50% - 100px))/2);
 height:auto;
 padding:15px;
 margin-left:auto;
 margin-right: auto;
 position:absolute;
 border: #110ef3 solid 2px;
 border-radius: 5px;
 background-color: #FFF;

}

Why Your Programmer Friend Doesn’t Want to Hear About Your Idea for a Great App

I think a safe assumption is that anyone who is identified as a programmer (including the kid whose grandmother says is “good with computers” because they spend 90% of their time in the basement playing Call of Duty) has heard the phrase, “You’re a programmer?  I’ve got a great idea for an app!”

 

I once had this happen to me while out shopping for a new router.

The guy helping me pick one out perked up when I mentioned what I did for a living,  and then proceeded to tell me his great idea.

His great idea was actually pretty good!

So good that I was, at that point, about 75% of the way to a working proof of concept.

That’s one of the main reasons,  that based on my own experiences,  that many programmers don’t appreciate unsolicited ideas for applications.

And yes, we realize that you probably wouldn’t make a fuss if we “stole” your idea,  unless of course the product is in the 0.000000015% of applications that are fiscally successful.

Of course another issue with coming up with an idea for the next Facebook is that many people place too much value on the idea,  and too little value on what it takes to take concept from idea to an actual thing that people can use.

A couple of years ago I was approached by a friend who told me that she had a friend who had a great idea for an app.  All they needed was a programmer!

I resisted, and wasn’t even swayed when the dollar amount “in the millions” was mentioned.

Finally she offered to shut up about the whole thing if I agreed to meet with her friend.    That offer was too good to pass up, so a meeting was set up.

I listened to the pitch.

It wasn’t a terrible idea,  nor did I think it was a great one.

I asked some questions to ensure that I understood the concept.

I then asked what he thought would be his fair share of the profits.

He suggested 50%.   His justification was that without his idea,  that I would not make any money from this endeavor.

I then asked him what he would be contributing to the project.

His response was a confused “The idea?”.

He then responded in the negative when asked if he could provide anything in the following areas:

Database design
Scripting (back end or front end)
User Interface Design
User Experience Design
Server set up and maintenance
Project Management
Business Management
Legal Advice
Marketing
Money

By the time I listed all these off he looked a bit shell shocked.

Then came the big question.

What happens if this fails?

I explained to him that in addition to the approximately 2500 hours of development time this project,  that business expenses,  server hosting,  contracting out work and various other expenses would likely run to $15K to get to the point where we could being testing.

I gently explained to him that while his idea might be a good one,   that getting it to the point where it would be profitable requires a great deal of effort,  time and money.

 

So now you know why your programmer friend doesn’t really want to hear your idea.   And if they do,  make sure you have a contract in place prior to discussing it.   Otherwise there is nothing saying they have to pay your for using it.

The Real Reason Why Many Programmers Don’t Have Social Lives

I often have difficulty speaking to other humans.

After hours buried in code,  when I’m forced to communicate with other humans I have difficulty in switching to the rather arbitrary syntax and structure of Conversation.

Many people believe this is why I don’t have much of a social life,  but that isn’t the real reason.   Like most full-stack programmers I only need a few minutes to get comfortable with the current language/platform.

Here’s what happens to many of us when we’re planning on going out…

As we’re leaving we realize we left something important, like our phone, keys etc near our computer.

When we approach the computer,  we think about something we’re working on,  or we remember that we wanted to try something,  or had an idea to fix a problem…

So we think:

I’ll just take a minute and try that…

What follows are thoughts like

Well, that didn’t work!  Maybe if I….

and

now where was that chunk of code I used before??

then, finally..

Wait, why am I hungry?

and/or

OMG, Why is it so dark out??!!!

Then when you look out and see that its not an alien invasion with ships so big they blot out the sun, but rather that its late at night and life has once again passed you by.

Mirth: Making sure that dev/test code doesn’t get into LIVE (Is this lazy, or just accommodating reality?)

In a perfect world database connections and other things that must be changed when you migrate code between environments are neatly stored in one place where they can be easily changed.

With Mirth you can do this using global maps,  however when you do that,  they are exposed to anyone who has appropriate access to Connect.

I get around this by declaring variables at the top of the filters or transformers where I make database calls.

One of the things with my position is that I wear many hats and am the organization’s ‘go to’ for a great many things.  This means that interruptions are frequent.

This means that I when I’m doing something like preparing an interface to move from TEST to PRODUCTION that I can miss things.

Some of you might scoff,  but that is the reality of my world,  and almost 50 years on this planet has taught me that reality is often very far from ideal,   so you plan for reality.

I’m working on a project where I reach out to a couple of databases to pull data that isn’t included in the HL7 message.

Some of the transformations are complex,  and things were complicated by very tight deadlines,  and a situation where the spec “needed clarification”.  (as in I built my end to spec but they wanted a change).

Those of you familiar with this reality thing will know that this often leads to kludged together solutions.

After spending several hours making sure that our iPeople Echo downloads were moving the correct data from our test environment and copying/altering stored procedures and SQL functions I finally got to combing through my Mirth interface to make the changes there.

To give you an idea of the complexity,  I have 13 transformers in my source connector.

I realized that when I moved this to Live that there were too many potential failure points and wanted to prevent them.

So I added this code to my source filter:


var channelName = ChannelUtil.getDeployedChannelName(channelId);

if (channelName.indexOf('LIVE') > -1) {

logger.error('******************** CHECK ' + channelName + ' FOR DEV/TEST SETTINGS! ****************');
 return false;
 
}

return true;

/* Changes for Live
-remove anonymizer
-change db settings in source PID, PV1, OBR and ZDR
-change db settings in destination MR PID transformer

*/

Hey look…a checklist of sorts!

My thinking is that if I forgot to make this very basic change that I’ll look and wonder why all my messages are being filtered!

But then I got to thinking of how many times I’ve been interrupted today and what would happen if I missed a single change…

So I wrote this:

function envcheck(sql,strTest,strLive) {

 var channelName = ChannelUtil.getDeployedChannelName(channelId);

 if (channelName.indexOf('LIVE') > -1) {

 logger.error(channelName + ' **** CHANGE SQL STATEMENT FOR LIVE ' + sql);

 sql = sql.replace(strTest,strLive);
 
 }

 return sql;
 
 
}