What is Refactoring?

To me, refactoring is one of the most important parts of the software development lifecycle. Most developers are familiar with the idea of refactoring, but customers and managers may not be.  So, what is refactoring and what value does it bring to the development process? Refactoring is the process of going through code and redesigning, updating, and fixing with the intent of improving the code. This can encompass a lot of different improvements. For example, a developer may find that certain blocks of code are repeated over and over again. Repeated code can cause all kinds of problems. At the very least it increases the size of the application needlessly, but on the more problematic size, it also decreases maintainability of the application. For example, if a code block is repeated 8 times, and the required logic for that code must change, the code will need to be replaced in 8 different places. Chances are good that developers will only find 7 and you’ll spend months trying to figure out where the problem is. Other common tasks involve redesigning to make the application cleaner, removing unnecessary code, and all sorts of things to generally improve the codebase. Why is this important, and what is the benefit to the organization? Without refactoring, code tends to become messy. Each new developer adds something new, code is duplicated, paradigms change, data models are updated, technologies are improved, etc. As these things happen, the application becomes increasingly difficult for developers to follow. Additionally, bugs increase, the size of the code increase, and things run less than optimally. In the end, refactoring is kind of like getting a tuneup on your car. As a good developer, I am always looking for ways to improve the code so that future developers will have an easier time maintaining the application. It’s incredibly important and should be a priority not only for developers but for management and customers as well.

Hacker Boxes

Every month, I eagerly await a package to arrive. It’s a small package, and it’s contents are always a surprise. What is it? It’s my HackerBox! HackerBoxes is a monthly service that sends you a box with some sort of tech project inside. Previous projects have included Raspberry Pi systems, Arduino micro controllers, GPS, circuits to connect to the cell network and so much more. This month, the project was to build and program an EKG device. An hour of soldering later, and I could measure all sorts of bodily signals. Through my monthly subscription, I have not only been exposed to new technologies (such as the amazing Micro:bit) but also been able to tinker with hardware at a lower level than I typically do – opportunities to tinker with circuits and hardware as well as the code that makes them work. It’s a great service, and one I would encourage all tech nerds to receive. While I may not make hardware for a living, the exposure to all the technologies I receive from HackerBoxes is well worth the price I pay.

 

Python Web Server

As a software developer, I often write HTML files or JavaScript code that I would like to see in my web browser. I could just open the file in my browser, but if I’m testing JavaScript I would rather run from a real server. I could start up an Apache server, or create an instance of NGINX using Docker. But both of those options require too much effort for simply testing an HTML file.  What I really want is just a command that will allow me to start an HTTP server in the folder where the HTML or JavaScript files are saved. Well, thanks to Python, such a option exists. Simply go to the directory where you want the server to run from and execute the command:

python -m SimpleHTTPServer 8080

This will start up a simple HTTP server running on port 8080. Now, point your web browser to localhost:8080 and you can see your web page! Nothing could be simpler for quick testing of web pages or websites!

Scamming the Scammer

Day after day, I receive calls from thieves in India. For several months, they said they were with Microsoft and that my computer had a virus that they wanted to help me fix. Now, they claim to be with a credit card company wanting to lower my interest rate. What’s sad is that people fall for these tricks all the time. Often, the elderly are the most  vulnerable – not only because they tend to have a fixed income, but because they are also more easily confused and duped. Because of this, I have made it my civic duty to waste as much time as possible on the phone with the scammers. After all, the more time they waste talking to me, the less time they have to scam an elderly grandmother.

Just a few days ago, I received two calls in a single afternoon from hackers –  and I took them both for a ride. When they asked for a credit card number, I gave them one of the test credit numbers typically used by developers for application testing – just google ‘test credit card numbers’ for a list. They asked for a bank name, I said Wells Fargo. They asked for birthday, last four of SSN, and other information. I provided false – but believable – answers. Then, after providing the information, they asked me to stay on hold while they verified my data. After another minute or so, the scammer got back on the phone: “We contacted your bank and found out that you are an *********” and hung up on me. Few things are quite as fun as having a scammer call you names or swear at you because you wasted their time!

Five Technologies for 2018

It’s a new year, and new years mean new challenges. And how can those challenges be faced? By staying up-to-date with technologies and ensuring you have the skills to turn those challenges into opportunities. But there are so many technologies out there, which ones do you learn? I have selected 5 technologies that I think everyone should learn in 2018. These are not necessarily new technologies. In fact, most of technologies listed have been around for awhile and I believe developers can no longer afford to ignore them.

