DEV Community

bright inventions
bright inventions

Posted on • Updated on • Originally published at brightinventions.pl

Self code review

Once I was a child my parents were convincing me that it was worth double checking both my homework as well as tests before handing them in, to catch errors and fix them. It soon became a habit for me. The habit that once evaluated into a self code review process :)

I will share with you the steps I take before commiting code. Probably most of them are obvious to you, but maybe you will find something interesting and worth including into your routine?

1. Compilation errors

This might seem to be quite obvious. If the code doesn’t compile, how can you even check if it works? I have added this step to my in-mind checklist lately as in our TypeScript projects the compile script is a little more “strict” than the one for running an app in the hot reloading mode (e.g. compilation errors on unused imports). So even though the app recompiles seamlessly, it will not compile on the CI server.

2. Warnings

I actually quite like a strict approach when warnings prevent compilation. But this is not always the case, so it’s worth having in mind to look through the warnings and apply fixes where needed.

3. Unit and integration tests

Just run all tests and see if they are green. This is also the time for some framework-specific checks, e.g. mocha requires to append only() to test methods to run a specific subset of the tests. Of course you need to remove it before commiting :) Do you know any other frameworks’ features which are likely to produce this kind of leftovers?

4. The code review itself

I usually list all the files that have changed and then read them carefully one by one, paying special attention to the following elements (the similarity to an ordinary code review process is not accidental :) ).

  • All the little things that make the code cleaner like all the shorthands or smart methods that modern languages have (to name a few: Kotlin’s isNullOrEmpty or Scala's getOrElse). IDEs give lots of such hints, we just need to make use of them.
  • Spelling - typos make the code messy :)
  • Rethink the names of classes, variables and so on. Are they meaningful enough? Or maybe too verbose?
  • Any too complicated constructions like long computations or nested conditions? If I have just written it and still do not get the sense at first glance, maybe there is a way to make it cleaner?

IDEs make this kind of reading easier. In the code editing window you have the changed lines marked so you know which ones to focus on at most. I know some of us use the diff window for this purpose. I usually prefer the more gentle way of highlighting the differences, but that’s quite personal - try both and decide which is the best for you. Or just combine them.

5. The big picture

Then I read the code again, taking the big picture this time. The aim is to check if the code is clear and understandable, if it just reads smoothly.

6. CI server check

Once I have committed and pushed, the last step is to check if the code compiles and the tests are green on the CI server.

Do I apply this routine each and every time? Does this routine prevent me from checking some fishy code in? Of course not, we all know scenarios of delivering a feature as soon as possible or just a little change which surely does not require all these steps. Commits like Fix typos or Remove “only” from tests still happen :) But after all, we are only humans and we all make mistakes. And the teammate code review is just irreplaceable :)

Originally published at brightinventions.pl

By Agnieszka Olszewska, Software Engineer @ Bright Inventions
Email

Latest comments (15)

Collapse
 
exchangesavvy profile image
Exchange Savvy

Successful migration to Microsoft 365 requires careful planning and execution. Conducting a thorough assessment of existing data, defining migration goals, and choosing appropriate migration strategies are essential steps. Following best practices ensures a smooth transition with minimal downtime and data loss. exchangesavvy.com/

Collapse
 
moretranz profile image
More Tranz

Sublimation transfers involve printing designs onto special paper using sublimation ink, which is then heat pressed onto polyester fabric. This method produces vivid and long-lasting prints, making it popular for full-color designs.

Collapse
 
wearvarsity profile image
Get Varsity Jackets

Get ready to rock the fashion scene with the must-have ateez bomber jacket! This stylish piece is a true statement-maker, perfect for all fans of the sensational K-pop group. Crafted with premium quality materials, it ensures both comfort and durability. The ATEEZ bomber jacket features the iconic group logo and vibrant colors that showcase your love and support. Whether you're attending a concert or simply want to stand out in style, this jacket is a wardrobe essential. So, gear up, embrace the energetic vibes, and make heads turn with the ATEEZ bomber jacket - a must-have for every K-pop enthusiast!

Collapse
 
ramonmiles profile image
RamonMiles

Dubai's recording studios epitomize excellence in audio production. Equipped with state-of-the-art technology, these sanctuaries of sound provide unparalleled creative spaces for artists and musicians. From world-class mixing consoles to high-end acoustics, every detail is meticulously crafted to capture the essence of musical genius. recording studio in dubai are the epitome of luxury and precision, inspiring the creation of unforgettable sonic masterpieces.

Collapse
 
peterpaul3358 profile image
PeterPaul3358

49ers jacket mens are another popular style that can add a stylish edge to any outfit. They are versatile and can be worn with jeans or dressed up with a skirt or dress.

Collapse
 
peterpaul3358 profile image
PeterPaul3358

Nice Information Good Work Keep it Up! We are sell the best Yellowstone Season 5 John Dutton Grey blazer in USA with Free delivery.

Collapse
 
peterpaul3358 profile image
PeterPaul3358

Nice Information Good Work Keep it Up! We are sell the best Yellowstone Season 5 John Dutton Grey blazer in USA with Free delivery.

Collapse
 
yellowstonejac2 profile image
Yellowstone Jackets • Edited

Yellowstone based on the American television series & Yellowstone Jackets is now available.
yellowstone Jacket

Collapse
 
elmokub profile image
elmokub

Through your pen I found the problem up interesting! I believe there are many other people who are interested in them just like me! How long does it take to complete this article? I hope you continue to have such quality articles to share with everyone! I believe a lot of people will be surprised to read this article! Thanks for your post! cookie clicker

Collapse
 
sophiekells profile image
Sophiekells

My brother is into coding. I think he will find this post useful. I was planning to learn a bit of coding as well but then I got busy with my work. I started providing master thesis help and it leaves me with no time to learn coding. Anyway, I am sending this post to my brother – I hope he finds it helpful.

Collapse
 
adampeake20 profile image
AdamPeake

The post is really superb. It’s varied accessory information that consists during a basic and necessary method. Thanks for sharing this text. The substance is genuinely composed. This web log is frequently sharing lost vape orion useful actualities. Keep sharing a lot of posts.

Collapse
 
aliciab13550469 profile image
Alicia Black

I was lucky enough to go through the code review when I first came into contact with the development team in the "real world." Code review can get people to criticize their own code, but I found it especially helpful to get code review skills that are greatly better than my code.
Regards: Master Degree Dissertation

Collapse
 
usa_jacket profile image
USA Jacket

Yes it's nice offer i will love to take Cyberpunk 2077 Merch it's astounding

Collapse
 
jozephchristopher profile image
JozephChristopher

By using the code, I have made much improvements and i am sure that reviewing things in this way, there would be some services available from which people can buy dissertation online easily.

Collapse
 
sarahtaylor profile image
Sarah Taylor

The code review itself is really helpful for me and I am very happy when read about self code review I was shocked why don't people aware about it. Actually my profession is providing Cheap Dissertation service provider and this is and outstanding topic for me.

Some comments have been hidden by the post's author - find out more