Let's summarize how to extend the expiration date of Rails

Introduction

At the end of the year, the Advent calendar is booming. Rails entries are also busy. Inspired by the following entries, I thought I'd try to summarize how development can proceed even a little even if it becomes a large-scale development. https://okuramasafumi.hatenablog.jp/entry/2020/12/16/224401 https://blog.unasuke.com/2020/i-have-to-learn-those-things-in-the-future/

Way of thinking

This article does not deal with discussions about DDD or architecture, but focuses on specific Ruby coding methods. First of all, why is Rails not suitable for large scale in principle? Let's think about why it gets harder as development progresses.

Reasons not suitable for large-scale development: -** The reference point of the class or object cannot be grasped accurately. For this reason, it is difficult to add functions as well as refactoring, and the speed and quality of development deteriorates. ** **

You do not have this experience? --I was following the Gem source code, but I don't know where the method definition is. --The nesting is too deep and you cannot understand the processing contents.

One of the major differences between scripted and compiled languages ​​like Ruby is dynamic function calls, which is a major reason why development becomes more difficult as it grows in scale. As a means to solve this, I think that methods such as DDD are often adopted.

Coding to make the reference part as explicit as possible

To make the reference explicit, you can roughly say ** "Avoid Metapro" **. In particular, --Avoid dynamic method definitions = --Avoid code that changes processing using # respond_to? --Do not use # send --Do not process static processing dynamically (Example: Create a display using .each for ActiveRecord attributes in view)

It's like that.

It's not a metapro, but there are some standard Rails features that you should avoid.

--Avoid including/mixins of modules such as Concern Should be transferred to another class --Avoid ActiveRecord's before_ */after_ * Call a method from another class with a service pattern, command pattern, etc.

Define coding rules

Considering more practical operation, if you set the points introduced so far as coding rules and share them with the team, you can prevent the increase of debt and create a desirable situation. Also, it will be necessary to check in the review whether these things are observed, but it will increase the burden on the reviewer, so it is ideal to detect it with a tool such as querly. With this, even when new members join, the burden on the team is reduced, quality is maintained, and new members can become familiar with themselves as much as possible.

Miscellaneous feelings

It became like a miscellaneous note book because it was collected, but I also want to re-edit it in an integrated manner. By all means, I would be grateful if you could comment on things you don't understand (reasons to avoid and remedies) and other points that you should be aware of.

Recommended Posts

Let's summarize how to extend the expiration date of Rails
[Rails] How to change the column name of the table
[Rails] How to get the contents of strong parameters
[Rails] How to display the list of posts by category
[Rails] How to get the URL of the transition source and redirect
[Rails / Heroku / MySQL] How to reset the DB of Rails application on Heroku
[Rails] How to omit the display of the character string of the link_to method
[Rails] How to change the page title of the browser for each page
Let's summarize "MVC" of Ruby on Rails
How to determine the number of parallels
[Java] How to set the Date time to 00:00:00
How to sort the List of SelectItem
How to get the date in java
The process of introducing Vuetify to Rails
How to decorate the radio button of rails6 form_with (helper) with CSS
How to solve the local environment construction of Ruby on Rails (MAC)!
[Ruby On Rails] How to search the contents of params using include?
How to make the schema of the URL generated by Rails URL helper https
[Rails] How to solve the time lag of created_at after save method
[Rails] How to decide the destination by "rails routes"
How to find the cause of the Ruby error
[Rails] Introduction of pry-rails ~ How to debug binding.pry
How to get today's day of the week
Output of how to use the slice method
[Validation] rails How to specify after today's date
How to use JQuery in js.erb of Rails6
How to display the result of form input
[Java] How to get the authority of the folder
Try to summarize the common layout with rails
How to check Rails commands in the terminal
[Ruby on Rails] How to make the link destination part of the specified id
[Ruby on Rails] Rails tutorial Chapter 14 Summary of how to implement the status feed
How to make a unique combination of data in the rails intermediate table
[Ruby on Rails] How to Japaneseize the error message of Form object (ActiveModel)
How to write Rails
How to uninstall Rails
[Java] How to use compareTo method of Date class
How to delete / update the list field of OneToMany
How to set the display time to Japan time in Rails
Extend Highfaces to flip the vertical axis of the graph
How to write Scala from the perspective of Java
How to remove the underline displayed by Rails link_to
I tried to summarize the state transition of docker
[Rails, JS] How to implement asynchronous display of comments
[Ruby] How to find the sum of each digit
[Ruby on Rails] How to change the column name
How to install the root certificate of Centos7 (Cybertrust)
[Java] How to get the maximum value of HashMap
[Rails] I don't know how to use the model ...
How to write a date comparison search in Rails
[Android] How to get the setting language of the terminal
How to judge the click of any area of the image
How to download the old version of Apache Tomcat
[Swift] How to get the document ID of Firebase
[Rails] How to display an image in the view
How to install Docker in the local environment of an existing Rails application [Rails 6 / MySQL 8]
[Rough explanation] How to separate the operation of the production environment and the development environment with Rails
[Rails] How to display the weather forecast of the registered address in Japanese using OpenWeatherMap
[rails] How to post images
[Ruby On Rails] How to search and save the data of the parent table from the child table
How to display the select field of time_select every 30 minutes