coding-style

Integrate StyleCop in NAnt buildscript

Is there a way to integrate StyleCop in a NAnt script such that the build fails if there are too many style violations? There doesn't seem to be a NAnt task for StyleCop, but we've found StyleCopCmd. However this only seems to generate an XML file as output that we'd have to parse. Is there some easier solution? ...

What are basic programs like, recursion, Fibonacci, small trick programs?

This question may seem daft (I'm a new to 'programming' and should probably stop if this is the type of question I'm required to ask)... What are: "basic programs like, recursion, fibonacci, factorial, string manipulation, small trick programs"? I've recently read Coding Horror - the non programmer and followed the links to Kege...

Is concatenating with an empty string to do a string conversion really that bad?

Let's say I have two char variables, and later on I want to concatenate them into a string. This is how I would do it: char c1, c2; // ... String s = "" + c1 + c2; I've seen people who say that the "" + "trick" is "ugly", etc, and that you should use String.valueOf or Character.toString instead. I prefer this construct because: I p...

CSS style guide question

What are the best practices with respect to styling HTML elements using CSS? What's the preferred granularity for styling HTML elements? i.e., do you have lots of div.searchbox input div.searchbox p div.searchbox p.help OR input.searchbox p.searchbox p.searchboxhelp Which css code is considered easy to maintain? Is using grid ...

Are there any reasons to make all fields and variables final?

In my current project I noticed that all class fields and variable inside methods are declared with final modifier whenever it's possible. Just like here: private final XMLStreamWriter _xmlStreamWriter; private final Marshaller _marshaller; private final OutputStream _documentStream; private final OutputStream _stylesStream; private ...

Adding the sum of numbers using a loop statement

I need serious help dividing the positive numbers and the negative numbers. I am to accumulate the total of the negative values and separately accumulate the total of the positive values. After the loop, you are then to display the sum of the negative values and the sum of the positive values. The data is suppose to look like this: ...

Is there a software that can automatically create possible css rules from an html file?

Hello, I know that StyleMaster has this feature, but is there any free sofware that has it? Thanks) ...

Javascript: Inline function vs predefined functions

Can any body throw me some arguments for using inline functions against passing predefined function name to some handler. I.e. which is better: (function(){ setTimeout(function(){ /*some code here*/ }, 5); })(); versus (function(){ function invokeMe() { /*code*/ } setTimeout(invokeMe, 5); })(); Strange question, but w...

Could someone tell me if my C++ indent style is named? (example given)

I'm learning C++. For me, my programming style is just what looks the best; it doesn't seem to follow the rules of any one particular style. Here's an example void f(int x){ //no space between close-paren and bracket if (!x){ cout << "x is non-zero\n"; } //closing bracket indented to the same level as the original statem...

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... ...

Coding styles for html

Is there a coding standard for HTML? Please suggest links that have the coding styles for HTML. For example: <table> <tr> <td> Data </td> </tr> </table> ...

Combining multiple attributes in C#

Is there a functional difference between the following syntax... [Foo, Bar] public class Baz {} ...and this syntax? [Foo] [Bar] public class Baz {} Assuming each produces identical results when compiled, which is the preferred form? ...

Best ways to construct Dynamic Search Conditions for Sql

I have always wondered what's the best way to achieve this task. In most web based applications you have to provide search options on many different criteria. Based on what criteria is chosen behind the scene you modify your SQL. Generally, this is how I tend to go about it:- Have a base SQL template. In the base template have conditi...

C# Setting Properties using Index

I have a business class that contains many properties for various stock-exchange price types. This is a sample of the class: public class Prices { public decimal Today {get; set;} public decimal OneDay {get; set;} public decimal SixDay {get; set;} public decimal TenDay {get; set;} public decimal TwelveDay {get; set;}...

is it bad to use initializer block

Hi I use initializer block in C# new Something { foo = 1, bar = 2 }; but people say this is bad practice. I don't think it is wrong, is it? ...

Is it bad programming style to have a single, maybe common, generic exception?

Hi, so in my program I have parts where I use try catch blocks like this try { DirectoryInfo dirInfo = new DirectoryInfo(someString); //I don't know if that directory exists //I don't know if that string is valid path string... it could be anything //Some operations here } catch(Exception iDontCareWhyItFailed) { //Didn't work? ...

A matter of style

Would you write something like: enum XYZ_TYPE {X=1, Y=2, Z=3}; I saw it and the suffix _TYPE confuses me in the enum context. There is a strong prospect that it is because I am not bright. ...

Tuple unpacking: dummy variable vs index

What is the usual/clearest way to write this in Python? value, _ = func_returning_a_tuple() or: value = func_returning_a_tuple()[0] ...

Revision histories and documenting changes

I work on legacy systems and I used to see revision history of files or functions being modified every release in the source code, for example: // // Rev. No Date Author Description // ------------------------------------------------------- // 1.0 2009/12/01 johnc <Some description> // 1.1 2009/12/24 daveb ...

How to create an Intellij and Eclipse compatible code style and code formatting configuration (for java code)?

Few weeks ago I tried Intellij and I found it really awesome. Now, at my project there's two programmers (including me) using Intellij and few other programmers gonna still be using Eclipse. Since this project is already very large and it gonna be growing a lot, we need to use compatible Code Style and Code Formatting between Intellij an...