coding-standards

Accessibility and code organization problems in javascript with jquery.

I'm having troubles with the order of my code in my program. right now I have some things with in document.ready(function() { } ); and some things out side of it. Whenever I move anything (to organize or improve my code) I end up breaking something, I'm guessing because of either order of declarations or access levels (ie. something outs...

Too many constants?

Is there such a thing as too many constants in a project? What are some general rules of thumb about where the use of constants starts to become inappropriate and should be refactored? Perhaps moving some of these values into a model tier, or configuration files, etc. A concrete example. Using the pureMVC framework for Actionscript/Flex...

C# standards/style for a Delphi developer?

After you've been programming for a long time with a language, you pick up certain coding standards or styles. With Delphi it's things like prefixing private variables with f and putting private declarations before protected, which in turn are before public ones etc etc. Most of this comes from the VCL. Is there any recognized coding st...

Coding Standards for pure C (not C++)

I come from a java background (from my CS classes) and a semester of C++. I am just finishing up a OpenCV project for my Co-Op that's in pure C, so I'm a bit late in asking this question. What are the design processes and coding standards for pure C? I'm familiar with object oriented programming, design and best practices. I'm jus...

How do you resolve traditional coding standard vs python idomatic code?

In my experience code clarity and readability are the primary concerns in traditional coding standards. PEP-8 would have been rejected by some of my previous customers. The idiomatic concepts such as, using dictionaries and lambda functions to emulate the behavior of a switch statement looks like something that would have clearly been f...

What's the best way to write code, allowing that any developer can easily understand it?

Normally each person takes their own "calligraphy" to write code, however, is there a "standard" or any way that you feel clear and easy to allow the code becomes "readable" by any programmer who is using your code? Personally I use (a simple example): if (myVar == 5) { // easy to identify where the IF was launched, IMHO. } Inste...

What should be the standard for private class constants in C#?

For those of you that use the underscore prefix for private class members in C# (i.e. private int _count;), what do you use for private constants? I'm thinking the following but am curious as to what others are doing. private const int _MaxCount; ...

What are the most commonly use web development policies in software companies?

Having the best forum website among developers, I think I will find a very good consensus of what policies and best practices make good coding. I will put some of them here, so I give the idea, but I will like to hear your opinion and the votes will probably be the judge of the best policies around. Specific Indentation for coding be...

Is there any advantage in writing a set of operations in a single line if all those operations have to occur anyway?

From a post-compilation perspective (rather than a coding syntax perspective), in C#, is there any actual difference in the compiled code between a set of operations that have occurred on one line to a set of operations that occur across multiple lines? This object anObject = new object(); anObject = this.FindName("rec"+keyPlayed.ToStr...

Haskell: -fglasgow-exts should one avoid code that requires this?

I am a beginner with Haskell and I've started seeing errors similar to: Illegal parallel list comprehension: use -fglasgow-exts I am working within ghci and with ghc but only due to the fact that it was the first one I found on a search. I'm curious if this is the type of situation one would want to avoid moving forward. Any searche...

C++ rely on implicit conversion to bool in conditions?

I found the following rule in a coding standards sheet : Do not rely on implicit conversion to bool in conditions. if (ptr) // wrong if (ptr != NULL) // ok How reasonable/usefull is this rule? How much overload on the compiled code? ...

Does identifier casing really matter?

FxCop thought me (basically, from memory) that functions, classes and properties should be written in MajorCamelCase, while private variables should be in minorCamelCase. I was talking about a reasonably popular project on IRC and quoted some code. One other guy, a fairly notorious troll who was also a half-op (gasp!) didn't seem to agr...

Standards for Web Programming

This is strictly an opinion/experience question for research purposes. I was wondering what coding standards companies have in place now for Web Developers? (Document formats, coding standards, file structures, etc.) Obviously they all can't be listed, but some major ones would give me an idea. ...

What are the uses of getter/setters in Java?

I have seen member variables given a private modifier and then using getter/setter methods just to set and get the values of the variable (in the name of standardization). Why not then make the variable public itself (Other than cases like spring framework which depends on getter/setters for IOC etc). It serves the purpose. In C# I hav...

Are there any widespread, modern Java coding conventions?

Sun's "Code Conventions for the Java Programming Language" was last updated April 1999. Ten years later a lot has changed in the language, as well as general usage patterns. Are there more up to date, widely adopted standards? Most guidelines omit specifying file encoding and line endings. Sun recommends mixed tabs and spaces. The E...

Should a collection of constants be placed in a class or interface?

If I have a collection of static constants that I want to declare centrally so that they can be shared among various projects should they be put in a class or interface (Java). In the past I have seen them mostly put in a class but I started thinking that since the class will not and should not be instantiated maybe they would be better...

Should I check if the 'disabled' attribute exists before removing it?

I had a requirement where I need to clear off the "select all" checkbox in case user manually deselects any of the data rows. This has been accomplished by detecting this during an onRowSelect (jqgrid event) event. The code snippet is as below and works as expected. onSelectRow: function(){$("input:checkbox[id='cb_jqg']").removeAttr('ch...

How to code in professional manner?

I was wondering, how a program can be written in a perfect professional style. Many times it happens that we write a very good program/code which gives the accurate output.One might use the best algorithm to solve the given problem. But for a person who is reading your code for his/her reference, it becomes difficult to unders...

standard Xhtml- div vs li.

Hi All, I need ur suggestion in the following scenario. Lets say I have an UI something like Col1 Col2 A D B E C F Now to get this right now in my HTML I am using ..like <div class="col1"> <div>A</div> <div>B</div> .......... </div> <div class="col2"> <div>D</div> <div>E</div> .......... </div> But here I am ...

Cross-Language coding standards?

I'm looking for advice as to coding conventions. The primary languages I use, in order of frequency are C#, JavaScript, and ActionScript. They are all ECMA-based languages, so for the most part, the syntax is interchangeable. What I would like to do is standardize the way I write code. I looked around for documents on coding standards a...