I am in a current iteration between design and implementation, and ended up with the following "one-liner":
IEnumerable<Channel> ActiveChannels = Receiver.AcquisitionInfo
.ActiveIndices
.Select(v => Receiver.Sensors
.SelectMany(s => s.Channels)
.ElementAt(v));
Basically, in the class where this code appears, I need to know, from the available channels, which of those are activated. There is an AcquisitionInfo
object holding the list of Sensors with their respective Channels, and so on.
Just by looking to the code, it is obvious that it has some "syndrome". Just like the saying "he wanted a banana, but got a gorilla holding a banana and the whole forest!", or, like some blogger has stated: "imagine if you go to the grocery clerk, take off your pants and hand it to him, so that he can take your wallet from the pant's pocket, and then take the proper amount of money from the wallet."
So, is there a name for this smell / anti-pattern? If not, how could I characterize it and, most important, how should I refactor it?
.
instead of the lisp-ish style of()
. It is important to try to understand LINQ before one starts complaining how many.
are used when writing a statement. – Aug 13 '15 at 00:39