I wrote some blog posts way back in the good old days of 2016 about a bot we developed for an intenral work tool. It ran inside of Slack. When we did the development we were basically writing code to handle all the states of the conversation. It was clunky and had some real limitiations.
Fast forward to more recent times - we bought a Google Home at the end of last year. Because I usually want to make something and not just consume information, I started to play around with Google Assistant and how to create an Assistant App for Google Home with tools on Google Cloud.
So right away I found myself working in the Dialogflow ecosystem. This was a big improvement over how we built our Slackbot in 2016 where we were hand-coding our state and writing a million if/else statements to handle the user interaction.
The Dialogflow designer interface is intuitive for creating your conversation. My biggest sticking points were working through the integration between it (Dialogflow) and my existing webservices. The answers were there in the documentation but it took some time to work through my SSL issues (doesn't allow self-signed certificates) and formatting of request. This was a little frustrating at times, but nothing out of the ordinary for using a tool that you haven't worked with before.
I also came across Let's Encrypt for solving my SSL issues. Let's encrypt allows you to get a real-ish certificate for development and test purposes. It is fast and automates several parts of the SSL cert process I've never seen automated before - very handy!
My Google Assistant App is submitted now and waiting for approval. I believe I adhere to all their guidelines, so hopefully they will approve me! Fingers crossed!
It's hard to draw a map of a place if you've only ever been through it once, going in a straight line in a fast moving vehicle.
For a guide, you may want someone who can draw a map from memory. You may want someone who has been lost where you're going. You may want someone who has, at least, been there a lot of times, walking in more of a zig-zag pattern and seeing what's around.
OR you're accepting a guide who knows a little more than you but can't draw the map.
Both can work, but understand what you're getting and accept the advantages of the latter if you choose it. That is, you will be getting lost along the way, but you will also be a guide at the end of the journey.
Sometimes there is no map and never will be - for the country is forever new. In these cases we can only compare it to country we have been in before and offer help to one another.
More reasons why code is harder to read than write:
Code is meant to be executed by machines, not to be read by people. In other words, you, as a human, are not the intended audience. Everything about the program you're trying to read, including the intent of the language designers, was focused on machines and not on you.
Developers don't get paid to write, they get paid to build.
Developers prefer to build things over writing about it or adding comments to code.
There is always a deadline. The deadline is never about writing comments or documentation.
I've posted this article recently, but it got me thinking about why code is harder to read than to write. So, I will post it again, to make your life easier and explain why I think that code is still harder to read than write, even all these years later. Here's the article:
The title of this post seems counter-intuitive because we think of reading and writing in relationship to human language, but programming languages are not like human language.
What are the important differences? Here is the main one:
Programming languages can't be read aloud.
So when we talk about 'reading code' we're using 'reading' in a purely metaphorical sense. When you 'read' code you don't actually read it - you're looking at it and trying to make sense of what it does.
This is nothing like reading a book, paragraph, or sentence written in human language.
When you review code you study, you re-read, you look things up. You jump around from file to file. You may consult web pages. Even in programming languages you are familiar with and with a business domain you know, these tasks can be time consuming.
You're trying to 'read' something that can't be read, across many files, and trying to ascertain the author's intent not just comprehend a sentence.
An equivalent would be trying to read in a language where you had to look up every third word, every time you read something because:
Every author used the language in a novel way. AND
Every page of a book was put in a different file and they were constantly referencing each other and not in order.
It would be hard. And it would not really be reading. That's what 'reading' code is.
I reference it again, because it is great and it makes a lot of good points.
One thing it says is that 'Code Doesn't Age'. Specifically, Joel says this:
The idea that new code is better than old is patently absurd.
This is true in many senses: code doesn't get rusty, code doesn't wear out after the millionth time it's used, and you can make a thousand copies and this does not effect the code's quality in any way. Also, as he says, old code has been tested, where new code has not.
However, code can age, and I want to talk a bit about that and what it means to you. How can this ageless thing age? Here's how:
Code Doesn't Stand Alone - unless you have a very, very simple program, it is connected to lots of libraries and (today) APIs. These things don't stay the same, nor are they supported forever. So, your code doesn't physically get old, but sometimes the things that it relies on break, or they get changed, or they are killed off. When this happens, your code just got old, very fast.
Code Runs on Something - it used to be hardware, and deep inside of a data center somewhere that is still true. But even when we're only talking about VMs, VMs have operating systems and supporting code and those things aren't supported forever either.
Code is Written by People - and people don't write COBOL anymore. Or at least most people don't. People also don't write VB or C++ as much as they used to. Sometimes perfectly good technologies fall out of favor and everyone learns something new making your product hard to support.
It used to be, most of what I'm describing happened over a long period of time. COBOL didn't go away overnight, that took decades. But with things being more and more interconnected via APIs, and with more changes coming quickly to platforms and other programs, the pace of change is increasing.
APIs change all the time, which is great (Hooray for new features and better performance!) and also challenging (I have to make the changes by when?).
Sometimes things come and go quickly or you make a bad choice. Silverlight anyone?
So, code doesn't physically age, but it is dependent on things around it. Those things can change or break. If that happens, the code has to be kept up or it has to be refactored or (sometimes) you need to rewrite an application entirely because the people who built the original are all retired.
The good news - you get to build something great with new technology that leverages all the awesome things your old project did, but is new and shiny and fun to code.
The bad news - all the things in that article are still true. So, you need to plan for them.