DEV Community

Bruno Noriller
Bruno Noriller

Posted on • Originally published at Medium

Throw Away your Code!

Uncle Bob says “Software should be \"soft\" or easily changeable, unlike \"hard\" hardware.”.

And what’s more easily changeable than a code that can easily be deleted?

Low Stakes Coding: REPL

A REPL or some playground is something amazing for that.

Do you want to just play around with the syntax and methods? REPL!

While console REPL is nice, some languages have more features and niceties than others.

Languages like Python and Javascript make it so easy it amazes me how some people depend on debuggers and console prints for simple prototyping inside a feature.

In Python, you can just pop a notebook and have the same experience as you would normally have, one piece of code at a time, autocompletion, and all.

For Javascript, you can just open the browser console. But an even better way is using an extension like Quokka that even in the free version already helps a lot to quickly verify if what you want to do will work or not.

How to do it? Input + Output

You have the input, you know what you need as output. All you need to do is go from A to B.

When using the REPL, you don’t need to care about edge cases or even having everything perfectly as the actual code.

You just need the bare minimum to validate that from A you can get B.

Throw away the code

Now, the fun part…

You get what you learned in the REPL, not copy-paste.

You do it again, from “zero”. But now in your code.

And then… delete what you’ve made in the REPL.

Be promiscuous with code

The code is not sacred, it’s probably not even that good in the first stages…

Just code and delete it as soon as it’s not helping you anymore and make more code to replace it.

We are all at fault for commenting code because “what if I need it?”.

But…

Old code just drags you down!

The code you commented will just drag you down.

You might think that “you might need it”, but instead it becomes an anchor that makes you unable to find a better solution.

So delete it and be free to explore new solutions.

Top comments (0)