Where does it end?
-
Sander: Yes, it's 'clever' code. I have many years with Winforms, and the DataGridView. Also with building software for users, using a team of developers. To my mind (based on your necessarily limited description) you are re-coding something that the DataGridView already does. It does it (a) more efficiently than your code, (b) with less potential for support issues (ie, bugs), and (c) in a more user-friendly manner. If you were on my team I would see two problems. They are very common problems, so fairly straightforward to deal with. The first problem is: Why on earth do you need to invoke the sort from a drop-down? Does the client really want to pay $10,000 to be able to sort clunky-fashion, instead of just click the damn header like every other right-thinking user? Go back to the user and enlighten them on what they really want to do here. The second problem is: You (the developer) have decided (as developers often do) to code your way out of a corner. You develop code that must be laboriously explained (although it is excitingly generic). Then you post the code on a geeky forum, looking for approval. I know why you've done that: because you know there are other guys on your team who will diss your 'clever' code. Pro tip: you are writing Winforms apps for end users. You have not yet been called to write cross-platform compilers for GoogIntelSoft. As your boss I would tell you: "Sander, when we deliver that software (next week BTW), our client will not pay us one red cent extra for the cleverness of your grid sorting code. Any bugs it generates in the approval period will cost me money."
What a pleasure to read this kind of thoughtful analysis ! thanks, Bill
«To kill an error's as good a service, sometimes better than, establishing new truth or fact.» Charles Darwin in "Prospero's Precepts"
-
kmoorevs wrote:
Just leave decent documentation for the next guy
If I told you you could call it like this, would you know enough? :)
SomeFunction("Name", Queryable.OrderBy, q => q.Name);
Visit my blog at Sander's bits - Writing the code you need. Or read my articles at my CodeProject profile.
Simplicity is prerequisite for reliability. — Edsger W. Dijkstra
Regards, Sander
Sander Rossel wrote:
would you know enough?
I wouldn't. I don't do lambdas. Or Linq.
-
Sander: Yes, it's 'clever' code. I have many years with Winforms, and the DataGridView. Also with building software for users, using a team of developers. To my mind (based on your necessarily limited description) you are re-coding something that the DataGridView already does. It does it (a) more efficiently than your code, (b) with less potential for support issues (ie, bugs), and (c) in a more user-friendly manner. If you were on my team I would see two problems. They are very common problems, so fairly straightforward to deal with. The first problem is: Why on earth do you need to invoke the sort from a drop-down? Does the client really want to pay $10,000 to be able to sort clunky-fashion, instead of just click the damn header like every other right-thinking user? Go back to the user and enlighten them on what they really want to do here. The second problem is: You (the developer) have decided (as developers often do) to code your way out of a corner. You develop code that must be laboriously explained (although it is excitingly generic). Then you post the code on a geeky forum, looking for approval. I know why you've done that: because you know there are other guys on your team who will diss your 'clever' code. Pro tip: you are writing Winforms apps for end users. You have not yet been called to write cross-platform compilers for GoogIntelSoft. As your boss I would tell you: "Sander, when we deliver that software (next week BTW), our client will not pay us one red cent extra for the cleverness of your grid sorting code. Any bugs it generates in the approval period will cost me money."
Robert g Blair wrote:
instead of just click the damn header
How do I have it sort by column 5 then by column 7 descending? Clicking on column headers to sort is bullshit and whoever started it should be shot.
-
Sander Rossel wrote:
would you know enough?
I wouldn't. I don't do lambdas. Or Linq.
You don't do C#?
Visit my blog at Sander's bits - Writing the code you need. Or read my articles at my CodeProject profile.
Simplicity is prerequisite for reliability. — Edsger W. Dijkstra
Regards, Sander
-
You don't do C#?
Visit my blog at Sander's bits - Writing the code you need. Or read my articles at my CodeProject profile.
Simplicity is prerequisite for reliability. — Edsger W. Dijkstra
Regards, Sander
I do
C#
; it's kids these days who don't. -
I do
C#
; it's kids these days who don't.You do C#, but not LINQ and lambda? How do you work with collections, write out each foreach loop every time?
Visit my blog at Sander's bits - Writing the code you need. Or read my articles at my CodeProject profile.
Simplicity is prerequisite for reliability. — Edsger W. Dijkstra
Regards, Sander
-
You do C#, but not LINQ and lambda? How do you work with collections, write out each foreach loop every time?
Visit my blog at Sander's bits - Writing the code you need. Or read my articles at my CodeProject profile.
Simplicity is prerequisite for reliability. — Edsger W. Dijkstra
Regards, Sander
Foreach is inefficient, for loops rule.
-
Foreach is inefficient, for loops rule.
I think/hope you're missing a joke icon :laugh:
Visit my blog at Sander's bits - Writing the code you need. Or read my articles at my CodeProject profile.
Simplicity is prerequisite for reliability. — Edsger W. Dijkstra
Regards, Sander
-
A shame you didn't recognize it. It's an indication that my code is, indeed, 'clever'... Not sure how to make it more readable though (I guess this is the part where it becomes a programming question :laugh: ).
Visit my blog at Sander's bits - Writing the code you need. Or read my articles at my CodeProject profile.
Simplicity is prerequisite for reliability. — Edsger W. Dijkstra
Regards, Sander
-
Have you considered adding a comment? I find that's generally a good idea for clever code (with or without quotes).
It's funny you should say that. While you certainly make a valid point allow me to explain why I don't think that's the solution. If the code is so unclear it needs comments I really think you should stop and have another look at your code. Try rewriting it so that it shouldn't need comments (which is what I did). If there's really nothing else you can do you can use a comment, but I highly discourage it. I've said it before and I'll say it now; comments are the evil of this world :) In fact I've had so much bad experiences with comments that I've written a tip about it a few years ago. If you're interested: Write comments that matter[^]. Thanks for the tip though :thumbsup:
Visit my blog at Sander's bits - Writing the code you need. Or read my articles at my CodeProject profile.
Simplicity is prerequisite for reliability. — Edsger W. Dijkstra
Regards, Sander