I am using Eclipse IDE for C/C++ Developer- Build id: 20090920-1017
We know that eclipse for C++ has built-in 'coding aids' for C/C++ developers:
1) Code completion -
Automatically complete/fill method names or fields names of a class or structure.
Automatically populate class structures, for loops et al
2)Templates
You can create and...
There seem to be many different ways of organizing methods in a class. I could group methods by access, and order them alphabetically. I could group related methods together. I could use a mix of the two, or something else entirely. Is there a standard way to approach this? If not, how do you approach it?
...
I've developed a natural aversion to long parameter lists in functions. While this is to some extent a good thing, sometimes long parameter lists are the lesser of two evils compared to code duplication or ridiculously long functions due to "manual inlining". What's a good way to at least make some of these monstrosities human-readable...
Should I seal all classes I know shouldn't ever be used as a base class even when there are no tangible performance or security concerns, or is this just adding cruft?
...
I'm fairly new to C#, and I think properties are a wonderful thing. So wonderful, in fact, that I can't see any real advantage to using fields, instead. Even for private fields, it seems like the flexibility and modularity that properties offer can at best save you serious headaches, and at worst have no effect at all.
The only advantag...
I am almost obsessed with perfect indentation and alignment when writing code, but for some reason I don't feel comfortable indenting HTML markup. Maybe because some times the level of indentation gets too deep, but I usually just (ab)use VIM's folding feature. Is this considered bad practice? What's your style with markup indentation?
...
hey there
Maybe this isn't the right place to ask, but I was wondering if there is any advice on how to start fixing an old-fashioned-style php script.
A few days ago I received an offer for developing an old PHP project, and by old-fashioned I mean the structure did not use OOP coding method and it doesn't have a definite framework...
I've often seen it argued that heavily nested function calls should not be used because they are unreadable. However, using temporary variables instead creates a lot of unnecessary verbosity and forces the reader to mentally link each temporary variable to what it represents. When looking at the way Lisp code is typically formatted, it...
I often find myself using inline initialization (see example below), especially in a switch statement when I don't know which case loop will hit. I find it easier to read than if statements.
But is this good practice or will it incur side-effects or a performance hit?
for (var i in array) {
var o = o ? o : {}; // init object if it...
I am a beginner in Rails. I use 2.3.X.
I just saw Rails 3 is pre-released [edit: now in release candidate!]. I will most probably eventually switch to it.
What are the common coding habits in 2.3 I should not take, so that the switch is as smooth as possible ?
Edit:
I've done my homework and read the Release notes. But they are far f...
What are the best practices and recommendations for using explicit del statement in python? I understand that it is used to remove attributes or dictionary/list elements and so on, but sometimes I see it used on local variables in code like this:
def action(x):
result = None
something = produce_something(x)
if something:
...
Is there an accepted best practice for commenting functions? I only know of the doxygen style but it is not officially supported by C++ like Javadocs is for Java so just wondering what is best.
...
Hello, I'm writing an IRCd. For this topic it doesn't really matter if you know much about IRC. Its a simple code style problem.
Quick overview of the problem:
No message may be longer than 512 characters
If the message is more, it must be broken into pieces
The NAMES reply sends all the nicknames of users on a channel, and quickly gr...
I have a class that needs access to urllib2, the trivial example for me is:
class foo(object):
myStringHTML = urllib2.urlopen("http://www.google.com").read()
How should I structure my code to include urllib2? In general, I want to store foo in a utility module with a number of other classes, and be able to import foo by itself fr...
I've seen some guides or blogs that say using this to access a class's own members is bad. However, I've also seen some places where professionals are accessing with this. I tend to prefer explicitly using this, since it seems to make it clear that the thing I'm accessing is part of the class.
this.MyProperty = this.GetSomeValue();
Is...
Why do Lispers format their code like shown in sample 1 instead of as shown in sample 2? To me (and I guess, to most others coming from different programming backgrounds than Lisp), the formatting shown in sample 2 would be easier to read. Is there any particular reason why Lispers prefer the sample 1 style?
Sample 1
(defun factorial ...
I have a question about Java style. I've been programming Java for years, but primarily for my own purposes, where I didn't have to worry much about style, but I've just not got a job where I have to use it professionally. I'm asking because I'm about to have people really go over my code for the first time and I want to look like I kn...
I've never really been a big fan of the way most editors handle namespaces. They always force you to add an extra pointless level of indentation.
For instance, I have a lot of code in a page that I would much rather prefer formatted as
namespace mycode{
class myclass{
void function(){
foo();
}
void foo(){
bar();
}
v...
I prefer to use local variables rather than multiple calls to the same method.
/*
* I prefer this
*/
Vehicle vehicle = person.getVehicle()
if (vehicle instanceof Car) {
Car car = (Car) vehicle;
car.openSunroof();
} else if (vehicle instanceof Bike) {
Bike bike = (Bike) vehicle;
bike.foldKickstand();
}
/*
* Rather than t...
Given that multiple return statements are acceptable (I disagree, but let us digress), I'm looking for a more acceptable way to achieve the following behavior:
Option A: multiple returns, repeated code block
public bool myMethod() {
/* ... code ... */
if(thisCondition) {
/* ... code that must run at end of method ... *...