Category Archives: Facepalm

Signs that you need coffee, #8

You wake up on a rainy Saturday morning and desperately need a cappuccino.

You take the milk out of the fridge.

You start the milk frother without actually pouring milk into it .

You put the coffee cup under the espresso machine and press the coffee button without having turned it on.

You see the milk out of the fridge, wonder who forgot it there, and put it back in.

You stare at the coffee cup trying to understand why it’s empty.

You peek at the milk frother and are perplexed to discover it too is empty.

In this state, it will probably take a miracle for me to get the coffee I so obviously need.

Stories from the Field, #2: The customer is not always right

(note: all “Stories from the Field” are true, thinly anonymized to protect the -usually- guilty)

Project Manager: Hi Jim and team, we need a new version of our product with this and that new feature.

Team: Sure, but it’ll need a bit more memory on our customers’ computers.

PM: No worries, our customers have more than adequate computers already.

Team: Hmmmokey

Team: (codes)

Team: (tests)

Team: It’s ready and has passed our internals tests successfully.

Team: Now it’s time to go and test it on a few customers just to be safe, like we did last time.

PM: Yeah about that.

Team: WHAT NOW THIS IS A GOOD THING

PM: No no no don’t get me wrong, our customers loved it.

PM: In fact they loved it so much that they have been asking for it.

PM: Jim can you talk to Sales? They’ll tell you some great customers to test with.

Jim: (makes the rookie mistake and calls Sales)

Sales: Oh hi so happy to hear you.

Jim: Really? You usually complain about how our product is a piece of shit.

Sales: AAAAHAHAHAFUNNY no really I’m totally happy to hear you.

Sales: I’ve got a totally great customer you can test the new version with.

Sales: Who is totally not a cheapskate bloodsucking asshole.

Sales: You should totally call him.

Jim: I have a bad feeling about this.

Jim: (calls customer)

Totally Not A Cheapskate Customer: Oh hi happy to hear you, you’re supposed to give me free product to resell to my customers right?

Jim: NO NOT AT ALL we need to test our product and therefore 1) yes you get something for free but 2) be aware that your computers need to have more memory and 3) it’s still being tested which means DO NOT CHARGE YOUR CUSTOMERS FOR IT AND PLEASE TELL THEM THIS MIGHT NOT WORK.

Totally Not A Cheapskate Customer: Yada yada yada so I get free stuff great see you on Thursday bye.

Jim: (has a very bad feeling about this)

Jim and a Teammate: (show up early)

Jim and a Teammate: (start installing the new version on the Totally Not a Cheapskate Customer’s computers)

Jim and a Teammate: Wait this doesn’t work you don’t have enough memory here.

Jim and a Teammate: This isn’t even enough memory for the previous version.

Totally Not A Cheapskate Customer: SO WHAT I DON’T CARE ARE YOU TRYING TO STEAL THE FOOD OF MY CHILDREN? (* actual quote)

Jim and a Teammate: No wait we made very very clear that…

Totally Not A Cheapskate Customer: YOU ARE WORSE THAN THIEVES (* actual quote)

Totally Not A Cheapskate Customer’s Customers: WHY DON’T YOU GIVE US CHEAP STUFF AREN’T WE CITIZENS OF THIS COUNTRY??? (* actual quote)

Totally Not A Cheapskate Customer: I’LL CALL YOUR BOSS RIGHT NOW

PM: Hi Jim what’s going on there?

Jim: This and that, the Totally Not A Cheapskate Customer turned out to be a Totally Cheapskate Customer.

PM: Hmmm so Sales wasn’t 100% sincere.

PM: Who would’ve thought.

PM: Can you remove the installation restriction just for now?

Jim: I can but some things might work, some might not.

PM: Do your best.

Team: (does their best and has a special version ready within 15 minutes)

Jim and a Teammate: (install the software)

Jim and a Teammate: See it kind of works but it has issues BECAUSE IT NEEDS MORE MEMORY.

Totally Not A Cheapskate Customer: SEE MY LOYAL CUSTOMERS I HAVE SLAIN THE THIEVING EVIL CORPORATE DRAGON AND GAVE YOU CHEAP STUFF.

Jim and a Teammate: Wait you actually charged them for this we specifically asked you not to.

Totally Not A Cheapskate Customer: BEGONE YOU FOUL DEMON.

Jim: (silently curses in languages he doesn’t even speak)

Signs that you need coffee, #7

