Codementor Events

Be a smart developer

Published Jun 27, 2018
Be a smart developer

It is often really hard to stop yourself from questioning "can I do this" when working on an a development assignment. I started developing that way, and found that I ended up hurriedly throwing things into the editor because I wasn't sure I could make something work. And it always lead to building an incomprehensible mess of spaghetti code. And regret!

Is this you?

You start building a web app, but you know you need a home page with an elegant design and a database and OAUTH security and ...

Before you know where you are you have a mass of code that you need to get working. And even the stuff you wrote a few hours ago is not fresh in your mind and is difficult to fully understand. And there are so many error messages and defects to tackle...

There's a better approach, that may seem slower, but actually is a lot faster.

In a nutshell

Take things one small step at a time. Use the tools that you have available wisely (and that doesn't mean anything fancy). A good editor and version control are all you need (I'll leave choosing
those to another post).

The better way

Here is how to make it easier, and to develop smarter.

  1. Pick a small feature (it doesn't really matter which; let's say start with the web page).
  2. Write a few lines of code and get an empty page to display.
  3. And here is the important bit: commit the change to source control. I keep the following command available in a terminal
    git add . && git commit -m "blah blah"
    and then all I need to do is to up arrow, change the message and press return.
  4. Now I test the code to see if it does what I want, I tweak it (and maybe commit the change again) until the code works.
  5. Then I commit, with a message indicating I'm done with that function for now and move on to the next.
  6. And repeat.

Now, if (sorry, when) I mess things up I just revert to the last good change in source control, and start again from there.

It may sound inefficient, but I'm focusing on one thing at a time and I know it works before I move on.

And even better

Automated testing can help make this process even more efficient. Watch out for a post on that in the near future.

Please give this approach a try. And let me know how it goes.

Discover and read more posts from Andy Miles
get started
post commentsBe the first to share your opinion
Show more replies