Do you think a software company should impose developers a coding-style?
If you think it shouldn't, explain why. If yes, how deep should the guidelines be in your opinion? For example, indentation of code should be included? ...
If you think it shouldn't, explain why. If yes, how deep should the guidelines be in your opinion? For example, indentation of code should be included? ...
The following have been proposed for an upcoming C++ project. C++ Coding Standards, by Sutter and Alexandrescu JSF Air Vehicle C++ coding standards The Elements of C++ Style Effective C++ 3rd Edition, by Scott Meyers Are there other choices? Or is the list above what be should used on a C++ project? Some related links http://stac...
One of my nasty (?) programming habits in C++ and Java is to always precede calls or accesses to members with a this. For example: this.process(this.event). A few of my students commented on this, and I'm wondering if I am teaching bad habits. My rationale is: 1) Makes code more readable — Easier to distinguish fields from local variab...
Okay, we know that the following two lines are equivalent - (0 == i) (i == 0) Also, the first method was encouraged in the past because that would have allowed the compiler to give an error message if you accidentally used '=' instead of '=='. My question is - in today's generation of pretty slick IDE's and intelligent compilers, d...
Any code I've seen that uses Regexes tends to use them as a black box: Put in string Magic Regex Get out string This doesn't seem a particularly good idea to use in production code, as even a small change can often result in a completely different regex. Apart from cases where the standard is permanent and unchanging, are regexes th...
Which of theese two alternatives do you find yourself using most often, and which is more "idiomatic"? f arg (obj.DoStuff()) f arg <| obj.DoStuff() ...
What is the ideal code to logging ratio? I'm not used to writing logs as most of the applications I've developed have not had much logging. Recently though I've changed job, and I've noticed that you can't see the application code for the calls to log4net. I appreciate that this is useful but surely having too many debug statements is j...
I'm wondering how (un)common it is to encapsulate an algorithm into a class? More concretely, instead of having a number of separate functions that forward common parameters between each other: void f(int common1, int param1, int *out1); void g(int common1, int common2, int param1, int *out2) { f(common1, param1, ..); } to encapsula...
I was inspired to ask this here based on this blog post. Do you always try to use nouns for class names? ...
Are there any projects that help to show that two code beautification tools are configured to produce identical results? For example, suppose that a project has mandated a particular coding style. Further suppose that the developers of this project are free to use whatever development environment they feel makes them most productive. Th...
I wrote a small web app using ruby on rails, its main purpose is to upload, store, and display results from xml(files can be up to several MB) files. After running for about 2 months I noticed that the mongrel process was using about 4GB of memory. I did some research on debugging ruby memory leaks and could not find much. So I have tw...
Should methods in a Java interface be declared with or without a public access modifier? Technically it doesn't matter of course. A class method that implements an interface is always public. But what is a better convention? Java itself is not consequent in this. See for instance Collection vs. Comparable or Future vs. ScriptEngine. ...
I noticed some code of a colleague today that initialized class variables in the initialization. However it was causing a warning, he says because of the order they are in. My question is why is it better to do variable initialization where it currently is and not within the curly brackets? DiagramScene::DiagramScene( int slideNo, QRe...
Quite often in ANSI C code I can see parenthesis sorrounding a single return value. Like this:- int foo(int x) { if (x) return (-1); else return (0); } Why use () around the return value in those cases? Any ideas? I can see no reason for that. ...
This is a minor style question, but every bit of readability you add to your code counts. So if you've got: if (condition) then { // do stuff } else { // do other stuff } How do you decide if it's better like that, or like this: if (!condition) then { // do other stuff { else { // do stuff } My he...
After maintaining lots of code littered with #region (in both C# and VB.NET), it seems to me that this construct is just a bunch of "make work" for the programmer. It's work to PUT the dang things into the code, and then they make searching and reading code very annoying. What are the benefits? Why do coders go to the extra trouble to p...
I have seen a few mentions of this idiom (including on SO): // Deliberately empty subscriber public event EventHandler AskQuestion = delegate {}; The upside is clear - it avoids the need to check for null before raising the event. However, I am keen to understand if there are any downsides. For example, is it something that is in wi...
Do you subscribe to this school of thought? Assertion: "I always return an Enum, Array, or an Iterator, never a Boolean, NULL, or an Instance." Reasoning: Code using Enums instead of Booleans. Return Empty Arrays instead of nulls, and return an Iterator even if the calling Method will only take the first value; instead o...
When structuring a visual studio solution I tend to structure it so that various components are in different project (As I would assume most people do) I tend to have a bunch of User defined exceptions. The Question is should these exceptions be in a separate project to the (for example) Model classes? I tend to put them in a sub-names...
Hello, I've got a question concerning fields in databases wich are measures that might be displayed in different units but are stored only in one, such as "height", for example. Where should the "pattern unit" be stated?. Of course, in the documentation, etc... But we all know nobody reads the documentation and that self-docummented th...