Clean code and the practice of programming

"Should I be descriptive or can I be lazy?"

When you are teaching yourself, it's easy to pick up bad habits or style because you don’t have someone checking your work. You don’t have many reference points for clean code because not many books/courses directly address these.

So, I want this newsletter to be your reference point for building your intuitions about beautiful code and good programming practices.


Here are 4 guiding principles that I personally follow to keep my code clean:

  1. Don’t settle for “it runs”.

  2. Write for readability - code is read more often than it is written.

  3. Explicit is better than implicit.

  4. Duplication may be the root of all evil in software.

These should help guide you when you are making decisions about designing your code.

I also want to share some more specific, actionable pieces of advice.

5 simple, actionable, good programming practices:

  1. Put some thought into choosing your variables’ names -
    Don’t be lazy with long descriptive names. Remember, most IDEs can autocomplete your variable names.

  2. Create new functions whenever necessary
    It is easy to understand the syntax of writing functions in your favorite language. But it takes practice and some sense of design to learn when to break the code into functions. You need to write small functions with descriptive names that do only one thing.

  3. Document your code and write helpful comments
    Remember, “documentation is a love letter that you write to your future self.” :p

  4. Be consistent in your coding style
    Consistent coding style is good coding style. It makes it easy for someone (including you, yourself) to dive into your code and read it in the future.

  5. If it breaks, assume that it’s (probably) your fault
    You are likely to spend a majority of your coding time banging your head over broken code. In those moments, you will inevitably try to shift the blame to your IDE, compiler, environment or your machine. But you should remember - It's not the computer, it's you. Only when you do that, will you be able to diagnose and get to the heart of the problem (even if it is some problem with the machine).

Finally,

Here are the 2 books that really helped form my own intuitions:

  1. Bob Martin's book Clean Code

  2. Brian W. Kerninghan’s book - The Practice of Programming

"The purpose of style is to make the code easy to read for yourself and others, and good style is crucial to good programming."

-Brian W. Kerninghan in his book - The Practice of Programming

I have written and published a detailed article about this called - Writing Clean Code and The Practice of Programming: Actionable advice for beginners. Check it out if you want to read a more detailed version of this newsletter!


Thanks a lot for reading! This was the Build To Learn newsletter and you can subscribe to it here.

If you think that coder friend of yours might find this newsletter useful as well, please forward it to him/her. :)

Also, if you have other such best principles that you follow, please let me know by replying to this email or reaching out to me on either Twitter or LinkedIn.

Finally, if you liked what you read, please hit the hardly-visible heart icon below. It will help in improving the visibility of this newsletter on Substack - the platform that hosts Build To Learn :-)

Teach yourself using a cool guided project

Advance your Python programming skills by building a Whatsapp Chat Analyser

Finding ways to apply your knowledge after the learning process essentially means that the learning happened without much sense of a destination. All we were trying to do was amass all the knowledge we could, in the hope that it would come of use in some distant, mystical future.

Doesn't that feel like procrastination?

With Build To Learn, I want to approach learning by giving projects the primary importance

When you try to make something, you discover a hundred things that you don’t know. You discover things that you thought you knew but don’t really know. You trip over things that seemed so simple that you didn’t even pay attention to them. You fill the gaps in your learning.

Also, it is super fun and adventurous!

But there are a few problems with using this approach to teach yourself:

  • It’s hard to be structured because you are both the student and the curriculum designer

  • You aren’t sure if you are too much out of your depth

  • You get lost trying to find resources to teach yourself

That is why I have created a guide for you that you can use as a roadmap to help yourself build something cool - a Whatsapp Chat Analyser!

Okay so here's my project idea:

When chatting with a close friend, have you ever wanted to know -

  • the number of messages sent by each of you

  • your the average length of messages

  • who texts first and the first text in each conversation

  • your chatting time patterns - hourly, daily and monthly

  • most shared website links

  • most common words that each of you use

Wouldn't it be cool if you wrote a program that would just calculate all this stuff for you?!?

And what will you learn by doing this project?

Here are some textbook skills that you will pick up:

  • File handling

  • String operations in Python

  • Functions

  • Modules

  • PiP and using 3rd party packages

  • Regular Expressions (RegEx) in Python