You do the first coffee break of the day, say around 10:00.

You sit at the table, feeling sleepy, wondering why the coffee hasn’t had any effect on you.

After ten whole minutes you realize you didn’t actually prepare the coffee.

I’m sure there’s some joke about vicious circles here, but I haven’t had my coffee so I’m too sleepy to think what that might be.

Stories from the Field, #1: Learn how to push back

(note: all “Stories from the Field” are true, thinly anonymized to protect the -usually- guilty)

Teammate: (goes to a big and important customer)

Customer: I want a software like this and that

Customer: And I want it yesterday

Project Manager: They want it yesterday

Teammate: But I need a bit more time in order to implement some UI checks, so that users don’t make mistakes

Customer: Our users don’t make mistakes, they are permanent employees for so many years, they know their job

Teammate: Hmmmokey

Teammate: (implements software in just a few days)

Teammate: (delivers)

Customer: (installs)

Users: (use the software)

Users: (literally fuck up everything that is possible and some things that are not)

Customer: WHY ARE THE DATA WRONG

Teammate: …but you said…

Customer: you’re not good I want another one

Project Manager: Jim you’re assigned to this

Jim: I will rewrite it from zero and I will implement these UI checks plus many many more

Customer: I WANT IT YESTERDAY

Project Manager: THEY WANT IT YESTERDAY

Jim: (doesn’t give a shit)

Jim: (writes code anywhere, anytime, day, night, while eating, while getting the baby to sleep, while helping his wife with breastfeeding etc etc)

Jim: (delivers)

Customer: Why is this 40MB this is bigger than the previous one I don’t like this

Jim: (loses his shit and starts screaming)

Customer: Jeez why are you so nervous you need to calm down

Customer: (installs)

Users: (use the software)

Users: OH HEY THIS WORKS

Users: IT HAS HELPFUL COLOURS TOO

Users: AND IT HAS EXPLANATIONS FOR EACH FIELD

Users: THIS IS GREAT

Customer: great job Jim, see I told you the first guy was not good

Jim: (silently curses in languages he doesn’t even speak)

Note: to be fair, the “40MB” complaint wasn’t as irrational as it sounds. The software had to be copied to many client computers, some of them in remote parts of the country with slow lines; this was still the days of ISDN. Still, the refactoring was worth it. The added volume was caused by a reporting library (Crystal Reports for .Net) which solved many problems by itself. I now understand the frustration of the customer’s IT as someone had to stay up all night copying. But the pressure from management was so much that at this point the poor guy just said the wrong thing at the wrong time to the wrong person. Elias if you ever read this, please accept my apologies 😊

Signs that you need coffee, #6

You wake up on Monday morning, which is bad by itself because Monday.

You decide you’ll have tea instead of coffee so you boil some water, pour it in a mug and dip two bags of your favourite tea in it.

You go to your home office room to start your laptop, check emails etc.

Then you go back to the kitchen and spend the next 5 minutes wondering where your coffee is.

Please don’t write logs inside Program Files (here’s how to do it right)

So the other day I’m troubleshooting a Windows Service that keeps failing on a server, part of a product we’re using in the company. Long story short, that’s what the problem was:

Access to the path 'C:\Program Files\whatever\whatever.log is denied'

I mean, dear programmer, look. You want to write your application’s logs as simple text files. I get it. Text files are simple, reliable (if the file system doesn’t work, you have bigger problems than logging) and they’re shown in virtually every coding tutorial in every programming language. Depending on the case, there might be better ways to do that such as syslog, eventlog and others.

But sure, let’s go with text files. Take the following example somewhere in the middle of a Python tutorial. Look at line 3:

import logging

logging.basicConfig(filename='app.log', filemode='w', format='%(name)s - %(levelname)s - %(message)s')
logging.warning('This will get logged to a file')

Did you notice? This code writes the log in the same place as the binary. It’s not explicitly mentioned and usually you wouldn’t give it a second thought, right?

To be clear, I don’t want to be hard on the writers of this or any other tutorial; it’s just a basic tutorial, and as such it should highlight the core concept. A professional developer writing an enterprise product should know a bit more!

But the thing is, these examples are everywhere. Take another Java tutorial and look at line 16:

package com.javacodegeeks.snippets.core;

import java.util.logging.Logger;
import java.util.logging.FileHandler;
import java.util.logging.SimpleFormatter;
import java.io.IOException;

