- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Well, it would have helped if they'd used FIrstOrDefault and surfaced the bug immediately, wouldn't it?
Sometimes a foolish consistency is the hobgoblin of little minds. Sometimes a lack of consistency is just asking for it.
Admin
Bet $$ that the assignments were added after, and there was not a unit test for the null result...
Admin
I can't think of any excuse for treating a single instance of a class as a list, which is what irritates me the most about this code. The only reason would be massive copypasting, but that would be above-and-beyond-the-usual amount of stupid.
Admin
Actually, Dapper has a terrible mechanism for fetching additional properties, be it many to one or one to many. It's only useful for simple objects with primitive type properties. Still, the solution is either use Dapper's bad API, or use another approach (a different ORM or direct ADO.NET), not run multiple queries.
Admin
Yes the naming here is atrocious. Singular and plural both went out the window of a Hong Kong skyscraper.
Admin
"a foolish consistency is the hobgoblin of little minds" the most overused and misapplied blethering stupidity that has ever been applied to the software development industry.
I've had it quacked at me far too often by colleagues and other animals. It's usually in response to an observation that code would be far easier to read and understand if it were only set down on the page neatly. Make the stuff line up, fill in the docs, use standard English spellings for comments and not your made-up phonetic-intuitive illiteracy, etc. etc. And most of all, if you devise a more-or-less functional and efficient technique for achieving an effect, use it over and over again, rather than re-inventing it differently three times on the same page.
Grr. Rant over.
Admin
It's not the naming, it's the actual use of .ToList() and .First() and [0], all of which are completely unnecessary.
Admin
Not familiar with .net or Dapper, but would "vendorlist[0].Id" not be equal to "id"?
Admin
Well, here's a good reason. (Obviously unrelated to the OP.)
If you, say, condition all outputs from an external API (in this case Dapper) to be IEnumerable<Vendor>, then you're automatically preparing all the following Linq code to behave (mostly) as though you were using FP. Which is pretty much what Linq is for.
After that, you can just model your mapping as:
Recursion optional, and probably not advised in C#. But this is essentially car:cdr from FP. A strong argument for it is that it's pretty much future-proof -- any changes that come before are automatically list processed with no additional side effects and no surprises such as new exceptions.
Admin
"Foolish" is the operative word. In software development, it seems like being consistent is rarely a foolish decision.
Admin
"Frist" is German for Deadline.
Admin
Damn, I thought you were joking, but it is actually true :)
Admin
Sounds like some confusion on their part between DRY principles + consistent formatting versus "bEcAuSe We'Ve AlWaYs DoNe It ThAt WaY" attitudes. Establish coding standards isn't foolish. Refusing to revisit them when a better idea is put forward or circumstances change (e.g. adopted a new language or technology) is foolish.
Admin
Yes, yes it would be.
Admin
So much .... audacious ugliness in such a short amount of code. It's hard to look away. It's so ugly, it's created a new reason for Rated R. No alibi...
Admin
I usually quote it as "any consistency at all is the hobgoblin of small minds" right after someone points out how inconsistent I am.
But then, I usually make jokes at my own expense.