code-standards

How do I configure autoformatting in Eclipse?

坚强是说给别人听的谎言 提交于 2019-11-27 22:09:26
问题 I dislike how auto format messes up empty cycle body, like: Before for (int i = 0; isTest(i); i++); After for (int i = 0; isTest(i); i++) ; How to configure eclipse not to do this? 回答1: Go to Windows -> Preferences , and in the options table select Java -> Code Style -> Formatter , then configure to your hearts content. For future reference, in the Preferences menu you can just type in a search term to find all options for that term - so just going onto the Preferences menu and typing "format

Eclipse: Can you format code on save?

一个人想着一个人 提交于 2019-11-27 17:13:51
In Eclipse, under Windows -> Preference -> Java -> Code Style , you can define code templates for comments and code, and you can setup a code formatter. I'm wondering if it is possible in Eclipse to have these setting take affect every time I save a source file. Basically, instead of me highlighting everything and pressing Ctrl + Shift + F , I want Eclipse to be responsible for making sure my code is formatted properly. Is this possible and how do you set it up? Note On Using the Auto-Format: It's probably best to choose "Format Edited Lines" as merging changes becomes very difficult when you

How to use @Nullable and @Nonnull annotations more effectively?

懵懂的女人 提交于 2019-11-27 09:16:50
问题 I can see that @Nullable and @Nonnull annotations could be helpful in preventing NullPointerException s but they do not propagate very far. The effectiveness of these annotations drop off completely after one level of indirection, so if you only add a few they don't propagate very far. Since these annotations are not well enforced there is a danger of assuming a value marked with @Nonnull is not null and consequently not performing null checks. The code below causes a parameter marked with

How do I modify Eclipse code formatting?

血红的双手。 提交于 2019-11-27 08:15:52
When I reformat code with Eclipse, it turns method headers like this: public void myMethod(String param) { into method headers like this: public void myMethod( String param) { When I was brought on here I'd never used Eclipse before, and I imported project settings provided by someone else. I have seen that on small new projects I've worked on Eclipse does not do this, so it must be in the settings I've imported. But I've gone through every panel I can find, as well as every hidden file I can find in the workspace, and I can't figure out what is causing this. How do I turn it off? I don't want

jQuery Standards and Best Practice [closed]

断了今生、忘了曾经 提交于 2019-11-27 02:25:36
I’m currently responsible for rolling out the use of jQuery to the community of Web Developers within our company. Part of this involves presenting a course, however another part involves communicating standards and best practice. If you Google 'jQuery best practice', you’ll probably find the following among the search results. http://www.smashingmagazine.com/2008/09/16/jquery-examples-and-best-practices/ http://www.artzstudio.com/2009/04/jquery-performance-rules/ These have been helpful and I have gleamed much useful information on them. However, what I would be really interested in would be

jQuery best practices in case of $('document').ready

吃可爱长大的小学妹 提交于 2019-11-26 23:59:38
问题 I was researching on jQuery best practices and found this article by Greg Franko Normally, I do: $("document").ready(function() { // The DOM is ready! // The rest of the code goes here }); But the article recommends to use: // IIFE - Immediately Invoked Function Expression (function($, window, document) { // The $ is now locally scoped // Listen for the jQuery ready event on the document $(function() { // The DOM is ready! }); // The rest of the code goes here! }(window.jQuery, window,

Eclipse: Can you format code on save?

时光怂恿深爱的人放手 提交于 2019-11-26 18:54:42
问题 In Eclipse, under Windows -> Preference -> Java -> Code Style , you can define code templates for comments and code, and you can setup a code formatter. I'm wondering if it is possible in Eclipse to have these setting take affect every time I save a source file. Basically, instead of me highlighting everything and pressing Ctrl + Shift + F , I want Eclipse to be responsible for making sure my code is formatted properly. Is this possible and how do you set it up? Note On Using the Auto-Format:

jQuery Standards and Best Practice [closed]

雨燕双飞 提交于 2019-11-26 12:34:31
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . I’m currently responsible for rolling out the use of jQuery to the community of Web Developers within our company. Part of this