Create new models / classes within a module / namespace
GitLab has become an incredibly broad product with so many features and components. There are multiple on-going initiatives that try to help with reducing cognitive load that engineers experience when working on
- Introducing domain maintainers gitlab-com/www-gitlab-com#4517
- Reorganize CI/CD classes #209745
- Decoupled services #31121
- Make teams to be maintainers of their code #25872
The essential complexity of having so many concepts represented in our backend code in
gitlab-rails is significant.
We keep creating top-level classes like
class Requirement < ApplicationRecord ee/app/models/requirement.rb. Given the amount of concepts and business rules that our backend code needs to model, it might be difficult for some people to understand what the
Requirement class stands for. Looking at the class implementation does not make it easier to understand that as well.
- New classes should be created inside a module if there is no good reason to make them top-level classes
- Add Rubocop rule that forbids adding new top-level classes without a comment describing a class purpose
- Document it better what the benefits of using modules and nested structure are and what the impact on engineers productivity might be
What do you think @gitlab-org/maintainers/rails-backend?