Questions tagged [idioms]
38 questions
43
votes
7 answers
What is idiomatic?
I understand an "idiom" to be a common operation or pattern that in a particular language is not simplified by core language syntax, such as integer increment:
i = i + 1;
In C++, this idiom is simplified by an operator:
++i;
However, when someone…

void.pointer
- 4,983
- 8
- 30
- 40
41
votes
10 answers
Difference between Idiom and Design Pattern?
What is the difference between idiom and design-pattern? It seems that these terminologies overlap somewhere; where exactly, I don't know. Are they interchangeable? When should I use what?
Here is a list of C++ Idioms. Can I call them design…

Nawaz
- 1,515
- 1
- 12
- 22
31
votes
3 answers
What does 'opinionated software' really mean?
I've seen a lot of other framework/library developers throw the phrase 'we write opinionated software' around, but in practical terms, what does that really mean? Does it mean that the author of the 'Opinionated Framework X' says that because they…

plaureano
- 1,231
- 1
- 11
- 13
23
votes
3 answers
Is the purpose behind code being 'idiomatic' to reduce cognitive overhead?
I'm trying to explain to someone that the way they've written the code makes it hard to understand, and if you refactor it then it's easier to read. This style of code I'm driving at is commonly called 'idiomatic' code'.
But the phrase idiomatic…

hawkeye
- 4,819
- 3
- 24
- 35
17
votes
6 answers
Representing business rules with exceptions
I know it is expensive but (IMO) I believe it is a very good practice. I'm talking about rules like say, you can't save an Invoice if you are not a sales person... so in that case throwing an exception saying 'your are not authorized' or…

sebagomez
- 432
- 4
- 11
12
votes
5 answers
What problems can arise from emulating concepts from another languages?
I've read many times on the web that if your language doesn't support some concept, for example, object orientation, or maybe function calls, and it's considered a good practice in this other context, you should do it.
The only problem I can see now…

Julio Rodrigues
- 940
- 2
- 9
- 19
9
votes
4 answers
C++ Iterator lifetime and detecting invalidation
Based on what's considered idiomatic in C++11:
should an iterator into a custom container survive the container itself being destroyed?
should it be possible to detect when an iterator becomes invalidated?
are the above conditional on "debug…

DK.
- 228
- 1
- 3
- 7
8
votes
3 answers
Idiomaticy of macros in C++
Macros are considered a good thing by one and evil by another.
Is there a rule of thumb when to and when not to use macros in C++?
When are macros idiomatic and when should they be avoided?

Mast
- 201
- 2
- 12
7
votes
2 answers
Pros and cons of branching when fixing old code
Sometimes I discover that a commit I made two months ago had a bug. So I write a fix for the bug, but then I must choose one these ways of committing it:
I can commit the fix directly onto the main up-to-date branch (the trunk).
I can use a branch…

joeytwiddle
- 265
- 1
- 4
7
votes
6 answers
Coding style for chained function calls
A common thing you need to do is to take a value, do something with it by passing it to a function, and then do some more with the return value, in a chain. Whenever I run into this type of scenario, I get unsure about how best to write the code.
As…

last-child
- 189
- 1
- 6
7
votes
5 answers
Filesystem like permissions for C++ type-members
Abstract (tl;dr)
Please read the full question, this is awfully simplified:
How can unix file permission style restrictions be applied to inter-type data/control flows, allowing fine-grained access to some class-members for some groups of…

bitmask
- 879
- 2
- 8
- 19
6
votes
3 answers
When we say "sanity" when referring to user input, are we talking about the cleanliness of the input or whether or not it is sane?
I often hear people say they "sanitize input," which would mean make it clean. I understand this to mean "clean of potentially damaging contents," where the function that does the sanitizing would do something like character escaping.
But then I…

Carson Myers
- 2,480
- 3
- 24
- 25
6
votes
4 answers
How does one learn to program (and think) the Ruby way?
Why I Ask this Question:
I've just starting to learn Ruby (and by extension IronRuby since I work in the Microsoft world). I picked up IronRuby Unleased to teach me the basic syntax of Ruby, and any particulars of IronRuby. However, learning the…

Matt
- 1,052
- 9
- 14
6
votes
4 answers
RAII Idiom Extension Suggestions
RAII is by far the most useful idiom in c++. However there seem to be two common pitfalls associated with it that I believe need to be formally addressed.
Failure to release a resource in the destructor and resource invalidation prior to…

Aaron Albers
- 69
- 3
5
votes
4 answers
Why do software engineers refer to computers as "machines"
Since entering software engineering, I picked up the habit of saying "machine" when talking about a computer. Most of my colleagues seem to do the same. However, when I use this idiom in everyday conversation, people get a bit confused.
Obviously, a…

azani
- 159
- 1
- 3