Standalone java base java formatter
Is there a Java-based program(jar) that can format java code(indenting/spacing). If it would be configurable that would be great. ...
Is there a Java-based program(jar) that can format java code(indenting/spacing). If it would be configurable that would be great. ...
Background In a C# command-line app I'm writing, several of the parameters have "yes" and "no" as the possible values. I am storing their input using the Enum type shown below. enum YesNo { Yes, No } Which is fine - the code works. No problem there. NOTE: Yes, I could store these as bool (that's how it used to work). My ...
Duplicate of: Naming Conventions in C# Where can I find the most common and up to date coding conventions for C#? ...
I know this is a matter of style, hence the subjective tag. I have a small piece of code, with two nested conditions. I could code it in two ways, and I'd like to see how more experienced developers think it should look like. Style 1: while (!String.IsNullOrEmpty(msg = reader.readMsg())) { RaiseMessageReceived(); if (parseMsg) ...
I need to automatically check the style of javascript sources written by different people. Do you know of a good tool to do it? Integration with emacs would be a plus. Thank you in advance. ...
Is it cool? IMO one-liners reduces the readability and makes debugging/understanding more difficult. ...
Effective Java (Second Edition), Item 4, discusses using private constructors to enforce noninstantiability. Here's the code sample from the book: public final class UtilityClass { private UtilityClass() { throw new AssertionError(); } } However, AssertionError doesn't seem like the right thing to throw. Nothing is bei...
I was reading some Java recently and came across something (an idiom?) new to me: in the program, classes with multiple constructors would also always include a blank constructor. For example: public class Genotype { private boolean bits[]; private int rating; private int length; private Random random; public Genotype() { ...
Sometimes I want to write a "major" comment to describe a large block of code and then write "minor" comments to describe a few of the lines within that block of code: // Major comment // Minor comment ... // Minor comment 2 ... The major comment looks strange without code directly beneath it, and you can't visually tell how much co...
I've been programming in C-derived languages for a couple of decades now. Somewhere along the line, I decided that I no longer wanted to write: if (var) // in C if ($var) # in Perl when what I meant was: if (var != 0) if (defined $var and $var ne '') I think part of it is that I have a strongly-typed brain and in my mind, "if...
I am looking for best practices for function/class/module documentation, i.e. comments in the code itself. Ideally I would like a comment template which is both human readable and consumable by Python documentation utilities. I have read the Python documentation on docstrings: http://docs.python.org/tutorial/controlflow.html. I underst...
When referencing class variables, why do people prepend it with this? I'm not talking about the case when this is used to disambiguate from method parameters, but rather when it seems unnecessary. Example: public class Person { private String name; public String toString() { return this.name; } } In toStr...
I've seen this questions here. I'm wondering if there exists an offical name for the following indent style: void fooBar(String s) { while (true) { // ... do something } } When the opening brace is in the same line as the control statement, the statments within are indented and the closing brace is on the same iden...
I have a list of booleans where occasionally I reset them all to false. After first writing the reset as: for b in bool_list: b = False I found it doesn't work. I spent a moment scratching my head, then remembered that of course it won't work since I'm only changing a reference to the bool, not its value. So I rewrote as: for i i...
I'm working for a company that has strict coding style guidelines but no automatic tool to validate them. I've looked around and the only tools I could find were lint like tools that seem to be aimed at verifying what the code does, and preventing bugs and not at making sure the coding style is correct. What tool should we use, if at al...
I found this statement is some old code and it took me a second to figure out... IsTestActive = (TestStateID == 1 ? true : false); Please correct me if I'm wrong but isn't this the same as this one?: IsTestActive = (TestStateID == 1); If it is, why would you ever want to use the first? Which one is more readable? (I think the latt...
After going through the Appendix A, "C# Coding Style Conventions" of the great book "Framework Design Guidelines" (2nd edition from November 2008), I am quite confused as to what coding style is Microsoft using internally / recommending. The blog entry A Brief History Of C# Style claims: In fact, the differences between the "StyleCo...
Are there any good CSS coding style/standards? ...
I mean to name ids, names, values, etc? ...
I've recently started using it. However, after running it against one of my company's largest project. It turns up mountains of problems. The list of problems was so overwhelming it would take days to find and fix some, if not all of the stuff. Now, I know that it's not very practical to fix everything FxCop tells you to fix. But as I ...