top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Question about length of ActionDispatch::Routing::Mapper class file

+1 vote
354 views

Our team lead and I recently discussed the pros and cons of breaking up a long source file into multiple source files. I tend to prefer one class per file, because I find the individual files easier to read and easier to find (with ctrl-p in Sublime). On the other hand, our team lead doesnt have issues with long source files. He argues that they are quite common in open-source projects. As an example, he pointed to the ActionDispatch::Routing::Mapper class in Rails as a case of a long file with multiple inline classes.

I am curious to learn the intent behind keeping all the contents of Mapper class within a single file. What were the advantages of taking this approach?

posted Sep 8, 2015 by anonymous

Looking for an answer?  Promote on:
Facebook Share Button Twitter Share Button LinkedIn Share Button
on my case, my reason is simple. I edit a single responsibility, easy for my brain and easy for my tests.

Also I don't buy that argument (it has no argument really); the rails source is not a god : )

Choose what you think is easy for you, why you think it's easy, then justify, demonstrate it.

Similar Questions
0 votes

I have deployed a ruby on rails app on two instances of production server, now there are two separate log file are being created for different instances. My question is how I can make a single log file for both the instances?

+2 votes

What you used to do when your controller function gets lengthy sometimes ? A way I found is just split the function. What is the real and Rails way to keep my code cleaner and maintainable.

+2 votes

I declared a variable and incremented/modified it inside Mapper class. Now I need to use the modified value of that variable in Driver class. I declared a static variable inside Mapper class and its modified value works in Driver class when I run the code in Eclipse IDE. But after creating that code as a runable jar from Eclipse and run jar file as “$ hadoop jar filename.jar input output” modified value does not reflect (value is 0) in Driver class.

+1 vote

Something like x.instance_variables.each.... { |i} .... }

Thought to be a one liner. I can't figure out how to apply strip() to each variable, since instance_variable_get returns the value. I really want something I can apply .strip! to....

+1 vote

When setting the class static variables, These are shared across all the instances created.

Class A
 @@bool_var = true

 def get_bool_var
 @@bool_var
 end
end

All the instances will have this static variable, When through a controller, a user requests, Based on some logic, I set the value to false.

Is this class static variable be set to false in all the other requests from other users on a web application ?

...