How do you write good code?
How do we write code that looks good?
This is the question that many developers and designers are looking to answer as they write their code, and a new book by MIT graduate student Jeremy Gebbia provides an answer.
Gebbi, who’s also a software engineer at Dropbox, says that the best ways to write code are to be “a bit creative and do some exercises” to build confidence.
“We need to have a good understanding of the code and be able to put the pieces together,” he says.
“In a sense, that’s the point of having a book like this: to help you understand the code better.”
Gebbis’s book, The Codebook, will be released in March and has been praised for its practical exercises, which he says make it easy to get the most out of the time you spend writing code.
Among the exercises, Gebbs recommends working through a few exercises in order to become more confident.
“For example, when you’re in the middle of an assignment, try to figure out which exercises are the most important,” he writes.
“If you’re a novice programmer, this may not be obvious.
But if you’re the kind of person who spends an hour writing a function, that may be the most valuable part of the book.”
You’ll find a list of 30 exercises in the book, which also includes a checklist for learning more about each exercise.
Gebbia says that for anyone who wants to improve their writing skills, he recommends working with other developers to find the exercises that are most relevant to you.
“The best thing you can do is to find a mentor or a team,” he explains.
“And then learn from that.”
One of the exercises Gebbias recommends is “How to Write Code with a Testable Approach,” which is a type of exercise where you use the test-driven development approach to write your code.
You can check out the book for yourself here.
Gbbia’s advice is that you don’t have to write a test-based code, but that you should make sure that it looks and feels right.
“When you write code, you’re not just writing a test, you are writing something that’s going to fail, which means that it’s going out and failing, and you’re going to have to learn from those failures,” he tells Ars.
You can also find a complete list of exercises in The Codebooks app, which can be downloaded for free.