Docker
For the last decade, virtual machines have been used to startup new servers. This work great, but is very wasteful of resources. Not only that, it’s very time consuming to both setup and configure. Docker is much simpler and less resource intensive. Want an Apache server, or a MySQL database? Start a Docker instance with that service. Need to experiment with nginx for a new project? Spawn a Docker server to tinker with your new technology. With thousands of images for a sorts of services, it’s likely that you can find what you need. I run my Jenkins and Artifactory services using Docker – it took minutes to setup and has been running for a year or more. There is simply no faster way to setup servers than using Docker.

Angular
The JavaScript world is in constant flux. Technologies come and go, and it’s hard to keep track of them all. As such, many are reluctant to dive too deep into JavaScript technologies for fear of their pending obsolescence when a new framework come out. However, if you look at job openings for web architectures, you will see over and over the desire for Angular developers. And there’s good reason for that – Angular is a great framework. The best thing about Angular, in my opinion, is how easily it is to write reusable components. In a world where businesses solve the same problems over and over, reusability saves time and money. Outside of the web world, Angular is also used by the Ionic framework for creating cross-platform mobile applications. Thus, if you know Angular you can not only develop cutting-edge web applications, but you can easily move into the realm of Android and iOS development.

Kotlin
This one is a bit more speculation the the other technologies on my list. However, since it’s supported by Android, I expect to see it grow in popularity this year with the possibility of overtaking Java in popularity for native Android development at some point in the future. The Android Developer page for Kotlin lists a variety of reasons to switch to Kotlin – including safer code, concise data classes and lambda expressions, default and named arguments (something very popular in a variety of other languages), as well as being fully interoperable with Java. Numerous JVM languages, such as Groovy and Scala, have failed to gain wide-spread usage, but Google’s support for Kotlin code in Android may just change the game.

Linux
Linux is anything but new. In fact, it’s been around for decades now. However, it’s sad to see how many people in the tech world are still uncomfortable with the Linux command line. With all the technologies available today that use Linux, it’s time to learn it now! What are those technologies? Docker, Raspberry Pi, AWS, Google Cloud, and Android, all use Linux. Mac OSX has, in large part, become amazingly popular with Linux-savy developers because it uses BSD (A Linux variant) under the hood. Countless other technologies run on Linux or simply run better on Linux. For example, setting up a LAMP stack, running Python, or setting up Node is a breeze in Linux – but can be far more painful on Windows. Connectivity tools such as SSH and SCP run natively too – making deployment and configuration of servers and services easier. If you’re not familiar with Linux, you’re probably working too hard to get your solutions working on Windows.

.NET Core
After just enumerating the benefits of Linux, it may be odd to see a Windows technology on the list. However, The .NET Core framework runs on non-windows machines – and that’s exactly why it’s great! Microsoft’s Entity Framework and their MVC implementation both make for greatly streamlined web development. Running it on a Linux server is icing on the cake. I expect to see growth in .NET Core this year as developers exploit the simplicity of .NET development with the control and deployment power of Linux and Docker servers.

Why I Write Simple Code

Simplicity

As per Kernighan’s law: “Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.”

Brian Kernighan, the author of the above law, is among the most famous of all computer scientists. He, along with Dennis Ritchie, authored “The C Programming Language”, one of the most well known of all computer programming books. As such, Brian Kernighan’s ideas carry a lot of weight.

Kernighan’s law sounds simple, but it carries a profound truth – that clever code is bad code. When I was a younger programmer, I thought writing clever code was a great idea. I loved writing code that made me appear to be a wizard of coding. Of course, when you write complex code, you realize the first time you try to fix a bug that the code isn’t maintainable. Now, after 20 years of programming, I aim to write simple code – the simpler the better. I want any programmer – today or in a decade – to be able to look at my code and figure it out without any effort. Simple code is maintainable code.

Do you write simple code? Do you hire programmers that write simple code? More importantly, when you hire contractors do they write simple code? Contractors are notorious for writing ‘clever’ code so that you have to keep them onboard long-term to maintain the code they wrote.  For a business, this is a huge – and costly – mistake! Clever code will cost you far more than you think over the lifetime of an application!

 

Slow and Steady Wins the Race

Giant Tortoise

One of my hobbies is game development. I have been tinkering with Unity for several years now; and I’ve also experimented with  Java, Android, C++, and a few other platforms. Unity is, without a doubt, my favorite. The ease of developing 3D games coupled with their outstanding framework makes it an easy platform for developing games. So, when I was asked to help teach a Unity game development class at the high school a few years back, I was excited and gladly took the opportunity. I teach C# scripting to the students every Friday, and it’s great fun.

This last week, I was going over some simple code on creating projectiles and applying the scripts for their movement and destruction. I had started a project a few weeks before, and most of my code was there. However, when I went to continue the project I found that my code was no longer on the computer. Given that the class is only 50 minutes long, this was a real showstopper. I frantically tried to recreate the project I had before and get it to a point where I could continue with my lesson. Unfortunately, circumstances worked against me and my presentation was less than stellar. This experience reinforced two important lessons from computer programming that I will be sharing with the class next week.

