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

Cleverness

Scheduled Pinned Locked Moved The Lounge
csharpphpwpfcomquestion
78 Posts 48 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.
  • J Josh Smith

    I abhor reading code which is intentionally clever.  Clever code which functions properly is garbage.  If you're smart enough to write clever code which works, stop being a jerk and write smart code which works.  Please. Clever code requires me to spend time figuring out how some pompous smart person thinks.  Smart code allows me to just read it and move on. Agreed?

    :josh: My WPF Blog[^] Without a strive for perfection I would be terribly bored.

    S Offline
    S Offline
    Stuart Dootson
    wrote on last edited by
    #37

    Ummmm - define 'clever code' - what your message says to me is that you don't believe you should have to think when reading code - I can't agree with that.

    J 1 Reply Last reply
    0
    • J Josh Smith

      I abhor reading code which is intentionally clever.  Clever code which functions properly is garbage.  If you're smart enough to write clever code which works, stop being a jerk and write smart code which works.  Please. Clever code requires me to spend time figuring out how some pompous smart person thinks.  Smart code allows me to just read it and move on. Agreed?

      :josh: My WPF Blog[^] Without a strive for perfection I would be terribly bored.

      B Offline
      B Offline
      Bob1000
      wrote on last edited by
      #38

      Can't agree more or re-arranging into something more readible Totaly agree with you! Perhaps the problem lies with the language designers allowing these constructs in the first place? Give an idiot enough rope ........! Bob

      1 Reply Last reply
      0
      • J Josh Smith

        I abhor reading code which is intentionally clever.  Clever code which functions properly is garbage.  If you're smart enough to write clever code which works, stop being a jerk and write smart code which works.  Please. Clever code requires me to spend time figuring out how some pompous smart person thinks.  Smart code allows me to just read it and move on. Agreed?

        :josh: My WPF Blog[^] Without a strive for perfection I would be terribly bored.

        B Offline
        B Offline
        Bob1000
        wrote on last edited by
        #39

        Can't agree more or re-arranging into something more readible Totaly agree with you! Perhaps the problem lies with the language designers allowing these constructs in the first place? Give an idiot enough rope ........! Bob

        1 Reply Last reply
        0
        • M Marc Clifton

          Josh Smith wrote:

          I abhor reading code which is intentionally clever. Clever code which functions properly is garbage. If you're smart enough to write clever code which works, stop being a jerk and write smart code which works. Please.

          You mean like: foo.GetType().GetProperty("Bar").SetValue(foo, "fizbin", null); when foo.bar="fizbin" would have worked just fine? Marc

          Thyme In The Country
          Interacx
          My Blog

          S Offline
          S Offline
          soneliso
          wrote on last edited by
          #40

          True, if you do something like that. Then you should probably maintain it yourself because i don't have 10 hours trying to figure out what you were trying to do

          1 Reply Last reply
          0
          • S Stuart Dootson

            Ummmm - define 'clever code' - what your message says to me is that you don't believe you should have to think when reading code - I can't agree with that.

            J Offline
            J Offline
            Josh Smith
            wrote on last edited by
            #41

            Stuart Dootson wrote:

            Ummmm - define 'clever code' - what your message says to me is that you don't believe you should have to think when reading code - I can't agree with that.

            Clever code is unabashed geeky-ness.  Code which is written for the sake of proving how smart one is, or how knowledgeable one is of abstruse features of a language.  I certainly agree that reading code requires thought, but something which can be simple shouldn't require me to sit there and "figure it out." They don't pay us to prove how smart we are by creating little puzzles, they pay us to create working software on time.

            :josh: My WPF Blog[^] Without a strive for perfection I would be terribly bored.

            S C 2 Replies Last reply
            0
            • P PIEBALDconsult

              But that takes the fun out of it.

              G Offline
              G Offline
              Gary Wheeler
              wrote on last edited by
              #42

              I'd like to take the fun out of it for the clever programmer. Along with his spleen :|.


              Software Zen: delete this;

              1 Reply Last reply
              0
              • B Brady Kelly

                I don't know if that qualifies as clever, just verbose.

                MY BLOG

                M Offline
                M Offline
                Marc Clifton
                wrote on last edited by
                #43

                Brady Kelly wrote:

                I don't know if that qualifies as clever, just verbose.

                Oh, if you want clever and terse, and if I knew about C# lambda and functional programming, I could probably whip somethin up that harkens back to the days of APL. Marc

                Thyme In The Country
                Interacx
                My Blog

                1 Reply Last reply
                0
                • Steve EcholsS Steve Echols

                  Bah! As long as your "cleverness" is well documented, why is it bad? Maybe you can learn some new techniques or ways of thinking from someone else's cleverness. Seems to me programmers these days don't want to think, or don't have time to think. I like a good brainteaser every now and again - keeps me sharp!


                  - S 50 cups of coffee and you know it's on!

                  D Offline
                  D Offline
                  Delphi4ever
                  wrote on last edited by
                  #44

                  Too Bad my coworkers are too "clever" to be bothered with documenting. There is not *one page* of documentation! And me, the new guy, is so screwed...

                  1 Reply Last reply
                  0
                  • J Josh Smith

                    I abhor reading code which is intentionally clever.  Clever code which functions properly is garbage.  If you're smart enough to write clever code which works, stop being a jerk and write smart code which works.  Please. Clever code requires me to spend time figuring out how some pompous smart person thinks.  Smart code allows me to just read it and move on. Agreed?

                    :josh: My WPF Blog[^] Without a strive for perfection I would be terribly bored.

                    R Offline
                    R Offline
                    rastaVnuce
                    wrote on last edited by
                    #45

                    I'm not quite sure we're on the same wavelength about the whole "clever code" terminology, but nevertheless... if there's a possibility to fit five lines into one, do it. No reason not to. If someone can't read int newInt = myInts[index++] or the likes of it... then he should switch to VB scripts, or learn C[++,#]. Learn it for real, this time.

                    A buffalo soldier, a dread-like rasta !

                    J 1 Reply Last reply
                    0
                    • R rastaVnuce

                      I'm not quite sure we're on the same wavelength about the whole "clever code" terminology, but nevertheless... if there's a possibility to fit five lines into one, do it. No reason not to. If someone can't read int newInt = myInts[index++] or the likes of it... then he should switch to VB scripts, or learn C[++,#]. Learn it for real, this time.

                      A buffalo soldier, a dread-like rasta !

                      J Offline
                      J Offline
                      Josh Smith
                      wrote on last edited by
                      #46

                      rastaVnuce wrote:

                      int newInt = myInts[index++]

                      That's not clever.  By "clever" I mean things like depending on some abstruse side-effect of a method call with a certain parameter value to make something work, etc.

                      :josh: My WPF Blog[^] Without a strive for perfection I would be terribly bored.

                      K C 2 Replies Last reply
                      0
                      • J Josh Smith

                        rastaVnuce wrote:

                        int newInt = myInts[index++]

                        That's not clever.  By "clever" I mean things like depending on some abstruse side-effect of a method call with a certain parameter value to make something work, etc.

                        :josh: My WPF Blog[^] Without a strive for perfection I would be terribly bored.

                        K Offline
                        K Offline
                        khuzwayom
                        wrote on last edited by
                        #47

                        Thank you for the lesson. As a rookie I always thougt that if I write code that confuses others they will regard me as the best in the team, not knowing that that actaul makes things difficult for the next person to maintain that app. I am now going to start writing SMART code not unnecesary Clever code. :-D Thank You.

                        khuzym

                        J 1 Reply Last reply
                        0
                        • K khuzwayom

                          Thank you for the lesson. As a rookie I always thougt that if I write code that confuses others they will regard me as the best in the team, not knowing that that actaul makes things difficult for the next person to maintain that app. I am now going to start writing SMART code not unnecesary Clever code. :-D Thank You.

                          khuzym

                          J Offline
                          J Offline
                          Josh Smith
                          wrote on last edited by
                          #48

                          khuzwayom wrote:

                          I am now going to start writing SMART code not unnecesary Clever code.

                          Good decision.

                          :josh: My WPF Blog[^] Without a strive for perfection I would be terribly bored.

                          1 Reply Last reply
                          0
                          • J Josh Smith

                            I abhor reading code which is intentionally clever.  Clever code which functions properly is garbage.  If you're smart enough to write clever code which works, stop being a jerk and write smart code which works.  Please. Clever code requires me to spend time figuring out how some pompous smart person thinks.  Smart code allows me to just read it and move on. Agreed?

                            :josh: My WPF Blog[^] Without a strive for perfection I would be terribly bored.

                            W Offline
                            W Offline
                            Wambach
                            wrote on last edited by
                            #49

                            Unless the clever code is written be judged on its cleverness. Years ago I followed the Obfuscated Perl contests. Code that hurts yours eyes, baffles your brain and delights your senses when run.

                            1 Reply Last reply
                            0
                            • J Josh Smith

                              Stuart Dootson wrote:

                              Ummmm - define 'clever code' - what your message says to me is that you don't believe you should have to think when reading code - I can't agree with that.

                              Clever code is unabashed geeky-ness.  Code which is written for the sake of proving how smart one is, or how knowledgeable one is of abstruse features of a language.  I certainly agree that reading code requires thought, but something which can be simple shouldn't require me to sit there and "figure it out." They don't pay us to prove how smart we are by creating little puzzles, they pay us to create working software on time.

                              :josh: My WPF Blog[^] Without a strive for perfection I would be terribly bored.

                              S Offline
                              S Offline
                              Stuart Dootson
                              wrote on last edited by
                              #50

                              I guess I just have an issue with blanket rejection of 'clever' code, having written some for a specific reason (performance related, in a resource-limited embedded system) and having it rejected because it was 'clever' and replaced with code that was 2 or 3 times slower. In most desktop situations, I would agree with you - clever code isn't desirable or should be stuck in a library so you don't see the implementation, just the API (e.g. the MS implementations of 'strcpy' and 'strcat' in hte C runtime). Trouble is, 'clever' does have many and varying definitions - for example, I wouldn't call use of the C++ standard library collections and algorithms 'clever', but I know people who would.

                              1 Reply Last reply
                              0
                              • J Josh Smith

                                I abhor reading code which is intentionally clever.  Clever code which functions properly is garbage.  If you're smart enough to write clever code which works, stop being a jerk and write smart code which works.  Please. Clever code requires me to spend time figuring out how some pompous smart person thinks.  Smart code allows me to just read it and move on. Agreed?

                                :josh: My WPF Blog[^] Without a strive for perfection I would be terribly bored.

                                K Offline
                                K Offline
                                k bl
                                wrote on last edited by
                                #51

                                What about clerverly(:)) simple code? For instance, with the jQuery toolkit for JavaScript there is an array handler called "each" used like this: $(arrayi).each(function(i){ document.write(i) }); I don't normally dig the "clever code", but I love when it is tastefully simple.

                                ASP.Net meets jQuery... Imagine the possibilities.

                                1 Reply Last reply
                                0
                                • B Brady Kelly

                                  El Corazon wrote:

                                  try imagining a 4 dimensional unit vector

                                  I read somewhere once, I think in a description of multi-dimensional mathematical stuff, that understanding and applying it requires one to not try and imagine real world examples, of e.g. a tesseract, but to simply accept them as abstract entities and use them.

                                  MY BLOG

                                  E Offline
                                  E Offline
                                  El Corazon
                                  wrote on last edited by
                                  #52

                                  Brady Kelly wrote:

                                  I read somewhere once, I think in a description of multi-dimensional mathematical stuff, that understanding and applying it requires one to not try and imagine real world examples, of e.g. a tesseract, but to simply accept them as abstract entities and use them.

                                  very true, and I try very hard to explain that. Some people can, some people can't just "accept" something as working and use it. In my business change is slow moving, and I push for far too many changes, so I am accused of cleverness, to outright dangerous volumes of change. :) but then, they were still drawing stick figures and line graphs when I came here 15+ years go. :laugh:

                                  _________________________ Asu no koto o ieba, tenjo de nezumi ga warau. Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)

                                  1 Reply Last reply
                                  0
                                  • C Christian Graus

                                    He means if you can see a way to make 5 lines work in one line of code, a simple example is int n = myInts[index++]; that's not *terribly* clever, but as a rough off the top of my head example, incrementing the index in the next line of code makes clear that you want it to increment after the operation. I know that in my early days of STL I delighted in writing code that in hindsight was far more obscure than this, on the basis that I knew how. But, you quickly realise that readable counts for more than clever, it's part of being a team player instead of trying to show off, IMO.

                                    Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

                                    D Offline
                                    D Offline
                                    deltalmg
                                    wrote on last edited by
                                    #53

                                    Christian Graus wrote:

                                    I know that in my early days of STL I delighted in writing code that in hindsight was far more obscure than this, on the basis that I knew how. But, you quickly realise that readable counts for more than clever, it's part of being a team player instead of trying to show off, IMO.

                                    Not only that, 9/10 times the code will compile to exactly the same assembly, or at least the performance won't be much different. So ... if you aren't coding in assembly, why make your code look like that junk ;P I realize the CPU has a 'add contents pointed to by this register, to the contents pointed to by that register and store it here and add 5 to it while your not busy', but do I really need to read that on each line? My favorite was during a job interview I was asked on the fly to code a program that would get the count of all values of an 8 bit integer, for a large set (several million). I wasn't thinking so I originally had a STL list, and a one dimensional array the size of the original input. Then after a couple seconds thought it became: int count[255]; int i; for (i = 0; i < 255; i++) count[i] = 0; for (i = 0; i < list.size; i++) count[list[i].Value]++; for (i = 0; i < 255; i++) cout << count[i]; Quick and dirty, and only n + 2*255 interations :) I thought it was beautiful using the value of the data to offset the array, and then increment it all on one line, hehe. I think I curled their eyebrows, I don't think they had thought of that and thought their would be more code required.

                                    A 1 Reply Last reply
                                    0
                                    • C Christian Graus

                                      He means if you can see a way to make 5 lines work in one line of code, a simple example is int n = myInts[index++]; that's not *terribly* clever, but as a rough off the top of my head example, incrementing the index in the next line of code makes clear that you want it to increment after the operation. I know that in my early days of STL I delighted in writing code that in hindsight was far more obscure than this, on the basis that I knew how. But, you quickly realise that readable counts for more than clever, it's part of being a team player instead of trying to show off, IMO.

                                      Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

                                      G Offline
                                      G Offline
                                      Gogza
                                      wrote on last edited by
                                      #54

                                      In that case use VB! ;) Instantally more readable and accessable! gogza

                                      1 Reply Last reply
                                      0
                                      • D Dario Solera

                                        Paul Conrad wrote:

                                        Though it is tough to beat an optimizing compiler these days.

                                        And hardware optimization.

                                        If you truly believe you need to pick a mobile phone that "says something" about your personality, don't bother. You don't have a personality. A mental illness, maybe - but not a personality. - Charlie Brooker My Blog - My Photos - ScrewTurn Wiki

                                        G Offline
                                        G Offline
                                        Gogza
                                        wrote on last edited by
                                        #55

                                        And quad-core processors! gogza

                                        1 Reply Last reply
                                        0
                                        • J Josh Smith

                                          I abhor reading code which is intentionally clever.  Clever code which functions properly is garbage.  If you're smart enough to write clever code which works, stop being a jerk and write smart code which works.  Please. Clever code requires me to spend time figuring out how some pompous smart person thinks.  Smart code allows me to just read it and move on. Agreed?

                                          :josh: My WPF Blog[^] Without a strive for perfection I would be terribly bored.

                                          L Offline
                                          L Offline
                                          Lost User
                                          wrote on last edited by
                                          #56

                                          Can't be any of my code.... I am too lazy to write clever code.

                                          Why is common sense not common? Never argue with an idiot. They will drag you down to their level where they are an expert. Sometimes it takes a lot of work to be lazy Individuality is fine, as long as we do it together - F. Burns

                                          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