Which typo is hardest to catch or debug?
Hi everyone, This is a general question. I wanted to know from your experience which typos are the hardest to find or debug in your code. A back story would be nice :) Thanks! ...
Hi everyone, This is a general question. I wanted to know from your experience which typos are the hardest to find or debug in your code. A back story would be nice :) Thanks! ...
I hesitate between using the name of the current setter versus using a common name (such as $value) for all setters. // Style 1 function set_section($section); // Style 2 function set_section($value); ...
Is there a code analyzing utility that can do things like calculate the average variable length in a script or in a bunch of scripts? I'm obsessed with the linguistic aspect of programming. I'd be curious to see how different frameworks or CMSs compare in that aspect. ...
It has been a while since I've written C, and I never really did any formatting when I did it since it was all toy work and inconsequential. For open source C projects, what would be the best (being the most agreed upon and utilized) style guide (Formatting and convention wise) to follow? ...
Hi guys, Do you know of a good style guide about coding? Particularly about how to comment code? In the last years I've seen the way you code and the naming conventions you use are very influenced by the language you use. Is that applicable for comments? I know there's not a unique way of doing things and, after all, comments are igno...
In theory it seems that books sugest declaring ADT in C as: struct some_structure; typedef some_structure *some_structure_t; while most code uses: struct some_structure; typedef some_structure some_structure_t; I know that const is not working with the first style. Is this the only reason for real libraries not to use first approac...
When coding python, I use the logging module a lot. After some bad experiences and reading articles like this one, I try to prevent import-time executed code wherever possible. However, for the sake of simplicity, I tend to get my logging object right at the beginning of the module file: # -*- coding: utf-8 -*- import logging logger =...
During a code review I performed today for my colleague, I noticed a function that was defined as returning a boolean value, but in practice it returned only true. In a case of failure, this function threw an exception. I pointed it out and advised to change the return value to void (the code is written in C++). I had no doubt that this ...
Suppose circumstances cause you to be transferred to a new team of programmers. This can happen for example because you are assigned to a new project within the same company, or after changing jobs. After a while you begin to realize that your new team members have very bad programming habits: there code contains a lot of duplication, is...
Hi, people. I study Obj-C and Cocoa now, and I was wondering: why everybody writes method definitions/implementations like this: - (void)translateOriginToPoint:(NSPoint)newOrigin{ - all together, no spaces. For me, it's way more clean to write everything with spaced like this: - (void) translateOriginToPoint: (NSPoint) newOrigin { ...
Which is the better convention of declaring pointers in C++? MyClass* ptr (or) MyClass *ptr I find the first one meaningful, because i feel like declaring MyClass pointer rather than a MyClass and specifying a type modifier. But i see a lot of books recommending the later convention. Can you give the rational behind the convention...
Let's say you have a piece of code where you have a for-loop, followed by another for-loop and so on... now, which one is preferable Give every counter variable the same name: for (int i = 0; i < someBound; i++) { doSomething(); } for (int i = 0; i < anotherBound; i++) { doSomethingElse(); } Give them different names: for ...
Hello, First off, I know this may be a very stupid question, so don't shoot me for asking it. I come from C++ background, and I love C++ to death, but now that I've been using C# for a while, I've grown to love C#. BUT, I miss the coding style of C++ and sometimes wish I could go back, but C# is just so time-saving now compared to C++ ...
Hi, I have started to do some programming using VIM. I have very mixed feelings so far. On one side I do love the idea, on the other - it is just hard to remember everything. So I took the approach of learning while actually doing some stuff (for Ruby on rails development). Unfortunately there is no chance in hell for me to be more pro...
My goal is to create a thick client to the database. Basically it is all about managing three lists of data. I would like to slice my application into decoupled layers so using Qt's Model/View framework seems natural to me. When should I create QSql*Model instances? I need to be able to connect/disconnect to/from the database severa...
If I want to iterate n times in Java, I write: for (i = 0; i < n; i++) { // do stuff } In Python, it seems the standard way to do this is: for x in range(n): # do stuff As always, Python is more concise and more readable. But the x bothers me, as it is unnecessary, and PyDev generates a warning, since x is never used. Is ...
Is there any reason to prefer one of the following notations over the others or is this simply a matter of preference? map toLower "FOO" fmap toLower "FOO" toLower <$> "FOO" As an aside: I realize that <$> is the same as `fmap`. Am I right in the assumption that map is just a less general form of fmap? ...
Possible Duplicates: Code polisher / reformater for C, C++ or Fortran Best C++ Code Formatter/Beautifier I am working as part of a team on a C++ project. Part of the code is a highly modified version of a large-ish external library, which doesn't conform to our coding conventions. The library uses this style: void main () ...
I've heard bad things about overusing regions but when adding enums to my classes I put them into a #region "Enums" at the end of the class, and do the same with structures and even subclasses. Is there a better/standard way to go about grouping such elements on classes? (Note: this is tagged C#/VB but maybe the same situation exists f...
We have a team of 40+ engineers working on a common code base. We're using resharper, and have been sharing our suggested settings by having a 'definitive' configuration file emailed out which people can import. However, as time goes on we wish to tighten up on various things on new versions and new work, without requiring refactoring o...