Upgrade to Pro — share decks privately, control downloads, hide ads and more …

[SaigonRB#20] Clean code in Ruby

[SaigonRB#20] Clean code in Ruby

Hoang Duc Quan

March 14, 2025
Tweet

More Decks by Hoang Duc Quan

Other Decks in Programming

Transcript

  1. About me Hoang Quan Born: Hanoi, Vietnam Work: Tokyo, Japan

    Github: BlazingRockStorm Viblo: Hoàng Đức Quân
  2. Agenda Topics Covered Why clean code is necessary? Coding convention

    Rubocop and setup Pronto and integration with Github actions
  3. Clean code is the code that is easy to read,

    understand, and maintain What is clean code?
  4. Readability and maintenance: Clean code prioritizes clarity, which makes reading,

    understanding, and modifying code easier. Writing readable code reduces the time required to grasp the code's functionality, leading to faster development times. Why clean code is necessary?
  5. Team collaboration: Clear and consistent code facilitates communication and cooperation

    among team members. By adhering to established coding standards and writing readable code, developers easily understand each other's work and collaborate more effectively. Why clean code is necessary?
  6. Debugging and issue resolution: Clean code is designed with clarity

    and simplicity, making it easier to locate and understand specific sections of the codebase. Clear structure, meaningful variable names, and well-defined functions make it easier to identify and resolve issues. Why clean code is necessary?
  7. Improved quality and reliability: Clean code prioritizes following established coding

    standards and writing well-structured code. This reduces the risk of introducing errors, leading to higher-quality and more reliable software down the line. Why clean code is necessary?
  8. Coding convention Coding conventions are a set of guidelines for

    a specific programming language that recommend programming style, practices, and methods for each aspect of a program written in that language.
  9. Coding convention These conventions usually cover file organization, indentation, comments,

    declarations, statements, white space, naming conventions, programming practices, programming principles, programming rules of thumb, architectural best practices, etc. These are guidelines for software structural quality.
  10. Rubocop RuboCop is a Ruby code style checker (linter) and

    formatter based on the community-driven Ruby Style Guide. RuboCop is extremely flexible and most aspects of its behavior can be tweaked via various configuration options. In practice RuboCop supports pretty much every (reasonably popular) coding style that you can think of. Apart from reporting problems in your code, RuboCop can also automatically fix some of the problems for you.
  11. https://github.com/prontolabs/pronto Pronto runs analysis quickly by checking only the relevant

    changes. Created to be used on GitHub pull requests, but also works locally and integrates with GitLab and Bitbucket. Written in Ruby Pronto