Five principles that define a good code
Isn’t is confusing and frustrating to not able to understand your own code after coming back from vacation? We all have been there. One of the major reason being, as developers, we would want to get the work done. Agreed.
We do crazy amount of coding every single day at Skcript. We write code in such a way that its universally understandable by others in the team, giving us good space to learn a lot from each other.
Over the past few years, we’ve been following certain techniques and ethics when coding a product. From our experience, here are the top five that takes the front row when we evaluate our code before signing off our work.
1. Commenting
Whenever you work on a new module, always make sure you have all of the module name, features, description and preferably, the workflow mentioned in the comments.
Commenting doesn’t stop just here. Make sure you provide a detailed and description commit messages whenever you’re pushing your code to the master repository. A lengthy, descriptive and searchable commit message would help you in the longer run.
2. Hierarchy
A very well planned code speaks for itself. It’s always good to go back to the paper to structure and design your code with the logic you have in mind before opening up your favorite code editor. Bringing in a hierarchy for your code makes it easier to fine and quickly troubleshoot the issue.
3. Breakdowns
While hierarchy is one major coding ethics that you can follow. Breaking down your code into pieces is another important one. Anything that you use more than once should be defined globally for you to access from anywhere. For example, if you are truncating the title of a div to fit the width programmatically, its always good to use the helpers in Rails, rather than just writing the same code over and over again.
4. Consistency
Internally, we use our own style guides to make sure everybody’s code is consistent. For example, if you are writing CSS code, you can use our CSS style guide to make sure the code is consistent throughout the product and the company.
It’s always advisable to have a universal style guide for your organization. This helps everyone to be on the same page, and reduce dependency on the developers.
5. Styling
Everyone has their own style of writing code. One of the best practices that we follow at Skcript, is that we always try to finish off a code block in less than 5 lines. For example, the CSS that we write will have less than 5% repetitive code, helping us increase the computation speed of the browser.
It’s going to be super fun
We have unlimited fun writing code every single day. We work out of a single GitHub repo, and everyday when we look at the commits, and the graphs of our repo, we feel super proud for reflecting our passion in the code we write. Also, writing good and consistent code has helped us build better and stable products quickly.
SHAPE
To learn and share the best coding practices that the industry experts use, we’re hosting our first conference called SHAPE. You can get yourself registered at this portal. The conference will be invite-only and free to attend.
Originally published at blog.skcript.com.