public class SequencedLogFile {

    public static final int FILE_SIZE = 1024;
    public static void main(String[] args) {

        Logger logger = Logger.getLogger(SequencedLogFile.class.getName());
        try {
            // Create an instance of FileHandler with 5 logging files sequences.
            FileHandler handler = new FileHandler("sample.log", FILE_SIZE, 5, true);
            handler.setFormatter(new SimpleFormatter());
            logger.addHandler(handler);
            logger.setUseParentHandlers(false);
        } catch (IOException e) {
            logger.warning("Failed to initialize logger handler.");
        }
        logger.info("Logging info message.");
        logger.warning("Logging warn message.");
    }
}

Or this Dot Net tutorial, which explains how to set up Log4Net (which is great!) and gives this configuration example. Let’s see if you can spot this one. Which line is the problem?

<log4net>
  <root>
    <level value="ALL" />
    <appender-ref ref="LogFileAppender" />
  </root>
  <appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender">
    <file value="proper.log" />
    <lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
    <appendToFile value="true" />
    <rollingStyle value="Size" />
    <maxSizeRollBackups value="2" />
    <maximumFileSize value="1MB" />
    <staticLogFileName value="true" />
    <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%d [%t] %-5p %c %m%n" />
    </layout>
  </appender>
</log4net>

If you answered “7”, congrats, you’re starting to get it. Not using a path -this should be obvious, I know, but it’s easy to forget nevertheless- means writing in the current path, which by default is wherever the binary is.

So this works fine while you’re developing. It works fine when you do your unit tests. It probably works when your testers do the user acceptance testing or whatever QA process you have.

But when your customers install the software, the exe usually goes to C:\Program Files (that’s in Windows; in Linux there are different possibilities as explained here, but let’s say /usr/bin). Normal users do not have permission to write there; an administrator can grant this, but they really really really shouldn’t. You’re not supposed to tamper with the executables! Unless you’re doing some maintenance or an upgrade of course.

So how do you do this correctly?

First of all, it’s a good idea to not reinvent the wheel. There are many, many, MANY libraries to choose from, some of them very mature, like log4net for Dot Net or log4j for Java.

But if you want to keep it very simple, fine. There are basically two ways to do it.

If it’s a UI-based software, that your users will use interactively:

Create a directory under %localappdata% (by default C:\Users\SOMEUSER\AppData\Local) with the brand name of your company and/or product, and write in there.

You can get the localappdata path using the following line in Dot Net:

string localAppDataPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);

Take for example the screen-capturing software called Greenshot. These guys do it right:

If it’s a non-interactive software, like a Windows Service:

You can do the same as above, but instead of Environment.SpecialFolder.LocalApplicationData use Environment.SpecialFolder.CommonApplicationData, which by default is C:\ProgramData. So your logs will be in C:\ProgramData\MyAmazingCompany\myamazingproduct.log.

Or -not recommended, but not as horrible as writing in Program Files- you can create something custom like C:\MyAmazingCompany\logs. I’ll be honest with you, it’s ugly, but it works.

But in any case, be careful to consider your environment. Is your software supposed to run on Windows, Linux, Mac, everything? A good place to start is here, for Dot Net, but the concept is the same in every language.

And, also important, make your logging configurable! The location should be changeable via a config file. Different systems have different requirements. Someone will need the logs somewhere special for their own reasons.

But whatever you do, PLEASE PLEASE PLEASE DON’T WRITE WHERE THE BINARY IS. DON’T WRITE IN C:\PROGRAM FILES. IT. DOES. NOT. WORK.

Signs that you need coffee, #5

You wake up on a beautiful sunny Swiss Sunday morning.

You go in front of your filter coffee machine which, spoiler, you have programmed to brew a coffee on a fixed time every day except Sunday.

You wait, like, 5 minutes in front of it wondering why there’s no coffee in the pot and pondering conspiracy theories which you will not confirm nor deny to include coffee-snatching aliens from Tau Ceti.

Signs that you need coffee, #4

You go at the office machine and put an espresso cup in place, which can hold 60 ml max.

You slide in an espresso capsule.

You press the “Large” button which produces around 110 ml coffee.

(spoiler alert, 110 ml is much more than 60 ml)

You stand in front of the machine in amazement while the coffee overflows the cup, wondering what went wrong.

You thank your good fortune that spared you the embarrassment as no colleague was in the company canteen at that time 🙂