Code Reviews

The dreaded code review, they are a time consuming unnecessary annoyance that stop us from developing software, right !

WRONG, they are integral to a software quality process. Without a code review strategy any code that you write has the potential to destroy the project. A code review should be something that’s embraced by all developers as it allows you to get another persons perspective on the code.

Most developers work very closely with the code and start to feel very protective over it when people start to suggest changes or say that its just not right or doesn’t resolve the task / bug that it was written to resolve.

In software development you cannot afford to get protective over the code that you write because the code you write on a Monday may be code that someone else is changing on a Wednesday.

Code reviews can be performed in a number of ways, there is the totally independent review where the person who is reviewing the code simply takes the code changes that you have committed to a local source code repository (such as a local GIT repository) and comparing that against the previous check-in’s and to see if the code looks sensible and matches the bug / task brief. The feedback that they give will either be positive; i.e. “the code changes look sound, should be committed” or “sorry, this failed the review because of XYZ please correct this and resubmit for review”.

The independent reviews can be quite harsh as the person who is reviewing the code doesn’t know you, doesn’t care about any issues outside of the code. Getting responses like “what on earth were you thinking!” or “This is utter rubbish” can really get you down, but hopefully with comments like these your reviewer would leave some constructive comments detailing why they think that and maybe even giving an example of how they would have done it.

The review is a two way learning process; you may learn something during the review which will influence the code you write. On the other side you may get comments like “this is pure genius” or “cool code!” which may mean that you have managed to teach the reviewer something that they can take away and implement in their own code.

Another type of review that may occur is where a colleague sits next to you and reviews it as you explain the solution to the problem; they will want to see a suite of passing unit tests, code differences and explanations as to why you implemented it in that way. These reviews, in some respects can be more difficult to deal with as you will know the person. In this type of situation its difficult to tell a person that you know and have worked with for a while that the code is just no good, its also very difficult to hear if your the one being told.

I’ve had this happen to me, being told the code is no good is the beginning of a constructive discussion. My first response when told this was “Ok, so explain to me why and then suggest an alternative solution to the problem”

Assuming that the reviewer has a valid point and there solution is viable you can adjust your code accordingly. Remember that software development is a continuous learning process, know one knows everything and one way that you can extend your knowledge is through processes like this.

The following checklist is something that i think is a good basis for a code review.

  • Does the code have comments on the classes / methods / properties and are spellings correct
  • Do variables have bad names, do they use abbreviations
  • Has code been duplicated, has a method been written elsewhere that does the same thing
  • Are null values handled correctly
  • Are input arguments being checked (for ranges, for nulls etc.. )
  • Are calls to external assemblies correctly trapped with try.. catch blocks
  • Does the logic make sense
  • Have unit tests been created/modified to cover the code
  • Do all unit tests for the solution pass
  • Could the code be optimized
  • Are there any bad design practices being used
  • Does the code meet the coding guidelines of your organisation
  • Is it possible for a method to return a null value, does the consuming code handle that
  • Does the code contain any logging information, if so does it expose any potential security risk

These are a few examples of things to look for, they are pretty basic so everyone should be able to follow them quite easily.

Here are some things that i try and do when i write code to make the whole development process easier

  • Use meaningful variable names, it doesn’t matter if they are long as long as they are not stupidly long and they explain what they are being used to hold
  • Avoid using the term “Temp” when naming anything because it wont end up being anything temporary will it
  • Avoid using the variable name retVal
  • Avoid calling classes / methods “Helper” or “Manager” unless they really are dedicated to managing something
  • Try not to create static variables / classes these are very difficult to unit test and are the firsts sign of a “code smell”
  • Check arguments as the first step in a method, throw ArgumentException, ArgumentNullExceptions or ArgumentOutOfRange exceptions where appropriate
  • Comment all your properties / methods / classes
  • Try not to put comments in the body of the code, it looks messy. Your code should be self documenting

These are a few things that i do, it would take a long time to write all of my considerations down but this should be a good start for anyone looking to
write code.

In the end its up to you to make your code cleaner and understandable as it will make maintaining it at a later date easier and will make code reviews more meaningful.

I hope that this article has helped you in some way with your code reviews

๐Ÿ™‚

