Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [idioms]

The tag has no usage guidance.

1
vote
0answers
101 views

When should I take idioms across languages? [closed]

I use multiple programming languages, and I generally keep each language's idioms to itself. Sometimes though, I see an idiom which I like in a language I am familiar with, and I try and use it in a ...
0
votes
2answers
125 views

Pattern name for a class inheriting of a generic based on itself

I'm wondering if there is a name for the pattern of defining a generic class with one type argument where the type inherits the defining class. For example public class A<T> where T : A<T&...
2
votes
2answers
167 views

The dilemma of implementing virtual inheritance

I am working on a program language, and I came to the dilemma whether it should support virtual inheritance or not. As a designer and implementer of the language, including that feature represents ...
0
votes
5answers
417 views

Anti-idiom? Chained equality operators

I got a headscratcher: someone submitted code to test whether all of some checkboxes were unchecked, and it indicated True when an even number were checked. The code looked something like: if (box1....
0
votes
1answer
122 views

What's the most idiomatic way to make a collection of enum.Enum in Python?

I have an Enum in Python that looks something like this: import enum class Color(enum.Enum): red = 'red' blue = 'blue' yellow = 'yellow' puce = 'puce' chartreuse = 'chartreuse' ...
2
votes
2answers
576 views

When to actually use RAII?

I understand the concept of RAII: Use the destructor as a means to free resources, such as memory, or closing file handles/database connections. Coming from a Java background this was actually rather ...
0
votes
0answers
235 views

iodiomatic future failures in scala

what would be the more idiomatic way to recover from a failed future val fut: Future[Option[Int]] = Future.failed(new RuntimeException("Hi, I have failed")) case class ApplicationException(msg: ...
7
votes
2answers
296 views

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 ...
6
votes
1answer
250 views

Idiomatic way of writing a GUI system in Go?

I'm writing a little GUI system for my game in Go. So far my structure is kind of like this: type Component interface { Update() Render(ctx) Translate() GetComponent() []Component ...
6
votes
4answers
455 views

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 ...
22
votes
3answers
583 views

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 ...
4
votes
2answers
223 views

Go - idioms/design for determining when an unknown number of goroutines are complete

I have a workflow wherein I walk recursively through a bunch of directories, then for each file perform some action. I'm using goroutines to walk each directory, and also to process each file. The ...
5
votes
3answers
440 views

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?
1
vote
2answers
264 views

Using self.method vs the scope :method DSL

According to the Thoughbot Rails Style Guide, we should Use def self.method, not the scope :method DSL. My question is: is this simply for the sake of choosing one of these styles and sticking ...
3
votes
3answers
508 views

Is checking return values always required? [duplicate]

We know that checking return values prevent our software from unexpected states. (You can see CWE definition.) But, we are sometimes sure about the return value. For example: bool ...
2
votes
2answers
270 views

Which programming idiom to choose for this open source library? [closed]

Which programming idiom is easier to use for beginner developers writing concrete file parsing classes? I'm developing an open source library, which one of the main functionality is to parse plain ...
0
votes
3answers
135 views

clone() only partially doable; how to react?

Suppose we have a class-hierarchy whose base class B requires a clone() method to be defined in its derivations. Whilst this works perfectly for most of them there is this one derivation X that holds ...
5
votes
1answer
191 views

Why are F# exceptions generally not suffixed with 'Exception'?

In .NET, it is idiomatic to suffix exception types with Exception. But most, if not all, sources I have seen for custom exception types in F# don't follow this idiom. Most seem to use the suffix ...
0
votes
2answers
1k views

help me understand Rails and attributes as class methods

This is from the Hartl Rails tutorial. We are automatically logging in a user in the process of creating that user with a callback to #create_remember_token. It works great but there are some things, ...
5
votes
3answers
1k views

Intersection of geometric entities

I was trying to design a small C++ geometric API for learning purposes, but came across a problem when dealing with intersections of geometric entities. For example, the intersection of a line and a ...
5
votes
6answers
4k views

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, ...
4
votes
1answer
500 views

Object oriented wrapper around a dll

So, I'm writing a C# managed wrapper around a native dll. The dll contains several hundred functions. In most cases, the first argument to each function is an opaque handle to a type internal to the ...
12
votes
5answers
932 views

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, ...
3
votes
1answer
1k views

Dummy float values to force floating-point operations

It is common to use idioms such as: x/60.0 to force a floating-point division when x is an integer in languages which do not have distinct operators for integer and decimal division. Is this an ...
8
votes
4answers
6k views

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 ...
7
votes
5answers
1k views

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 ...
2
votes
3answers
1k views

design pattern for describing a variable subpart of a config file

Suppose I have an XML config file like the following: <myapp> <settings/> <output> <mailto>mail service configuration parameters</mailto> ...
39
votes
10answers
8k views

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 ...
15
votes
7answers
8k views

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 ...
6
votes
3answers
2k views

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 ...
6
votes
4answers
1k views

How does one learn to program (and think) the Ruby way? [closed]

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 ...
6
votes
2answers
1k views

How to program for constraints/rules

First the background, during interviews in the past, many times I have been asked to design some or other variation of card game as programming puzzle, and I have tried to design it in OO way, but I ...
16
votes
6answers
3k views

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 ...
22
votes
2answers
7k views

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 '...