CategorySoftware

Business now, details later

Three minutes into a meeting discussing a new feature and we already have a list with tables, columns, flags, objects and methods in our head. It’s involuntary. Whenever we talk about a new feature we jump into programmer mode as soon as we get the chance. We need a model for this, a controller for that, and then we render this component and sync with that API.

Going into too much detail when discussing features makes us lose focus. Programming and figuring out how things should work are hard enough on their own. There’s no need to mix them together.

It’s not only harder for us to reason about the system we’re building. It also creates some kind of lock-in. It’s hard to reverse any of those decisions taken during the meeting. Even harder if you’ve already built something. Because “we discussed and decided that this is how we’re going to do things”.

We act like those initial thoughts are set in stone. Instead of going back to the drawing board and undo the things we’ve done, we build around them, making an even bigger mess.

Refrain from including implementation details whenever you’re trying to figure out how a new feature should work. Get your business rules spot on. Then figure out the implementation.

Cost is no object. No, that’s too much money.

Driving home from a mini-trip, one of my friends was testing product ideas bouncing them with the rest of us. Most of them were turned down because the financial part wasn’t appealing enough. Like who’s gonna pay 20$ for this product? I wouldn’t – most replied.

I wouldn’t pay 1200$ for a Kanye’s anything. None of his products are worth that much – for me. And I love Kanye.

But people value things differently. There are people willing to pay 8 million dollars for a phone.

The ones buying it don’t do it for the tech (it’s an iPhone 4 after all), for the gold, platinum, or diamonds.

They do it because they want to be the ones with the 8 million dollar phone.

Cost is a factor, but most of the times it’s just another excuse.

The programmer’s gut feeling

Whenever you feel like an object isn’t really what the name says it is, or that it shouldn’t exist, or that it should exist, but in a different shape, you are completely right.

Stop and re-think things through. Maybe what you find is that you don’t really need that object. Or maybe what you’re trying to accomplish needs two or more objects or an existing one.

That gut feeling telling you that something isn’t what you think it should be is always right.

A Parameter doesn’t have a ParameterRecommendation. The parameter value has a recommendation.

Wrong. We can have n variations of parameter values – we shouldn’t have a different recommendation for the slightest variation.

But we can have some pre-defined ranges. ParameterRange has recommendations.

Naming things is hard…

Coming up with clear, expressive and precise names can be challenging and sometimes even infuriating. Why can’t I name this damn thing!? 

We grab our best friend, the thesaurus, and we start digging, jumping from one result to another. And we do that until we find the best word for the thing we’re trying to name.

But finding good names takes time, so I made something the other day that will make you a bit faster. It’s an app for the other programmer’s best friend, the command line. I call it sini and you can find it here.

 

Help me and others understand your code

It’s hard to make things work. But it’s even harder to explain how you did it. Here are a few things you could do to help me, you, and others understand your code.

Good formatting. Yes, that space between operators is important. Line lengths, line breaks, blank lines, camelCase, snake_case — they all make a difference. Be consistent, adhere to a guide.

Careless naming. Don’t use abbr. Don’t make me guess. Don’t mislead. Be precise. What is it? What does it do? Why it exists?

Conditionals and switch statements produce different outcomes. Which means I have to read the code again, and again, and again…

Nested loops, nested loops with conditionals 😮 . Same as above, only a million times worse. Get rid of them.

Hide stuff I don’t need to know. I don’t need the details. I want to be able to say “ah, it does this” without knowing exactly how. Write in cascade. Start with high-level concepts and add more details as you go downstream.

Make smaller things. It increases the number of files, classes, and methods and makes it harder to reason about the whole system. But that’s the idea. I don’t want to reason about the whole system. I can’t. Nobody can. I’m more efficient reasoning about small things. One at a time.

Don’t fall into the “I’m the only one working on this” trap. There are at least two people working on a project during its lifetime. The first one is you. The second is the you after a few months.

Put some more care into your code. Name stuff a little better, split classes and methods into smaller ones, make it look and read well.

It's not your code. It's our code.

About those “would be nice if…”s

New project. We have our meetings, we come up with a plan, we somehow agree to a budget and then we get the ball rolling, coding our way to the finish line.

As we build stuff, fresh requirements are sent in. “We need this new feature”, “we haven’t thought of that”, “it would be nice if…”, etc. And it’s ok. We saw this coming.

Displaying that list on two columns, making those elements editable, changing that color, size, font, whatever — they seem to have such a low value that we often neglect them. But they pile up and sometimes affect the system in ways you wouldn’t expect, taking an even bigger dip in the budget.

We are bad estimators. But that’s not the worst part. The worst part is that we rarely, if ever, say no to a client.  One reason, apart from the customer is always right and make the client happy, is that it would make us feel incapable, unworthy of our profession. We take saying no as something to be embarrassed of. It’s not.

Saying no not only leaves you with fewer things to do but also leads to a major increase in productivity. It’s far easier to stay focused when you don’t have to worry about the “would be nice if”s.

The devil’s in the details. Control the scope.
Focus on what is essential to create value now. Add the rest later.

Deptory intro

Automated tests give us the speed and confidence we need to make quick changes without having to constantly check the thing we’re working on. They improve our code, make finding bugs easier, provide documentation and help us save money in the long run.

But automated tests are not enough to ship quality software. They focus on the happy path and don’t do much for the unknown scenarios. They cannot be compared to an actual human being going through the app, using it in all the ways a real user might.

Before deploying a project or a new feature to production, I split every screen into small components and describe how they work. I do that by writing checklists. Components are forms, buttons, lists, list items, whatever I can think of having its own set of actions.

I then go through each checklist and try to reveal any unwanted behavior. I simulate slow networks, click and drag things around, submit forms multiple times, make different actions on things no longer exist, etc. I do my best to go off the happy path and break the system.

It’s not only about finding the bugs. By disconnecting and using the software myself, I discover new ways to make it better. I can clear my head and look to improve things – both code and design wise.

Compiling those checklists takes a lot of time and effort. And if you write them on paper as I do, they’re gone as soon as your code hits production. I’d love having a place to keep them.

Work at the smallest scale possible

You know that feeling when you found an elegant solution to a problem you’ve been having? You discovered that pattern you’ve been missing and you’re like “yeah! now I get it!”.

The excitement gets the worst of us and we start acting like the thing we found is the holy grail of software writing.

Like yes, this looks way better. If I apply this pattern here and use this structure there, all my problems go away. And we sprinkle all that over our project.

A few days go by and we’re like “wait a minute…this solves my problem but complicates this other thing I’m working on. Fuck..”.

We fiddle around with it for a few hours, sometimes days, and then we either find a way to patch things up or we hit the undo button and start from scratch.

The thing we found has its use. Where we go wrong is trying to force use it everywhere.

© 2018 cdruc

Theme by Anders NorénUp ↑