Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. Where does it end?

Where does it end?

Scheduled Pinned Locked Moved The Lounge
cssalgorithmsquestioncsharpvisual-studio
44 Posts 12 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Sander RosselS Sander Rossel

    Another part of my app got slightly more complex, but I was able to implement this solution and overall reduce complexity (I hope) :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

    S Offline
    S Offline
    Sascha Lefevre
    wrote on last edited by
    #28

    That's great! Glad I could help a minuscule amount :-) You recommended the XtraGrid to Eddy Vluggen - may I ask why you don't use it in this project too? (I'm about to use it myself for the first time and I would be interested what reason there could be to not use it) /Sascha

    Sander RosselS 1 Reply Last reply
    0
    • S Sascha Lefevre

      That's great! Glad I could help a minuscule amount :-) You recommended the XtraGrid to Eddy Vluggen - may I ask why you don't use it in this project too? (I'm about to use it myself for the first time and I would be interested what reason there could be to not use it) /Sascha

      Sander RosselS Offline
      Sander RosselS Offline
      Sander Rossel
      wrote on last edited by
      #29

      Sascha Lefévre wrote:

      That's great! Glad I could help a minuscule amount

      I'm pretty sure you're helpful at bigger amounts than that (in fact this was more than minuscule already!) :)

      Sascha Lefévre wrote:

      You recommended the XtraGrid to Eddy Vluggen - may I ask why you don't use it in this project too?

      I used the XtraGrid (and more XtraControls) at my previous job. I'm now at a new job, working for a customer who sticks to as much "vanilla .NET" as possible. If I could I'd get those XtraControls right in there, but it's not my call :) And the job initially involved just some bugfixes for a few weeks. In HTML and CSS. With AngularJS. But in reality I've been doing WinForms for over a month now :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

      S 1 Reply Last reply
      0
      • Sander RosselS Sander Rossel

        Sascha Lefévre wrote:

        That's great! Glad I could help a minuscule amount

        I'm pretty sure you're helpful at bigger amounts than that (in fact this was more than minuscule already!) :)

        Sascha Lefévre wrote:

        You recommended the XtraGrid to Eddy Vluggen - may I ask why you don't use it in this project too?

        I used the XtraGrid (and more XtraControls) at my previous job. I'm now at a new job, working for a customer who sticks to as much "vanilla .NET" as possible. If I could I'd get those XtraControls right in there, but it's not my call :) And the job initially involved just some bugfixes for a few weeks. In HTML and CSS. With AngularJS. But in reality I've been doing WinForms for over a month now :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

        S Offline
        S Offline
        Sascha Lefevre
        wrote on last edited by
        #30

        Sander Rossel wrote:

        But in reality I've been doing WinForms for over a month now

        Probably they've realized there's someone who knows what he's doing in WinForms and need to capitalize on that before you leave :laugh:

        Sander RosselS 1 Reply Last reply
        0
        • S Sascha Lefevre

          Sander Rossel wrote:

          But in reality I've been doing WinForms for over a month now

          Probably they've realized there's someone who knows what he's doing in WinForms and need to capitalize on that before you leave :laugh:

          Sander RosselS Offline
          Sander RosselS Offline
          Sander Rossel
          wrote on last edited by
          #31

          Actually they didn't know. I quit my last job (three months ago) because I wanted to do something else than WinForms. The company I work for now doesn't do WinForms at all. They assured me I'd never do WinForms again! So then this customer called "We need a programmer for some quick bugfixes asap! We need a HTML and CSS expert!" A colleague and me would do the job. Then they called again "Actually, we need someone with AngularJS skills." I actually spend an entire day learning AngularJS, because I didn't know it yet (my colleague does know it). But the day before we'd get started they called again "Actually, do you have a WinForms programmer? We need it more than the web stuff!" And so here I am doing WinForms programming again. Not quite what I had in mind, but it's only for a few weeks :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

          S 1 Reply Last reply
          0
          • Sander RosselS Sander Rossel

            Actually they didn't know. I quit my last job (three months ago) because I wanted to do something else than WinForms. The company I work for now doesn't do WinForms at all. They assured me I'd never do WinForms again! So then this customer called "We need a programmer for some quick bugfixes asap! We need a HTML and CSS expert!" A colleague and me would do the job. Then they called again "Actually, we need someone with AngularJS skills." I actually spend an entire day learning AngularJS, because I didn't know it yet (my colleague does know it). But the day before we'd get started they called again "Actually, do you have a WinForms programmer? We need it more than the web stuff!" And so here I am doing WinForms programming again. Not quite what I had in mind, but it's only for a few weeks :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

            S Offline
            S Offline
            Sascha Lefevre
            wrote on last edited by
            #32

            Ah, I see - it's that client who exactly knows what he needs! :laugh: At least your time spent learning AngularJS won't have been wasted once you're done with this :) By the way, you said somewhere in this thread that n-order-sorting is being done with additional entries in that ComboBox. But at least now that you have this solution in place it would be easy to allow the user to flexibly chain sorting columns. Not that I want to lengthen your time with WinForms though ;)

            1 Reply Last reply
            0
            • Sander RosselS Sander Rossel

              *** DISCLAIMER *** This isn't a programming question, because I've solved the programming problem myself. Rather, I'm interested in your opinion regarding the solution, clever or 'clever'? So today I had a nice little challenge. My application has a grid which can be sorted on various columns, asc and desc. Now the sorting isn't applied by clicking the column header, but by selecting a value from a drop down (Name, Name (descending), Title, Title (descending) etc.). I was thinking I could just have a switch statement where I check which ordering the user chose (which would make me extend the switch for each new ordering), or... I could abstract this away. Of course I went for the second option. Now to make this work (and it works nicely, adding a new ordering is a piece of cake) I had to write the following function:

              SomeFunction(string caption, Func, Expression>, IQueryable> linqFunction, Expression> expression) { ... }

              Since this is a WinForms application though, and WinForms and generics don't go well together I'm more or less forced to use a dynamic later on as it's quite impossible to get the values of TElement and TKey from object. I'm thinking this isn't ideal in terms of complexity and readability, but it is pretty neat because adding a new ordering is really simple (one line of simple code) and guaranteed to work on the first try (you'll never forget to change that switch statement again). And the solution is even re-usable for the filter functionality I need as well (which, of course, becomes a breeze as well)! So judging from that, clever or 'clever'? And where do you draw the line for cleverness vs. readability/simplicity?

              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

              R Offline
              R Offline
              Robert g Blair
              wrote on last edited by
              #33

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

              Sander RosselS B P 3 Replies Last reply
              0
              • R Robert g Blair

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

                Sander RosselS Offline
                Sander RosselS Offline
                Sander Rossel
                wrote on last edited by
                #34

                Robert g Blair wrote:

                something that the DataGridView already does

                I have had this problem before and sorting a DataGridView is somehow a very difficult task when you're not using DataViews...

                Robert g Blair wrote:

                Why on earth do you need to invoke the sort from a drop-down?

                Because it's much easier than sorting the DataGridView without a DataView (why is this so hard anyway?).

                Robert g Blair wrote:

                Then you post the code on a geeky forum, looking for approval

                Actually I don't. I was expecting this to fail the 'clever'-test. But where does real clever become 'clever'? That I wonder. And I wondered that when writing the code. It does everything I need and it does it well (better than the DataGridView which is still impossible to sort...), but no mortal is ever going to figure out those generics (well, so to speak, I'm not that clever :laugh: ). I'm no newbie looking for approval. In fact I don't think the people who know me question my professionalism or my 'cleverness' (although they do, from time to time, question my sanity) :)

                Robert g Blair wrote:

                there are other guys on your team who will diss your 'clever' code

                Actually they were quite impressed I could concoct such a piece of unreadable, yet compiling, code :laugh: I did already make the code a bit simpler.

                Robert g Blair wrote:

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

                Actually we're being paid by the hour :laugh: That isn't to say I'm not doing my best or working my fastest. Our clients are programmers too and they will check out my code. I'm professional and practical enough to know when to stop working on a 'clever' solution and look for another solution. This solution here cost me about 15-30 minutes, which is infinitely faster than sorting the DataGridView without a DataView. If only it were actually easy to out-of-the-box sort that DataGridView... :sigh: I still wake up at night, sweating, screaming "InvalidOperationException! The DataSource does not support sorting!" (or something like that)...

                Visit my blog

                1 Reply Last reply
                0
                • R Robert g Blair

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

                  B Offline
                  B Offline
                  BillWoodruff
                  wrote on last edited by
                  #35

                  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"

                  1 Reply Last reply
                  0
                  • Sander RosselS Sander Rossel

                    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

                    P Offline
                    P Offline
                    PIEBALDconsult
                    wrote on last edited by
                    #36

                    Sander Rossel wrote:

                    would you know enough?

                    I wouldn't. I don't do lambdas. Or Linq.

                    Sander RosselS 1 Reply Last reply
                    0
                    • R Robert g Blair

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

                      P Offline
                      P Offline
                      PIEBALDconsult
                      wrote on last edited by
                      #37

                      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.

                      1 Reply Last reply
                      0
                      • P PIEBALDconsult

                        Sander Rossel wrote:

                        would you know enough?

                        I wouldn't. I don't do lambdas. Or Linq.

                        Sander RosselS Offline
                        Sander RosselS Offline
                        Sander Rossel
                        wrote on last edited by
                        #38

                        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

                        P 1 Reply Last reply
                        0
                        • Sander RosselS Sander Rossel

                          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

                          P Offline
                          P Offline
                          PIEBALDconsult
                          wrote on last edited by
                          #39

                          I do C#; it's kids these days who don't.

                          Sander RosselS 1 Reply Last reply
                          0
                          • P PIEBALDconsult

                            I do C#; it's kids these days who don't.

                            Sander RosselS Offline
                            Sander RosselS Offline
                            Sander Rossel
                            wrote on last edited by
                            #40

                            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

                            P 1 Reply Last reply
                            0
                            • Sander RosselS Sander Rossel

                              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

                              P Offline
                              P Offline
                              PIEBALDconsult
                              wrote on last edited by
                              #41

                              Foreach is inefficient, for loops rule.

                              Sander RosselS 1 Reply Last reply
                              0
                              • P PIEBALDconsult

                                Foreach is inefficient, for loops rule.

                                Sander RosselS Offline
                                Sander RosselS Offline
                                Sander Rossel
                                wrote on last edited by
                                #42

                                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

                                1 Reply Last reply
                                0
                                • Sander RosselS Sander Rossel

                                  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

                                  R Offline
                                  R Offline
                                  RASPeter
                                  wrote on last edited by
                                  #43

                                  Have you considered adding a comment? I find that's generally a good idea for clever code (with or without quotes).

                                  Sander RosselS 1 Reply Last reply
                                  0
                                  • R RASPeter

                                    Have you considered adding a comment? I find that's generally a good idea for clever code (with or without quotes).

                                    Sander RosselS Offline
                                    Sander RosselS Offline
                                    Sander Rossel
                                    wrote on last edited by
                                    #44

                                    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

                                    1 Reply Last reply
                                    0
                                    Reply
                                    • Reply as topic
                                    Log in to reply
                                    • Oldest to Newest
                                    • Newest to Oldest
                                    • Most Votes


                                    • Login

                                    • Don't have an account? Register

                                    • Login or register to search.
                                    • First post
                                      Last post
                                    0
                                    • Categories
                                    • Recent
                                    • Tags
                                    • Popular
                                    • World
                                    • Users
                                    • Groups