coding-style

Eclipse Plugin or else for coding footnote

I love the Manning In Action Series. One of appealing area is that the code listing inside the book always has a footnote where there is a detailed explanation by a reference number. See below the example: So I'm wondering if there is an Eclipse plugin or online blogging service that allows footnote taking in the source code? ...

Which of `if x:` or `if x != 0:` is preferred in Python?

Assuming that x is an integer, the construct if x: is functionally the same as if x != 0: in Python. Some languages' style guides explicitly forbid against the former -- for example, ActionScript/Flex's style guide states that you should never implicitly cast an int to bool for this sort of thing. Does Python have a preference? A link t...

CSS and filename coding conventions

Hi, What kind of convention do you (or your company) run on filenames and CSS class names? For example, let's say you have these class names: window, window top, window top left, window top right. How do you name those class names (and such filenames)? Currently I am doing the following: .window { background: url(images/window.png); ...

JavaScript braces on new line or not?

Hi, At work, we place braces on the next line, but at home, I do the opposite. Which one do you prefer? (K&R vs OTBS) function something() { // ... } function something() { // ... } A lot of JavaScript libraries seem to use the OTBS (one true brace style). I'd like to follow them for consistence among other JavaScript projec...

coding standards in yii framework

is there any coding standard which follows yii framework, and where it is specified ...

php array - upper case or lower case

Hi, does it matter whether an uppercase or lower case a is used for php arrays? ...

Javascript: Why if(false) ?

I saw this in code. It blew my mind. <% if (false) { %> <script type="text/javascript" src="~/Scripts/jquery-1.3.2.js"></script> <% } %> This seems so patently illogical that it must be intentional. I can only assume that somehow this "came up", and somebody inserted this as a work-around. There are, of course, no comments. Why ...

Java String Comparison: style choice or optimization?

I've been taking a look at some GWT code written by various people and there are different ways of comparing strings. I'm curious if this is just a style choice, or if one is more optimized than another: "".equals(myString); myString.equals(""); myString.isEmpty(); Is there a difference? ...

Coding Style - Passing method as Parameter

Hi, I have very a basic question. I have a MethodB returning Integer. I have a MethodA where I want to pass the value retrieved from MethodB. Is it a right way (the coding style, not the syntax) to pass MethodB to MethodA as mentioned below? MethodA(MethodB()); Thanks. ...

What is proper ASP.NET style?

I'm just starting to do web pages in ASP and all of the code just feels... messy. <% if (new Random().NextDouble() < 0.5) { %> <asp:Image ID="image" runat="server" ImageUrl="~/1.jpg" /> <% } else { %> <asp:Image ID="image" runat="server" ImageUrl="~/2.jpg" /> <% } %> Currently, I have a very basic page that is light on content...

What do I call this style of programming?

I am working with a type that passes state through instance variables. So you'll see methods like so: public MyType MyMethod() { DoThisMethod(); DoThatMethod(); AndDoThis(); return _bleh; } Is this a recognised approach? It's a little disconcerting working with this code because if you don't understand the code fully, the i...

Should I be using `this` by default?

We all know that this refers to the actual instance of a class...but it seems to me that most people are not using it. So, should I be using it? My thoughts about it are as follows: Since this refers to the actual instance of a class, it should be used to access any member of that class. public void(String newValue) { this.pr...

Global Variables or Tricky variable Passing Scheme?

Hey everyone, As a bit of a background I'm about to be a senior in Comp E and currently working on a project for my internship involving iPad development using Monotouch and C#. As a student with multiple projects at once during the semesters, code style is often completely ignored in order to get the final product working. I'm sure you...

Should you always use 'int' for numbers in C, even if they are non-negative?

I always use unsigned int for values that should never be negative. But today I noticed this situation in my code: void CreateRequestHeader( unsigned bitsAvailable, unsigned mandatoryDataSize, unsigned optionalDataSize ) { If ( bitsAvailable – mandatoryDataSize >= optionalDataSize ) { // Optional data fits, so add it to...

Why is "else" rarely used after "if x then return"?

This method: boolean containsSmiley(String s) { if (s == null) { return false; } else { return s.contains(":)"); } } can equivalently be written: boolean containsSmiley(String s) { if (s == null) { return false; } return s.contains(":)"); } In my experience, the second form is se...

Has any "big name entity" published C++0x syntax best practices

Although this "conversation" could quickly degenerate into something like "this is how I think ..." the question is not. Has any "big name entity" (e.g., google or the likes, Scott Meyers or the likes, etc.) published anything freely available which dictates/suggests what they feel the syntax guides lines for their code base should be f...

Checkstyle equivalent for JSPs?

Is there any tool to do for JSP files what checkstyle does for Java files? The ideal would be to include JSP checking on checkstyle, but as far as I can see, this isn't possible. I would like for example to check JSP files for : Indentation style Right placements of certain constructs Tab / space check Check for use of scriplets Tha...

Code style preferences using Sicstus and Eclipse (Spider)

Hi all, i I am currently using Sicstus Prolog VC9 4.1.1 within Eclipse Galileo (Spider). I have got a very newbie question: how can I automatically control indentation and in general code style preferences? Thanks, I. ...

Reformatting HTML

I'm not a developer so I don't know the right term for this. I am dealing with code done by other and it is coded in a continuous way. Meaning not like this, <body> <ul> <li>List 1</li> <li>List 2</li> <li>List 3</li> </ul> </body> but instead, like this, continuously: <body><ul><li>List 1</li><li>List 2</l...

Why do some experienced programmers write expressions this way?

Possible Duplicates: How to check for equals? (0 == i) or (i == 0) Why does one often see null != variable instead of variable != null in C#? I've been having a look at an odd tutorial here and there as well as some DirectX code and noticed that many experienced C++ programmers write expressions in the following way: (<cons...