AWS Certified Cloud Practitioner

I am not the first man who writes about that and shares his own experience but anyway would like to add some points from my side. Recently I have passed AWS CCP exam which is the foundational level…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




2 vs 4 spaces indentation for coding

Ever found yourself trying to decide if 2 or 4 spaces is best for your new code project? Great! Keep reading.

I could save you the hassle of reading the entire post and tell you which of the two is better. As you probably know, it’s based on individual preference for personal/solo projects and coding guidelines if you are coding for an organization (assuming the organization has coding guidelines).

My preference as a software developer is to use 2-space indentation in front-end projects and 4-space indentation in backend projects. However, using 4-space indentation gives more margin than required. On the flip side, 2-space indentation makes for inadequate spacing and may reduce code readability in some cases.

Why not have the best of both worlds? Use 3 spaces/tab . It’s a no brainer right? The 2 and 4 space indentation as we know is a convention that has been widely adopted. Don’t bother trying to debate if 3 space indentation is valid for coding. I use 3 spaces indentation in my new projects. This is clearly communicated to the other team members at the start of the project.

That said, I’ll leave the space vs tab indentation comparison for another post.

I’ll be glad to get your views on 3 space/tab indentation in the comment section. Thanks for reading.

Add a comment

Related posts:

How to efficiently use List Comprehensions in Python

Imagine you have a toy box full of different types of toys — cars, dolls, balls, and so on. Now, you want to pick out only the cars from the toy box and put them into another box. How would you do…

Happy Easter Every Bunny

Wherever you are and whatever you are doing, my wishes for you are to be safe and to look forward to renewal and hope. The Easter story is about strength and endurance and resurrection. The current…

A Journey of a Laser Cutting Machine and Asphalt Plant Supplier

In the ever-evolving landscape of industrial manufacturing, few industries have experienced such remarkable advancements as laser cutting and asphalt production. At the heart of these transformations…