But the guide is not a textbook. So along with them, you will also develop intuitions about good programming practices like:

  • The importance of readability of your code and coding style

  • When and how to break your code into functions

  • How to go about debugging your code (when you want to bang your head against the wall, instead)

  • How to look things up on the Internet - use Google, use StackOverflow, read documentation etc.

  • Understand the need for different data structures and when to use what


If you are intrigued as well, head over to the guide:

Advance your Python skills by Building a Whatsapp Chat Analyser: a Guided Project


Thanks a lot for reading! You can subscribe to the Build To Learn newsletter here.

If you liked this and want me to do more such guides please let me know by replying to this email or reaching out to me on either Twitter and LinkedIn.

Also, you can let me know your thoughts, opinions, comments or questions the same way! I would love to answer them. :)

If you think that friend of yours might find this newsletter interesting as well- It would be awesome if you could forward this newsletter to him/her.

Also, if you liked what you read, please hit the hardly-visible heart icon below. It will help in improving the visibility of this newsletter on Substack - the platform that hosts Build To Learn :-)

Fantastic Programming Project Ideas and Where To Find Them

A beginner-friendly version

Hey subscribers,

The task of getting good project ideas is difficult. Its probably the biggest hurdle that prevents us from building stuff. Right?

But aren't you tired of project suggestions like ToDo list app, ecom website and the Titanic dataset?

I have discovered 4 sources for getting good, unique, even cool project ideas —

I have written a detailed article on how they can help you easily discover new, cool ideas. It’s called “Fantastic Programming Project Ideas and Where To Find Them (a beginner-friendly version)”.

The article includes 5 ideas from each of the above source to demonstrate how easy it is to pick them up.

Here’s one from each:

Devpost

A simple notifications app that lets you select messaging apps that you want to block notifications from when the frequency of notifications exceeds 1 every 3 seconds.
And tricked yourself to learn - Android development

Kaggle

Analyse Spotify's Worldwide Daily Song dataset,

This dataset contains the daily ranking of the 200 most listened songs in 53 countries from 2017 and 2018 by Spotify users. It contains more than 2 million rows, which comprises 6629 artists, 18598 songs for a total count of one hundred five billion streams.

Spotify's Worldwide Daily Song dataset

And find answers to:

  • How long do songs "resist" on the top 3, 5, 10, 20 ranking in your country? Which songs are the outliers?

  • Which countries have similar tastes in music?

  • How long time does a top ranking song takes to get into the ranking of neighbor countries?

Data Is Plural

Analyse How couples meet and stay together. It is a survey of 4,002 adults, 3,009 of those had a spouse or main romantic partner. It even has follow-up surveys that were implemented one and two years after the main survey, to study couple dissolution rates.

An analysis can reveal answers to the following questions:

  • Do traditional couples and nontraditional couples meet in the same way? What kinds of couples are more likely to have met online?

  • Have the most recent marriage cohorts (especially the traditional heterosexual same-race married couples) met in the same way their parents and grandparents did?

  • Does meeting online lead to greater or less couple stability?

  • How do the couple dissolution rates of nontraditional couples compare to the couple dissolution rates of more traditional same-race heterosexual couples?

  • How does the availability of civil union, domestic partnership or same-sex marriage rights affect couple stability for same-sex couples?

Do check out the article for more such ideas. It has 4 goldmines of project ideas and 20 cool project ideas for app development, web development, Data Science and Machine Learning.


I published this article a day ago and I’m SO excited with the response that it has received that I just wanted to share it with the subscribers of this newsletter!

Achievements (YAAY! :D):

Thanks a lot for reading! You can subscribe to this newsletter here.

If you think that friend of yours might find this newsletter interesting as well- It would be awesome if you could forward this newsletter to him/her.

Also, if you liked what you read, please hit the hardly-visible heart icon below. It will help in improving the visibility of this newsletter on Substack - the platform that hosts Build To Learn :-)

Make self-learning fun and fulfilling

Welcome to Build To Learn newsletter by Nityesh!

Build to Learn is an online learning platform centered around doing projects and learning the necessary programming skills along the way. 

Enter your email below so I can let you know about new articles to help you self-learn programming, cool project ideas and more —

I’m excited to show you what I’ve been working on!

Loading more posts…