Are there any advantages of std::for_eachover for loop? To me, std::for_each only seems to hinder the readability of code. Why do then some coding standards recommend its use?
Perhaps by compiling a list of common errors or coding style differences PHP coders make when first starting out with Python, we can help to avoid headaches later on. (Or at least I can :).
Hi.
Is there a way to run the changed files through a filter before doing the commit? I wish to make sure the files follows the coding standards for the project.
I would also like to compile and run some test before the commit/push actually takes place, so I know everything in the repo actually works.
When I code, I always write little pieces of unit, and compile it often. This helps me to make sure that everything run correctly, but it's very time consumed. is there any programming language that can support us to do coding and running at the same time side by side ? i mean as soon as a key press leads to valid code, the effect of the edit is…
hello a friend of mind ask something about php editor for his companion on coding.
PHP Editor that able to trace dependency of all function in a file with models/controllers or another part of a framework (or something we had code).
Basicly we use notepad++ but seeking another alternative.
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 two…
Hey all,
A short while ago, I'm fairly certain I came across an application (or perhaps a plugin for Coda - the IDE I use) which quickly parses a html document and then spits out all of the elements with IDs and Classes for me to use in a CSS file.
Having fully 'got into' zen coding - using the wonderful TEA plugin for Coda, I'm now hot…
I'm working with websites written in PHP, along with many other programmers, and sometimes I have to deal with really awful code.
Indentation totally messed up, curly braces in the wrong places, terrible whitespace use, it really hurts my eyes and actually makes my work harder and take longer.
Is there a tool where you can specify your…
I have an MVC application. The model has a property that is a struct NSSize. It is writable like this:
- (void)setSize:(NSSize)aSize;
The view sets this NSSize using key-value-coding. However, you can not key-value-code a struct, so I wrapped it in an NSValue-object like this:
[theView setValue:[NSValue valueWithSize:mySize]
…
In emacs, it is possible to start a file off with a line this:
/* -*- mode: java; c-basic-offset: 4; indent-tabs-mode: nil -*- */
This instructs emacs to use 4 spaces for indentation. I like the idea of storing this coding style meta-information directly and explicitly in the source code. Are there any options for doing this in…
I was wondering what style others' use when writing conditional statements that include boolean types. Currently I'm caught between using two styles.
bool foo;
if (foo == true)
if (foo)
if (foo == false)
if (!foo)
Obviously the first set is a bit more obvious. However, when combining conditions it could get a bit clunky.
if…
Recently switched to Textmate on Mac for coding. On PC when ever I want to tab in or out a block of code I just highlight and press tab or shift+tab to move it in our out. It's very useful when you are adding an extra loop or conditional statement to a block of code to keep everything tidy and neatly indented.
On Textmate…
I was developing for quite long time already on C/C++ (mostly C, which makes style poorer). So, I know how to use it. However, quite often I stuck with style decisions like:
- should I return error code here, throw exceptions, return error through a parameter
- should I have all this stuff in constructor or should I create…
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 : {}; //…
I have been doing programming from last 7 years, getting better and better, but still i think that am lacking something.
I have been doing work in JOOMLA, MAGENTO, WP, Custom PHP, Opencart, laravel, codeignitor.
Sometimes i need to design logic for a huge database application, in the applications we need nesting…
In python you may have a function definition:
def info(object, spacing=10, collapse=1)
which could be called in any of the following ways:
info(odbchelper)
info(odbchelper, 12)
info(odbchelper, collapse=0)
info(spacing=15, object=odbchelper)
thanks to python's…
I was wondering what was the most clean and understandable syntax for doing condition checks on nullable bools.
Is the following good or bad coding style? Is there a way to express the condition better/more cleanly?
bool? nullableBool = true;
if (nullableBool ?? false) { ... }
else { ... }
especially the…
Something that has been troubling me for a while:
The current wisdom is that types should be kept in a namespace that only
contains functions which are part of the type's non-member interface (see C++ Coding Standards Sutter and Alexandrescu or here) to prevent ADL pulling in unrelated definitions.
Does…
I have done a fair amount of programming together with mathematicians. Now I am even teaching some high school kids coming from a mathematics background how to program. Most of these people format their code so hideously it's hard to believe. I've even worked with and taught mathematicians who will fight…
I was speaking to an experienced lecturer recently who told me he could usually tell which programming language a student had learnt to program in by looking at their coding style (more specifically, when programming in other languages to the one which they were most comfortable with). He said that there…
I've tried to be descriptive :) It's rather programming-style problem than coding problem in itself.
Let's suppose we have :
A:
public class MyDict {
public Dictionary<int,string> dict;
// do custom-serialization of "dict"
public void SaveToFile(...);
// customized…
I've noticed that I usually use constant references as return values or arguments. I think the reason is that it works almost the same as using non-reference in the code. But it definitely takes more space and function declarations become longer. I'm OK with such code but I think some people my…
Suppose I have two .h files: A.h and B.h.
Moreover, A.h includes B.h itself:
B.h - declares class B.
class B {
...
};
A.h - declares class A, which uses class B.
#include B.h
class A {
void SomeFunction(const B& b);
};
Now, I have some .cpp file, that uses both A and B classes…
So yes, the problem has been raised in parts multiple times already. Still I'm looking for a keyboard layout that has the following features:
Easy on fingers (Dvorak-like layouts welcome)
Easy for coding
Includes german characters (typing ä with AltGr-p is not ok).
Works well with…
I'm toying with starting an occasional blog for posting odd bits of coding related stuff (mainly C++, probably).
Are there any platforms which can be recommended as providing exceptionally good support (e.g syntax highlighting) for posting snippets of code ? (Or any to avoid…