0
  1. Is it affect the performance when i use the method 2 ?
  2. Which one is the best?

Method 1 (Combine all the method to single controller)

-controllers
    -account_controller.rb

Method 2

-controllers
    -account
        -register_controller.rb
        -update_controller.rb
        -login_controller.rb
        -logout_controller.rb

1 Answer 1

3

It won't impact performance. About what is best, that's not an easy question. Your method 2 example looks like "one method per controller", which looks a bit much to me.

The good metric is how long/complex your class is. You can use tools such as rubocop to watch this. When the class become too complex, it's not about splitting in files, but more ask yourself what responsibilities could be extracted from this controller into another one, or into a model or service.

In other words: the length and complexity of your code is not a problem for the machine - it's a problem for you/your colleagues.

Sign up to request clarification or add additional context in comments.

1 Comment

anecdotal: don't worry about performance until you have to worry about performance.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.