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.
  • _ _Damian S_

    There's cleverness for the sake of cleverness, and there's cleverness that creates an elegant solution to a difficult problem...

    ------------------------------------------- Don't walk in front of me, I may not follow; Don't walk behind me, I may not lead; Just bugger off and leave me alone!!

    P Offline
    P Offline
    Paul Conrad
    wrote on last edited by
    #17

    _Damian S_ wrote:

    there's cleverness that creates an elegant solution to a difficult problem...

    True. I just think of the cleverness for the sake of being a hot-shot smarty-pants.

    "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon

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

      C Offline
      C Offline
      Chris Austin
      wrote on last edited by
      #18

      I was never clever enough to write clever code. Unless you mean doing things like bit shifts because at times they were faster than basic arithmetic on some platforms. Now days the c/c++ compilers are pretty good so I haven't found the need to do it too often.

      My Blog A human being should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly. Specialization is for insects. - -Lazarus Long

      1 Reply Last reply
      0
      • P Paul Conrad

        _Damian S_ wrote:

        there's cleverness that creates an elegant solution to a difficult problem...

        True. I just think of the cleverness for the sake of being a hot-shot smarty-pants.

        "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon

        _ Offline
        _ Offline
        _Damian S_
        wrote on last edited by
        #19

        Absolutely... I was agreeing with you on that one!!

        ------------------------------------------- Don't walk in front of me, I may not follow; Don't walk behind me, I may not lead; Just bugger off and leave me alone!!

        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.

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

          Josh Smith wrote:

          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.

          Well, I will agree mostly. I still have to hesitantly present a situation, that someone else brought up. Sometimes the non-clever way is too cpu-intensive. I have been accused of writing "clever" code, even though all I did was bring game programming techniques to sci-vis and engineering. I didn't invent anything, I sped it up by an exponent or more. Quaternions were once considered clever because it was a mathematical concept that was difficult to imagine (try imagining a 4 dimensional unit vector). But today it is normal to use for solving problems. And now people are coming to me because they somehow just discovered quaternions. :laugh: But cleverness for the sake of showing off, that programmer is no different than a pilot hotdogging. He needs to grow up. :-D

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

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

            Steve EcholsS Offline
            Steve EcholsS Offline
            Steve Echols
            wrote on last edited by
            #21

            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!

            • S
              50 cups of coffee and you know it's on!
              Code, follow, or get out of the way.
            R D 2 Replies 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.

              S Offline
              S Offline
              Shog9 0
              wrote on last edited by
              #22

              I tell myself that every time i start a new project. But i never listen. And then i have to go back and clean up the mess i made of things, cussing at myself the whole time. It's easier when other people do it. I still cuss at them while fixing things, but they don't have to stick around to hear it. ;)

              every night, i kneel at the foot of my bed and thank the Great Overseeing Politicians for protecting my freedoms by reducing their number, as if they were deer in a state park. -- Chris Losinger, Online Poker Players?

              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.

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

                There must be a reason why "Clever" begins with "C". C was designed for and by clever coders. :cool: One of the practices I least liked seeing in C programs was things like Given: char* s The test: if ( !s ) ... The test: if ( s ) ... Rather than: if ( s != NULL ) ...

                R 1 Reply Last reply
                0
                • P PIEBALDconsult

                  There must be a reason why "Clever" begins with "C". C was designed for and by clever coders. :cool: One of the practices I least liked seeing in C programs was things like Given: char* s The test: if ( !s ) ... The test: if ( s ) ... Rather than: if ( s != NULL ) ...

                  R Offline
                  R Offline
                  Robert Surtees
                  wrote on last edited by
                  #24

                  are you sure !s is the same as s != NULL ?

                  D P 2 Replies Last reply
                  0
                  • C Christian Graus

                    Yeah, there was a time when I wrote 'clever' C++ code, but I got over myself.

                    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 )

                    B Offline
                    B Offline
                    Brady Kelly
                    wrote on last edited by
                    #25

                    I think we all go through that phase. I agree with Josh, writing simple code that works is smart. Being 'clever' only sets you, or your successor, up for trouble. That said, I do sometimes take a perverse pleasure in properly using the -- and ++ operators, knowing full well that a rookie will spend some extra time on a particular line. :suss:

                    MY BLOG

                    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 )

                      L Offline
                      L Offline
                      Leslie Sanford
                      wrote on last edited by
                      #26

                      Christian Graus wrote:

                      int n = myInts[index++];

                      Unfortunately, that sort of statement is in a lot of C and C++ code. I dislike embedded expressions that have side-effects. It makes the code unclear and difficult to debug.

                      K 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 )

                        B Offline
                        B Offline
                        Brady Kelly
                        wrote on last edited by
                        #27

                        This brings us back to the subject of functional programming. Without defining several intermediate, delegate type, functions, I can't see how even a small number diabolically nested functions can ever be readable without some sort of stack based source editor.

                        MY BLOG

                        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

                          B Offline
                          B Offline
                          Brady Kelly
                          wrote on last edited by
                          #28

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

                          MY BLOG

                          M 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
                            Brady Kelly
                            wrote on last edited by
                            #29

                            I touched on this in a recent blog[^], where I said how much I enjoyed a hard-core session of copy and paste coding, over spending too much time writing really clever, generalised code. I'm not going to be adding many more, if at all any, new web pages to the project, and all my copied and pasted, repetitive code is working now, where I'm sure the clever code I could have put out would still require more thorough testing.

                            MY BLOG

                            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
                              Leslie Sanford
                              wrote on last edited by
                              #30

                              Josh Smith wrote:

                              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.

                              The cleverness should be in the solution to the problem. How you execute that solution in code should be simple and elegant.

                              1 Reply Last reply
                              0
                              • E El Corazon

                                Josh Smith wrote:

                                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.

                                Well, I will agree mostly. I still have to hesitantly present a situation, that someone else brought up. Sometimes the non-clever way is too cpu-intensive. I have been accused of writing "clever" code, even though all I did was bring game programming techniques to sci-vis and engineering. I didn't invent anything, I sped it up by an exponent or more. Quaternions were once considered clever because it was a mathematical concept that was difficult to imagine (try imagining a 4 dimensional unit vector). But today it is normal to use for solving problems. And now people are coming to me because they somehow just discovered quaternions. :laugh: But cleverness for the sake of showing off, that programmer is no different than a pilot hotdogging. He needs to grow up. :-D

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

                                B Offline
                                B Offline
                                Brady Kelly
                                wrote on last edited by
                                #31

                                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 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
                                  leppie
                                  wrote on last edited by
                                  #32

                                  I prefer clever code over cowboy code anyday :)

                                  xacc.ide
                                  The rule of three: "The first time you notice something that might repeat, don't generalize it. The second time the situation occurs, develop in a similar fashion -- possibly even copy/paste -- but don't generalize yet. On the third time, look to generalize the approach."

                                  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
                                    Rei Miyasaka
                                    wrote on last edited by
                                    #33

                                    Amen. "Everything should be made as simple as possible, but not simpler." -- A. Einstein And now, allow me to be a jerk: #define Swap(x, y) (x^=y^=x^=y)

                                    C 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!

                                      R Offline
                                      R Offline
                                      Rei Miyasaka
                                      wrote on last edited by
                                      #34

                                      CP is notorious for overvaluing "clever" things. That's probably why lame one-liner posts on the forums always get 5 star votes. Clever coding isn't a technical problem; it's a personality problem.

                                      1 Reply Last reply
                                      0
                                      • P Paul Conrad

                                        CataclysmicQuantums wrote:

                                        Bit shifting instead of multiplication for instance

                                        I remember those tricks, and they still work well from time to time. ---modified Though it is tough to beat an optimizing compiler these days.

                                        "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon

                                        D Offline
                                        D Offline
                                        Dario Solera
                                        wrote on last edited by
                                        #35

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

                                          G Offline
                                          G Offline
                                          Guy Harwood
                                          wrote on last edited by
                                          #36

                                          Somebody (i cant remember who) once said.... Any fool can write code that a computer can understand. Good programmers write code that humans can understand. :) Guy

                                          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