Top "Coding-style" questions

**DO NOT USE!

How to generically format a boolean to a Yes/No string?

I would like to display Yes/No in different languages according to some boolean variable. Is there a generic way …

c# formatting coding-style string-formatting
Is there a better way of writing v = (v == 0 ? 1 : 0);

I want to toggle a variable between 0 and 1. If it's 0 I want to set it to 1, else if it's 1 I …

javascript variables coding-style toggle
What's the correct way to sort Python `import x` and `from x import y` statements?

The python style guide suggests to group imports like this: Imports should be grouped in the following order: standard library …

python coding-style python-import pep8
XSLT Stylesheet: Changing text to upper case

I am using an XSLT stylesheet to create an Excel document from an XML file. One of the values that …

xslt coding-style uppercase
Why is it considered a bad practice to omit curly braces?

Why does everyone tell me writing code like this is a bad practice? if (foo) Bar(); //or for(int i = 0 …

java c# c++ c coding-style
Using do block vs braces {}

New to ruby, put on your newbie gloves. Is there any difference (obscure or practical) between the following two snippets? …

ruby coding-style
Using private static methods

What do you think about using private static methods? Personally, I prefer using a static private method to non-static as …

java oop coding-style static-methods
Unobtrusive JavaScript: <script> at the top or the bottom of the HTML code?

I've recently read the Yahoo manifesto Best Practices for Speeding Up Your Web Site. They recommend to put the JavaScript …

javascript performance optimization coding-style
Applying Styles To ListItems in CheckBoxList

How can styles be applied to CheckBoxList ListItems. Unlike other controls, such as the Repeater where you can specify <…

asp.net html controls coding-style
JavaScript style for optional callbacks

I have some functions which occasionally (not always) will receive a callback and run it. Is checking if the callback …

javascript coding-style callback