First, I have been busy the last few months with my own business and have not been doing as much game development as I would like. This kept me from being on top of my game at class. I made some noob mistakes, and was unable to perform at my peak since my skills were a little rusty from months of under usage. In the tech world today, this is easy to have happen. The world of software development has so many tools, frameworks, languages, and platforms. Developers are increasingly expected to know countless technologies, and it’s almost impossible to be an expert in them all. For example, I have written plenty of Python code over the years, but I still have to pull up my sample code when I need a new script. Why? Because I don’t use python on a daily basis and I quickly get rusty. To stay up-to-date on skills requires constant effort.

Second, rushing to complete something will cause errors. This is as true in software as it is in any other endeavor in life. As I rushed to complete my code by the end of class, I caused more errors. And, in the end, nothing worked the way I wanted. Had I slowed down, I would have been better able to ensure that what I was doing worked the way I wanted.  However, the imposed deadline made me work without paying attention to the details. This happens in real world projects too. Unrealistic deadlines force programmers to pound out code without paying attention to the details. Errors are made, code is left undocumented, test cases are not written. Then, when the code is released, it doesn’t work as desired. Of course, deadlines are a part of the real world. But if we are rushed to meet unrealistic deadlines, we can be certain that the result will be less than desirable.

In the end, this experience shows some very real truths about software development. Much like the story of the tortoise and the hare, we see that slow and steady wins the race. We have to constantly reinforce the skills we want to use, we can’t let them get rusty. And, we need to take our time to ensure that the code we produce meets more than just timelines – it must be developed so that it is solid and stable.

Google Alerts

One of Google’s most under-utilitized tools is Google Alerts (google.com/alerts). This service allows you to receive emails with new results for particular search strings. While this may not seem useful, it is an excellent tool for being notified of information that may appear on the net about you or your business. With the rise of identity theft and the harm that can come from negative posts about you or your business online, it’s imperative to know what information is being posted out there about you. In Google Alerts, you simply enter the searches you want, and Google will notify you of new results. I encourage anyone who wants to keep an eye on their online-footprint to setup searches for all possible variants of their name and let Google do the rest!

Code Warnings

As a developer, I often look at someone else’s code. It may be a coworker, an open source project, or a code snippet on Stack Overflow. No matter the source, I often look at the code and wonder why something was done the way it was. That’s ok – that’s just part of being a developer. But some things make you seriously question the original developer’s technical prowess. For example, I was looking at some code today that was annotated to ignore all warnings. That’s a pretty brave move, as it assumes you know better than the computer does where problems may be. Reality is, you don’t. And when you ignore all warnings, you set yourself up for failure. For example, today I saw a piece of code with countless variables that were all context-specific in Android. When I removed the ‘hide warnings’ annotation, I saw countless warnings about how these variables would cause memory leaks. That’s pretty serious for a long running application, and it negatively impacts the user experience. Certainly some, in fact many, warnings can be safely ignored. But ignoring all warnings is a recipe for disaster.

Cheap Computers

Yesterday, I started up my spare laptop to load an Android Studio project. The laptop I normally use for this project was at the office, and I was sitting at home. I had to upgrade the version of Android Studio first, and then load the project. But, after over an hour, I still had not written a single line of code. On my Mac, I could have upgraded and had the project open and running in under ten minutes – but my old Windows computer is so slow it’s painful.

Consider the company you work for or the projects you work on. What is the cost of using slow hardware to your organization? What about to your productivity on your projects?

Many people look to buy a cheap computer for work and, indeed, a large number of companies do the same. Why spend too much on computers? Here’s why – when you buy a $500 machine instead of a $1,000 machine, you saved $500. However, during the lifetime of that computer – say two years – you will be less productive than on a more powerful computer that doesn’t have you waiting to work. Do the math and you quickly see that the $500 you saved in cheap hardware is dwarfed by the losses to productivity. If a faster computer allows you to work just a marginal 5% faster, that would mean that – during the course of 2 years – you would accomplish an additional 208 hours of work. (40 hours / week * 52 weeks / year * 2 years * 5%) Even at minimum wage, that comes out to over $1,500 dollars of additional work. Some may argue that the work they do doesn’t require a fast computer. That’s fine, buy cheap computers for those tasks. But for me, as a software engineer, the computer is often a limiting factor to my performance. And, I suspect many other fields are the same.

The power of the machines you purchase for your employees has a direct impact on their productivity. You may think you’re saving money with bargain computers, but long-term you’re losing far more in productivity.