What guidelines do you follow to improve the general quality of your code? Many people have rules about how to write C++ code that (supposedly) make it harder to make mistakes. I've seen people insist that every if statement is followed by a brace block ({...}).
I'm interested in what guidelines other people follow, and the reasons behi...
C# and Java allow almost any character in class names, method names, local variables, etc.. Is it bad practice to use non-ASCII characters, testing the boundaries of poor editors and analysis tools and making it difficult for some people to read, or is American arrogance the only argument against?
...
I'm trying to implement a data compression idea I've had, and since I'm imagining running it against a large corpus of test data, I had thought to code it in C (I mostly have experience in scripting languages like Ruby and Tcl.)
Looking through the O'Reilly 'cow' books on C, I realize that I can't simply index the bits of a simple 'cha...
In my day job I, and others on my team write a lot of hardware models in Verilog-AMS, a language supported primarily by commercial vendors and a few opensource simulator projects.
One thing that would make supporting each others code more helpful would be a LINTER that would check our code for common problems and assist with enforcing a...
What factors determine which approach is more appropriate?
...
I have a class with a string property that's actually several strings joined with a separator.
I'm wondering if it is good form to have a proxy property like this:
public string ActualProperty
{
get { return actualProperty; }
set { actualProperty = value; }
}
public string[] IndividualStrings
{
get { return ActualProperty....
I believe strongly in using unit-tests as an approach to building large multi-platform applications. We currently are planning on having our unit-tests within a separate project. This has the benefit of keeping are code base clean. I think, however, that this would separate the test code from the implementation of the unit. What do you t...
I have here 300 lines long NAnt file and it is quite a messy. I am wondering if there is a any style guide for writing NAnt scripts and what are the best practices for doing so.
Any tips?
...
in the old days everything was 80 columns. so if you wanted your code to be readable, you'd make it fit. but that's not the case anymore with wider and wider screens, so how long of line is too long?
...
My first question on Stack Overflow... :-)
Someone told me about a C++ style difference in their team. I have my own viewpoint on the subject, but I would be interested by pros and cons coming from everyone.
So... In case you have a class property you want to expose via two getters, one read/write, and the other, readonly (i.e. there i...
I've been somewhat spoiled using Eclipse and java. I started using vim to do C coding in a linux environment, is there a way to have vim automatically do the proper spacing for blocks?
So after typing a { the next line will have 2 spaces indented in, and a return on that line will keep it at the same indentation, and a } will shift b...
I recently discovered that our company has a set of coding guidelines (hidden away in a document management system where no one can find it). It generally seems pretty sensible, and keeps away from the usual religious wars about where to put '{'s and whether to use hard tabs. However, it does suggest that "lines SHOULD NOT contain embedd...
What are the different kinds of indent style in use? Are there any objective differences? How do you determine the indent style for a whole development shop?
The indent style that I use is the so-called BSD KNF style or Kernel Normal Form. It's for me the most logical way of formatting my code. For instance:
//I also prefer one tab per...
The best way to learn is by practicing, but it's always good to learn from others who are smarter than you. What is the best example of a well-designed, well coded open-source project? I'm specifically interested in C++ projects, but other exceptional examples would be welcome, as well.
...
Seriously. On a 22" monitor, it only covers maybe a quarter of the screen. I need some ammo to axe down this rule.
Edit: I'm not saying that there shouldn't be a limit; I'm just saying, 80 characters is very small.
...
No doubt, it's essential for understanding code to give member variables a prefix so that they can easily be distinguished from "normal" variables.
But what kind of prefix do you use?
I have been working on projects where we used m_ as prefix, on other projects we used an underscore only (which I personally don't like, because an under...
For example:
root.Nodes.Add(new TNode() { Foo1 = bar1, Foo2 = bar2, Foo3 = bar3 });
or:
root.Nodes.Add(new TNode() { Foo1 = bar1,
Foo2 = bar2,
Foo3 = bar3 });
...
OK, so I know what a code smell is, and the Wikipedia Article is pretty clear in its definition:
In computer programming, code smell is
any symptom in the source code of a
computer program that indicates
something may be wrong. It generally
indicates that the code should be
refactored or the overall design
should be reexa...
experimenting with Cockburn use cases in code
I was writing some complicated UI code. I decided to employ Cockburn use cases with fish,kite,and sea levels (discussed by Martin Fowler in his book 'UML Distilled'). I wrapped Cockburn use cases in static C# objects so that I could test logical conditions against static constants which r...
I believe there is, but I can't put the right words to it...bear with me
I have worked with a lot of developers and I think there is basically a few personalities and they will produce very different things.
Cowboy - a loner, often good but hard to get on track
Follower - lacks ideas
Anarchist - NIHS
Orthodox - doing ev...