Effective Java: recommended 18 years ago, still top of my recommended reading list today

In past years I used to put together a recommended reading list for software developers, particularly Java developers. I think I stopped doing it as often because year to year my list really didn’t change much, if at all.

As an example, 18 years ago, Effective Java by Josh Bloch I would say was required reading for all Java developers, new and experienced. It would still be at the top of my list today. It’s essential reading and solid guidance for all Java developers. If you’re a Java developer and you haven’t read this book yet, pick up a copy and read it now.

As an industry we do a poor job of teaching new developers how to develop software

This is not a criticism of any specific school course, bootcamp or on the job training, it’s merely an observation over the years: early Spring and late Autumn/Fall there is always an increase online of very basic developer questions. These questions always include things like: “why doesn’t my code work”, “can someone debug this for me”, “why does this code not produce the result I’m looking for”, and even the flatout “please help me with my homework – here’s the assignment”

These points in time coincide with the start of a new term as new students are starting to learn a programming language, I guess it’s pretty much expected that we would see the number of these types of question increase during these times of the year. My point though is that these types of questions appear again and again every year. Every. Year.

Why have we not progressed past the point where new developers don’t need to ask basic questions as they are starting out? Why are software development courses not equipping new developers with basic problem solving skills to help them trouble solve basic problems for themselves?

Most of these questions and problems could easily be solved by the developers themselves if they stepped through their code in a debugger in their IDE and looked at what happens in their code step by step up to the point where something goes wrong usually because of a simple logic error.

Other problems could easily be solved by applying basic problem solving and software development core techniques:

  • breaking a large problem down into smaller parts
  • writing unit tests to test each smaller part of the app in isolation to confirm each part works by itself
  • testing with a range of valid and invalid values to find what works and what doesn’t work
  • using log statements to trace execution through an app
  • identifying what changed since it was last working, incrementally backing out last changes to find the point where a change was added that broke something
  • using a debugger

There’s too much emphasis on learning a programming language to write code, and not enough focus on techniques to develop software. None of things I listed above are new ideas or concepts, experienced developers have applied these concepts daily for decades. It seems we’re failing short in training new developers if we’re missing out the basics.

Resetting a GitHub Personal Access Token on MacOS

Personal Access Token’s are used to grant access to one of your repos with specific permissions. They have an expiry, so when one expires you need to recreate a new one, details are here.

If you’re trying to push and your token has expired, you’ll see an error like this:

> git push
remote: Invalid username or password.
fatal: Authentication failed for 'https://github.com/youraccount/yourrepo

The first time accessing a repo requiring authentication is simpler because it will prompt you for your id and password (or token). Once you’ve set one up though, it’s not as obvious how to reset a new token value, since the git cli only gives you the above error, it doesn’t prompt you to enter a new password/token.

To replace your cached credentials, use these steps (from here):

git config --global --unset credential.helper

git credential-osxkeychain erase
host=github.com
protocol=https

Press Return twice on the second step. Close your Terminal, open a new one, then:

git config --global user.name "userid"
git config --global user.email you@example.com

From your GitHub account, go to Settings from the top right icon, then Developer Settings, then Personal Access Tokens.

Next time you do a push, use the Personal Access Token value when prompted for your password.

Fix the problems you have, not what you don’t have

It’s easy for new developers to get caught up spending time on things that really don’t matter. Spending time trying to work out whether approach A is using more or less memory than approach B is a common distraction, and usually the answer to whether it does or not is irrelevant (why would you be concerned if memory for a variable is stored on the heap or the stack, and try to do do ‘weird things’ to reduce memory usage).

It’s important to know if you have a problem or not, and then spend time investigating and resolving that specific problem. Don’t spend time worrying about things that are not important or irrelevant. Knowing what is important often comes with experience, but if you’re unsure then ask one of your more experienced collegues.

[Top tip series: rather than spending time writing lengthy articles over several days I’m going to try and post shorter, hopefully useful tips more frequently]