Good code review, nice SQL, smart deployment

Czas czytania: 4 min.

Knowing SQL syntax, creating complex queries, and using advanced
functionalities are not everything. The highest quality of developers’ services
means more than knowledge about programming language.

This time I would like to write a few words about three subjects which will
help you as a developer to increase the quality of your services and make you more
professional and efficient in this industry: code review, SQL best practices
and smart deployments. 

 
Code review

What is code review? A code review is a process where one or more developers analyze a teammate’s code, identifying bugs, logic errors, and overlooked edge cases.

Why do we do code reviews? 

·        Increasing Code Quality

No developer is perfect, but everyone is different and has a unique perspective. The main advantage of code review is decreasing the number of bugs and logical errors. This is a big time and money saver. It was proven by HP in 80’s that code reviews save more money than fixing defects after they were found by customers.

·        Learning

Code reviews are an important part of that learning process for both the reviewer and the reviewee. Even if there are no bugs in the code, you can exchange your experience with another developer in this little brainstorm and provide the best possible solution.

·        Knowledge Exchange

When new developers get onboarded on a new project, code reviews help them to understand the structure of the code faster. This is also a great opportunity to share knowledge about new code with the rest of the team – the better knowledge about product developers have, the easier is next development. In some cases, it is a good idea to invite a support team for code review as well if knowledge about changes will help them in their work.

How to review code?

  • Review fewer than 400 lines of code at a time

Code Reveiw

  • Take your time. Inspection rates should under 500 LOC per hour

Code Reveiw

  • Do not review for more than 60 minutes at a time
  • Use checklists
  • Choose the right tool

How to prepare for code review?

  • Put comments in your code – It is much easier to review a change if it is commented meaningfully
  • Format your code – No “oneliners”, proper indents, just write nice to read code
  • Find a subject matter expert – SME should be familiar with the area of the change and should be able to evaluate your code from both perspectives technical and logical.
  • Prepare yourself for presenting the business and technical background of the change – be ready to describe your change in simple words and give some business background to a reviewer to allow a faster understanding of a change.

Every company and every developer’s team is a better place when a code review is practiced.

SQL best practices

  • Multiline code – no „oneliners”, multiline code is much easier to see changes and it is very good practice from a code versioning point of view.
  • Indentation/Alignment – it is much easier to read and understand a code when it is indented and aligned properly
  • Modularize Code (e.g. CTE) – this is more bugproof and professional if your code is modularized properly, i.e. according to business logic
  • Naming Convention
    • Letter-casing – you should use a coherent and consistent naming convention in your whole code, this is the next proof of high quality and professionalism
    • Descriptive Names – it is important for other developers and for authors to use descriptive names of objects, variables, etc. Who will remember after a year what the “proc1”, “proc2” and “var1“ and “var2” do?
  • Simplify Code (e.g. temporary procedures) – make your code the simplest possible. If you need to repeat some operations in your code, create a temporary procedure for this. If you need to use some set of data multiple times try to use a temporary table for it. Do not copy and paste the same part of the code many times.
  • Write Useful Comments – meaningful comments are very important for many people: developers, reviewers, release managers, and support team members. This is not a big effort to put some comments in a code but you can save a lot of time and money for people in the future. This is just a high quality code, a high quality service.

 

Deployments

Have you ever wondered what is a good way to deploy your SQL code to a database server? How to do it smart if you don’t have any CI/CD or deployment automation in your project? To handle multi-object deployments and eliminate potential issues coming from manual deployment? How to do smart deployments in SQL Server? The answer is: deployment script that uses SQLCMD. If you are already managing your code properly in your local machine, you can create deployment scripts by pointing to proper files from your filesystem. Then you can be sure, that no object was changed during deployment script creation. The very helpful and important rule is to create code that is runnable in every environment. In other words – your code should be universal. Then your deployment script can be universal. In this situation, you are able to make a bug-free, multi-object deployments with one click.

 

Conclusion

Developers’ professionalism is more than the ability to write code. It matters how this code looks like, and how it is stored if version history and documentation exist. Good code review, good looking code, good comments causing less regression, less effort on support the product. All those things (and more) drive every project to higher quality, efficiency and customer satisfaction.

Facebook
Twitter
LinkedIn

Kontakt

Sprzedaż

+48 571 947 256

sprzedaz@polarysgroup.com

Biuro

+48 789 189 061

office@polarysgroup.com

Polarys Polska Sp. z o.o.
ul. Rakowicka 1/20-21
31-511 Kraków

Kontakt

Ola Wojdyła

Kontakt

Wspieramy firmy o każdej wielkości
i z każdej branży.

Pomożemy ci w doborze odpowiedniej technologii i rozwiązań, aby zwiększyć przejrzystość procesów twojej organizacji i opracować nowe cyfrowe modele biznesowe. 

Zespół naszych ekspertów czeka na twoje pytania.

Po wysłaniu formularza skontaktujemy się z tobą w ciągu dwóch dni, aby porozmawiać o twoich potrzebach.

Zaufali nam: