code-standards

How do I modify Eclipse code formatting?

混江龙づ霸主 提交于 2019-12-28 02:51:09
问题 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

How to customize Eclipse's text editor code formatting

醉酒当歌 提交于 2019-12-17 22:46:09
问题 How can I set my Eclipse's code formatter to allow code rows longer than 80 characters. I know that very long lines is hard to read but in my opinion 80 characters per line is very small value for wide screen monitors. 回答1: In Preferences , go to Java > Code Style > Formatter and edit/create the formatter and go to tab Line Wrapping . There in you can set the Maximum line width . Further on you can in General > Editors > Text Editors also set the Print margin column which should shift up that

Best practice for returning in PHP function/method

痴心易碎 提交于 2019-12-14 04:16:45
问题 I am refactoring an extensive codebase overtime. In the long run we are going to develop the whole system in classes but in the mean time I am using the opportunity to refine my PHP skills and improve some of the legacy code we use across several hundred websites. I have read conflicting articles over time about how best to return data from a custom function, generally the debate falls into two categories, those concerned about best technical practice and those concerned about ease of reading

Powershell verb for destroying a resource

邮差的信 提交于 2019-12-10 17:22:48
问题 I've been trying to stick with the approved list of Powershell verbs when naming my cmdlets. I have a function which creates a resource, so it's called New-ClearCaseView. I'd also like to make a function which destroys this resource once it is no longer in use. However, I don't see any pair verb to go with New. The Remove verb is closest I think, but that's for removing a resource from a collection, not for actually destroying a resource. Any suggestions? Is there any more up to date list of

Law of Demeter violation search tool? [closed]

感情迁移 提交于 2019-12-02 00:43:46
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . Does anybody know of a tool that I could use with a C# application to find possible Law of Demeter violations? I know that it would give a lot of false positives, but I think it could still be useful. Especially during the early design process. 回答1: If you're just looking for something.somethingelse.violation ,

Law of Demeter violation search tool? [closed]

烂漫一生 提交于 2019-12-01 21:41:43
Does anybody know of a tool that I could use with a C# application to find possible Law of Demeter violations? I know that it would give a lot of false positives, but I think it could still be useful. Especially during the early design process. If you're just looking for something.somethingelse.violation , then you can use Visual Studio. In the find dialog, check the box at the bottom to "Use" and select "Regular Expressions." Not very robust, but you can use <[:a_]+\.([:a_]+\.)+[:a_]+ to find the pattern above. A better tool would be grep or similar on the solution directory, so you can use

How do I configure autoformatting in Eclipse?

筅森魡賤 提交于 2019-11-29 03:33:40
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? tddmonkey 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" will show you all options 来源: https://stackoverflow.com/questions/1392744/how-do-i-configure

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

自闭症网瘾萝莉.ら 提交于 2019-11-28 15:33:23
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 @Nonnull to be null without raising any complaints. It throws a NullPointerException when it is run.

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

落花浮王杯 提交于 2019-11-28 03:04:35
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, document)); // The global jQuery object is passed as a parameter I can see the comments there, but I couldn't