conventions

What's the golden code/comment ratio? [closed]

蓝咒 提交于 2019-11-30 08:16:44
Is there a code/comment ratio that you consider to be a sign of good (bad) code health? Can you give examples of open source projects that are considered to be well coded and their respective comment ratio? (I realize that no ratio is "true" for every project and there may very well be crappy projects that exhibit this theoretical golden ratio. Still...) Comments should be very rare and valuable, almost always expressing the "why" and never the "how" (the exception being when the how is complex and not easily discernible from the code). Every comment is a hint that you may need to refactor to

Where do you put your Rack middleware files and requires?

落爺英雄遲暮 提交于 2019-11-30 06:20:33
问题 I'm in the process of refactoring some logic built into a Rails application into middleware, and one annoyance I've run into is a seeming lack of convention for where to put them. Currently I've settled on app/middleware but I could just as easily move it to vendor/middleware or maybe vendor/plugins/middleware ... The biggest problem is having to require the individual files at the top of config/environment.rb require "app/middleware/system_message" require "app/middleware/rack_backstage" or

Netbeans 7.4 introduces “10 lines max” per method rule. Where does this rule come from?

北城余情 提交于 2019-11-29 22:45:24
NetBeans 7.4 beta is currently available for public download, and it introduces a weird warning rule by default: Method length is 16 lines (10 allowed) My question is: Is this an accepted code convention rule, that can be proven somehow, somewhere ? NetBeans support/devs say it's not a bug, but don't give a statement why they only allow 10 lines, and where exactly this rule has its origin. Milen You can change the maximum method/function length warning behavior in NetBeans options (it's under Tools->Options->Editor , in the Hints tab, under " Too Many Lines " section in the checkboxes list).

Large Django application layout

被刻印的时光 ゝ 提交于 2019-11-29 20:59:31
I am in a team developing a web-based university portal, which will be based on Django. We are still in the exploratory stages, and I am trying to find the best way to lay the project/development environment out. My initial idea is to develop the system as a Django "app", which contains sub-applications to separate out the different parts of the system. The reason I intended to make these "sub" applications is that they would not have any use outside the parent application whatsoever, so there would be little point in distributing them separately. We envisage that the portal will be installed

What is the relationship between java:comp/env and java:global?

删除回忆录丶 提交于 2019-11-29 20:38:19
What is the relationship between java:comp/env and java:global (regarding 3.1 spec)? Seems like java:comp/env contains specific to EJB references. What means "specific" in this case? java:global is a namespace that's global for the entire application server, which includes other EAR modules (which are considered to be different applications). java:comp/env is a much smaller namespace. For the web module, it corresponds to all web components (servlets etc) which are all together considered to be a single 'component' for JNDI, but for EJB beans it's a namespace for a single bean, since every

Should arrays be used in C++?

我与影子孤独终老i 提交于 2019-11-29 20:00:52
Since std::list and std::vector exist, is there a reason to use traditional C arrays in C++, or should they be avoided, just like malloc ? In C++11 where std::array is available, the answer is "yes, arrays should be avoided". Prior to C++11, you may need to use C arrays to allocate arrays in the automatic storage (i.e. on the stack). James Kanze Definitely, although with std::array in C++11, practically only for static data. C style arrays have three important advantages over std::vector : They don't require dynamic allocation. For this reason, C style arrays are to be preferred where you're

Is there a standard for inclusive/exclusive ends of time intervals?

我怕爱的太早我们不能终老 提交于 2019-11-29 19:43:38
I'm wondering if there is a standard or "normal" means of interpreting time interval data end points with respect to inclusiveness/exclusiveness of the value defining the end point. Note however that I am asking what the standard (or most common) convention is (if there is one), not for a dissertation on your personal preference. If you really want to provide a dissertation, please attach it to a reference to someone's published standard or a standard text on the matter. Open standards (that I don't have to pay to read) are greatly preferred unless they are fundamentally flawed :). Of course

Is there any technical reason to use or not to use var in C# when the type is known?

纵然是瞬间 提交于 2019-11-29 17:51:52
问题 It seems that more and more C# code I read uses the var type identifier: foreach (var itemChange in ItemChanges) { //... } instead of explicitly stating the type: foreach (ItemChange itemChange in ItemChanges) { //... } even when the type is known. I am still using the latter explicit version just because I think someone reading it later will more quickly understand which type a variable is than if you use var. But is there any technical reason to use one or the other? 回答1: There is no

Fail vs. raise in Ruby : Should we really believe the style guide?

做~自己de王妃 提交于 2019-11-29 15:55:19
问题 Ruby offers two possibilities to cause an exception programmatically: raise and fail , both being Kernel methods. According to the documents, they are absolutely equivalent. Out of a habit, I used only raise so far. Now I found several recommendations (for example here), to use raise for exceptions to be caught, and fail for serious errors which are not meant to be handled. But does it really make sense? When you are writing a class or module, and cause a problem deep inside, which you signal

Automatic iVars with @synthesize

北城以北 提交于 2019-11-29 14:43:37
问题 I understand that starting with iOS 4, there is now the ability to not declare iVars at all, and allow the compiler to automatically create them for you when you synthesize the property. However, I cannot find any documentation from Apple on this feature. Also, is there any documentation on best practices or Apple recommended guidelines on using iVars and properties? I have always use properties like this: .h file @interface myClass { NSIndexPath *_indexPath } @property(nonatomic, retain)