New answers tagged

1

Wouldn’t it make sense to have an interface (Java speaking) OrderedSet and the classes BinaryTree and RedBlackTree implement that interface? If you are implementing a library and introduce the interface later, this will require a new major version. In this new major version, it could also be possible to rename the class OrderedSet to BinaryTree and ...


1

Addressing the question from a different perspective, I'd say that providing a domain-oriented abstraction may be the best answer. Rather than describing the properties (abstract or concrete) of the implementation, define an abstraction that is directly domain-relevant to its users, and limited to the specific capabilities they need. This means you provide ...


5

Something meaningful? Nesting lots of meaningless loop variables quickly becomes unreadable. Imagine seeing something like this embedded inside four levels of loops: do_stuff(i,j,k+4, l*i) and trying to understand what it does vs something like: do_stuff(row, col, height + 4, function_value * row) This is a simple example. A lot of this sort of logic ...


4

If there are four or more dimensions, then they represent something more than just cartesian (or other) co-ordinates, so just use a (short) word that signifies what each level actually is.


3

The MoreLINQ library has this method and calls it Pipe, which I find very appropriate. Pipe   |   Executes the given action on each element in the source sequence and yields it If you're interested - you can see it's source code here.


4

There isn't a standard name. Haskell doesn't even bother defining it, but as Jörg said, you can easily define it yourself as flip (.) F# defines it as >> and calls it the "forward composition operator." Scala defines it as the andThen method, but doesn't describe it further. If you looked at 10 more functional languages, you'd probably get 10 ...


11

Linq functions with modifying effects will at least violate the principle of least astonishment, so what you have in mind is a code smell, to my understanding. For your use case, I think it is much more readable when you do not try to push as many command into one line as you can. Why not write a function like IEnumerable<Button> CreateButtons() { ...



Top 50 recent answers are included