31 Comments

  1. Most of the PHP developers leverage the web application development with their other technical
    skills, which they learn in their respective web development center.
    Where Innovation plus Quality are the major key factor in web developers Singapore.
    , is a Connecticut software development company offering mobile, web and server applications for customers worldwide.

  2. On the other hand, 8 ball pool hack cheat engine 6.2 these controls will provide an opportunity
    to build, and become the leader of the club or sponsorships and
    so on. What is the account that you could utilize tilt controller, minus the conventional interaction; i.

  3. He left behind the prayer rug so that anyone clever enough would see the pattern and
    escape. โ€ข Donโ€™t forget to check its compatibility with your building structure and the
    ability of the system to deliver a good sound quality which depends on the
    structure of your home. Make sure you clean your face thoroughly before moisturizing.

    Feel free to surf to my blog … ืžืกื’ืจื™ื” ื‘ื›ืคืจ ืกื‘ื | ืžืกื’ืจ ืžืกื’ืจื™ื•ืช ืื• ืžืกื’ืจื™ื ื‘ื›ืคืจ ืกื‘ื ื•ื›ืคืจ ืกื‘ื ืคื™ืชื•ื—

  4. John Wild is vice president of Absolute Access & Security. ‘ Locksmiths can also give genuine suggestions on the kind of security systems which should be installed.
    In certain emergency situations, the availability of an expert locksmith in Delta BC is
    really helpful for the users.

    Feel free to surf to my blog post … ืขื‘ื•ื“ื•ืช ืžืชื›ืช ื‘ื”ืจืฆืœื™ื” ืคื™ืชื•ื—

  5. Having read this I believed it was really informative. I appreciate you spending
    some time and effort to put this content together. I once again find myself spending a significant amount of time both reading and posting comments.
    But so what, it was still worthwhile!

    Visit my blog post … http://www.youtube.com

  6. excellent submit, very informative. I ponder why the other
    experts of this sector don’t understand this.
    You should proceed your writing. I’m sure, you’ve a great readers’ base already!

  7. I mean panic away ocd to them how to live their
    lives. For all of your policy carefully and make the playoffs by many people.
    This activity is that your body is ultimately the path of destruction throughout the body.
    You didn’t have the supplies instead. This Examiner also presented testimony during Tuesday’s
    JCC meeting, noting donors were never taken them.
    Unfortunately, often periodontitis causes this
    problem is not labeled with lot numbers nor expiration dates.
    Natural health lifestyle is the same response.

  8. In addition to the kids, adults also play various online games through social
    networking sites and other modes. Many people have specific genres clash of clans hack download games they enjoy, but
    may not know what new games have come out.
    The pilots who want to keep the galaxy safe for freedom and democracy will need
    to learn gunnery, electronics, mechanical, and engineering, but they should start with the learning skill, which reduces the amount of time it takes for Eve
    Online characters to learn their skills.

  9. When I initially commented I clicked the “Notify me when new comments are added”
    checkbox and now each time a comment is added I get three e-mails with the same comment.

    Is there any way you can remove me from that service?
    Thanks!

  10. Hello just wanted to give you a quick heads up. The words in your content seem
    to be running off the screen in Chrome. I’m not sure if this is a format issue or
    something to do with web browser compatibility but I thought I’d post to let you
    know. The design and style look great though! Hope you get the problem resolved soon. Thanks

    my webpage twitter.com

  11. This is very interesting, You are an overly professional blogger.
    I have joined your feed and stay up for in quest of more of your
    great post. Also, I’ve shared your web site in my social networks

    Feel free to surf to my weblog :: ืคืจื™ืฆืช ืžื ืขื•ืœื™ื ืžื“ืจื™ืš ื‘ืชืœ ืื‘ื™ื‘

  12. Hello there! I know this is kinda off topic however I’d figured I’d
    ask. Would you be interested in exchanging links or maybe guest writing a blog post or vice-versa?
    My blog covers a lot of the same topics as yours and I feel we
    could greatly benefit from each other. If you happen to be interested feel
    free to send me an email. I look forward to hearing from you!
    Wonderful blog by the way!

    Also visit my web-site supplement reviews 2015 (Lamont)

  13. No matter if some one searches for his required thing, so he/she desires to be available that in detail, therefore that thing
    is maintained over here.

    Feel free to visit my web blog … pure asian garcinia reviews (Barbra)

  14. I think this is among the most significant info
    for me. And i am glad studying your article.
    However should commentary on few normal issues,
    The website style is great, the articles is truly nice : D.
    Just right process, cheers

    Here is my web-site :: nootrobrain tumblr [Celsa]

  15. Howdy! Would you mind if I share your blog with my twitter group?
    There’s a lot of people that I think would really enjoy your content.
    Please let me know. Many thanks

    Here is my web page Margie

  16. Howdy! I understand this is kind of off-topic however I had to
    ask. Does operating a well-established blog like yours take a large amount of work?
    I am brand new to writing a blog but I do write inn my journal every day.
    I’d like to start a blog sso I can share my personal experience
    and feelings online. Please let me know if you have any
    kind of ideas or tips for brand new aspiring bloggers.

    Thankyou!

    my bllog post; google.de (Kristeen)

  17. He was the co-founder and principal of GmbH (Belgium), an organization specializing in webmaster software improvement, industrial-strength
    cloaking and a wide range of upmarket seo instruments and companies, pioneering among other issues such benchmark products as the world’s most comprehensive database of verified search engine spiders, absolutely automated IP supply applications, link building community administration software program
    and automated customized content creation.

  18. This week we have stumbled throughout You Doodle,
    an app that shatters modern paradigms and gives you the
    unrelenting energy to… I’m just kidding, it is like MS Paint in your iPhone.

  19. Can I simply just say what a relief to discover a person that truly knows what they are discussing online.
    You certainly know how to bring a problem to light and make it important.
    A lot more people ought to check this out and understand this side of the story.
    I can’t believe you are not more popular because you
    certainly possess the gift.

Leave a Reply

Your email address will not be published.





five × 5 =