coding-standards

Should I expect programming teams to follow a strict coding standard?

I am personally a very big fan of following internal coding standards when working with a group of developers. I feel like it brings continuity to the code and allows people to more easily expand the code base, switch off work, and assist each other with difficult tasks. On the other hand I am aware that a large set of people are of the...

is there a reason why variable names should be camelCased in the PHP coding standard?

The PHP (PEAR, Zend, etc) coding standard specifies that class names should be in upper CamelCase, while methods and variables (associative arrays keys probably as well) should be in lower camelCase format. The rationale for having classes in CamelCase and underscores is to emulates namespaces and create a parallel with file location, bu...

How much duplicated code do you tolerate?

In a recent code review I spotted a few lines of duplicated logic in a class (less than 15 lines). When I suggested that the author refactor the code, he argued that the code is simpler to understand that way. After reading the code again, I have to agree extracting the duplicated logic would hurt readability a little. I know DRY is gu...

Methods which wrap a single method.

I think I'm going mad, someone please reassure me. public class MyFile { public static byte[] ReadBinaryFile(string fileName) { return File.ReadAllBytes(fileName); } public static void WriteBinaryFile(string fileName, byte[] fileContents) { File.WriteAllBytes(fileName, fileContents); } } Peo...

PHP: Printing HTML-Friendly Code?

Hi All, I am wondering if there is any technique out there for making HTML code look good when printing that HTML (multiple lines) from a PHP function? In particular, new lines and tabs. Obviously, I want the HTML tags behind-the-scenes to look good with the proper new lines and tabs. However, depending on when I call the PHP function...

Is it reasonable to enforce that unit tests should never talk to a live database/webservice?

My team continues to find more and more value in the unit tests we write. We don't generally unit test the data access layers of our applications, as they don't contain "logic". In my experience we've run into significant performance issues and non-reproducible errors as a result of letting developers write unit tests that talk to live d...

PHP Zend Framework coding standard, which is the more readable approach?

This is an subjective question, I need your feels and thoughts about coding standards, and formatting practices. PHP Zend coding standard requires to write multiline function calls like this: $returnedValue = $object->longMethodName( $argument1, $otherArgument, 42 ); I think the following approach is more readable: $retu...

How to find a list of hungarian notation prefixes?

I know that there is so many standards for writing code. and some policy tools (like FxCop) to check your writing statements. What's the best hungarian notation or any other snippets for writing codes? Like: lbl in start of naming a Label txt in start of naming a TextBox , etc. Update : So based on the answers, Is it a good Idea...

Coding style - keep parentheses on the same line or new line?

Suppose you are calling a function, where there's clearly a need to break down the statement into few lines, for readability's sake. However there are at least two way to do it: Would you do this: return render(request, template, { 'var1' : value1, 'var2' : value2, 'var3' : ...

What is the preferred way to write boolean expressions in Java

I have always written my boolean expressions like this: if (!isValid) { // code } But my new employer insists on the following style: if (false == isValid) { // code } Is one style preferred, or standard? ...

Should I focus on code quality while Rapid prototyping ?

When you are rapid prototyping for features should you really worry about code quality & optimization?. ...

Checkstyle for C#?

I'm looking to find something along the lines of Checkstyle for Visual Studio. I've recently started a new gig doing .NET work and realized that coding standards here are a bit lacking. While I'm still a young guy and far from the most experienced developer I'm trying to lead by example and get things going in the right direction. I l...

iPhone/Cocoa Coding Standards

Are there any generally-accepted coding standards (naming, casting etc) that apply specifically to iPhone/Cocoa/Objective-C? I know Microsoft has published similar standards as they relate to .Net and C# but haven't run across anything related to the iPhone world. ...

What human learning techniques can be applied to improve code layout?

Is it possible to use the results of studies made into human learning in order to identify how code might be laid out to improve comprehension? Code layout wars almost always end up defending consistency and the prevailing style, but could there be ways of laying out code that are provably better than others? ...

Should I use fork or threads?

In my script, I have a function foo which basically uses pynotify to notify user about something repeatedly after a time interval say 15 minutes. def foo: while True: """Does something""" time.sleep(900) My main script has to interact with user & does all other things so I just cant call the foo() function. direct...

How to properly document programming languages?

Where can I find information on how to properly document a programming language? What I mean is that there seems to be a standard way to document code. php.net and api.jquery.com seem to document there code the a similar way. For example, the trim() description on php.net. string trim ( string $str [, string $charlist ] ) And lik...

How to make your more experienced and authoritative teammates not to create 'fast temporary solutions'?

I'm currently working on a small short-lived project. But despite the size it's complicated enough with very unclear logic. That's why it was started by more experienced developers. They work on it from time to time because it's not their main project. They made some code drafts with numerous places which 'would be rewritten in the nea...

objective c coding guidelines

Is there any pdf which tells about coding guidelines in objective C. For Example... 1. Breaking the function names - checkIfHitTheTrack. 2. member variables must be like - mVariableName. 3. Giving better names to subclass - ? Please share the related links... ...

Should every class have its own namespace?

Something that has been troubling me for a while: The current wisdom is that types should be kept in a namespace that only contains functions which are part of the type's non-member interface (see C++ Coding Standards Sutter and Alexandrescu or here) to prevent ADL pulling in unrelated definitions. Does this imply that all classes must...

What are the characteristics of spaghetti code?

Somebody said that when your PHP Code and application use global variable then it must be a spaghetti code (i assume this). I use wordpress a lot. As far as i know, it's the best thing near a great php software. And it use many global variables to interact between its components. but forget about that, cause frankly, that's the only th...