3 karma · joined Dec 12, 2012 (13y ago) · 12 submissions
comment 13y ago · link · parent
We should care about each other and take care of each other first, then obey laws to care for each other second, then third have freedom.
comment 13y ago · link · parent
Looking at flat comments for an involved discussion is sometimes confusing because you have to scroll around even more to see who is replying to what.
Maybe PG would provide an option in user config to view comments in a list rather than a tree if we asked.
comment 13y ago · link · parent
Additional things to think about:
* https://github.com/railsjedi/rails_config for local developer config
* There is a reason for autoloading: faster development. Even though you should not usually need to make app-specific configuration changes outside of the main environment.rb and each environment-specific config (development.rb, etc.), if you do, you might consider putting them into a module in an autoload path, and make sure that the fully-qualified path (A::B::C maps to something like app/models/a/b/c.rb) is correct, so that it autoloads without trouble.
* Some suggest putting constants for frequently used values in a file somewhere under config/initializers. That way Rails doesn't complain when reloading them. But, that doesn't autoload if you make changes in development.
* You can extend a Module that is autoloaded with methods that are "marked" with module_function :method_name to become private class methods on the class that extends them. This way you have non-inheriting methods that basically act like config variables.
* You can just use class_attribute in Rails to define inheritable attributes and then use self.the_class_attr_name = something to set them in the body of the class for configuration.
* attr_accessor :some_var_name, @@some_class_var, @some_instance_var, a hash, a Struct, or a OpenStruct are fine ways to hold config values and can be set inline for class vars, in the initialize method for instance vars, or methods called by other hooks, depending on what you need.
* Usually avoid $some_global_var as there is no way to tell whether it has been defined nor whether it has been set explicitly to nil.
comment 13y ago · link · parent
comment 13y ago · link · parent
This is a good idea- everyone worth their salt wants a third-party single auth service, perhaps one that we pay an annual fee for, however this ain't it yet. You should not piggyback. Don't.
comment 13y ago · link · parent
However, considering the last Indiana Jones film was a miserable flop (spoiler ahead: was it the hiding in the refrigerator or the UFO that nailed that coffin), they would have to fully recreate the old Harrison Ford in CGI PERFECTLY with a great plot to get me interested, and btw Disney I expect the same for the new star wars final trilogy or the remake of the first three after removing all of the Jar Jar sequences and replacing the obi wan with a younger CGI version of Alec Guiness and getting rid of the lame Jabba, etc. bad CGI crap they added to New Hope, etc. People should learn a lesson from LucasArts; when you have customers for life, continue to cater to them as they age. Also what about some Biggs Darklighter in a new series? For the kids, how about an Ewok that learns to kick ass in a tie fighter?
comment 13y ago · link · parent
Here is the link to the sample: https://learn.thoughtbot.com/ruby-science-sample.pdf
And here are some counterpoints:
Long methods are not as easily testable, but overly short methods can make code much harder to read and follow and actually increase complexity, because now there are many more entry points, leading to excessive nil checking, etc. for those practicing paranoid TDD.
Even the developers of Rails are not sold on the promise of the null object pattern, and as it states as almost an afterthought that "it can lead to confusion" (paraphrased). If you are a developer, especially one that is a refugee from a more "type-safe" language, you are more likely to assume that:
an_object.a_method
Will fail if an_object is nil/null. By making an_object a null object, then you can end up with is_a?(NullSomething) when other programmers are using your API, defeating the whole purpose of trying to avoid additional try's and other checks in the code. It can be a bad code smell to use null object pattern in many situations.
Case statements can be a bad code smell, just as is_a?(...), but not in every situation. Often they can be a clear and concise way to get the job done. In Java the switch statement was ridiculed, only to produce a whole generation of Java developers that either had chained if's or would create 3x the code just to introduce a pattern for simple logic!
So, if the rest of this book is like this, please take it with a grain of salt. It is a reference for another way of thinking about things, but if you are going to do that, read "Design Patterns" by the GoF and "Refactoring" by Martin Fowler also. And then forget all of that and try to write DRY Ruby code in as few lines as possible without tests to get a feel for that. Then give both up and seek a middle ground. In this way, you will be like Bhudda. Neither conservative "tests, patterns, and refactoring is the only way or you are shunned" nor liberal "it doesn't matter how you write it, just write what you like" are the ways to enlightenment; it is the way between them.