Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
10/29/08 07:22
Read: times


 
#159454 - Games are for kidz
Responding to: ???'s previous message
Reading BEGIN/END or { } or something else is just a question of experience. When you get used to it, your eyes stops looking at characters to read (even if eyes or monitor fails to produce sharp, legible characters). You just get a mental image about a block start in whatever format your brain chooses to express such a concept. The bad thing is of course that someone writing a parenthese (OCR-scanning some source code?) there instead, will trig my brain into accepting a block :)

On the other hand - it doesn't really matter if someone manages to fool my brain with such tricks. The compiler will catch it, without any possibility of any danger.



It might be possible that people with their first 4 weeks of experience with C/C++ do write cryptic code. These people will learn, as they gain more experience.


Some few do it because they think it is cool. They are normally not much older than the SMS junkies that visists these forums regularly and expects to be considered cool if they can average 2..3 characters/word. Any company run by competent people will give them two choices. Start writing real code yesterday, or walk out the door (and possibly a silent hint at a third option - to get thrown out a window...)

These guys mostly represents a problem on the net. They like to exhibit their code on own and other peoples forums, and they like to register themselves on any "rent-a-coder" site as programming experts ready to take on programming tasks. The good thing is that it is so easy to screen them - since they are exhibitionists, it is enough to ask them to post one sample of the programming skillz ;)



Some write cryptic code because they think they know C, but hasn't really learned the language yet so they end up with the first rewrite that finally manages to produce the result that they think represents a correct application. Huge number of forgotten variables. Functions with one name but different functionality. Evaluations that are later thrown away because the original code was either part of a test printout, or a non-working try at getting the correct results.

The bad part with these guys is that since they think they know C, they don't see a need to improve. It is so easy to not know what you don't know. They often like to write on forums about how hard C is - just because that helps them feel good, knowing that they must be way above average for knowing C so well...



Most do it because they do not know better. They may actually do know C quite well, always being able to write correct with correct precedence between operators etcetera. They may possibly be described as technically proficient but not artistically. They have never managed to learn how to organize the code and edit it into a natural flow, a problem they would have in any language.

The problem here is to get them to open the door and notice a much larger world on the outside. They can't really be helped by yet one more book with the language definitions, since they already do know the definitiosn. They need to go looking at paintings instead. They need to see real-world programs written by truly good programmers, and see that besides writing correct applications, you can go one step further and write beautiful programs. Programs that a junior developer can take over and still manage to maintain. Programs that can run efficient but at the same time validate internal assumptions and emit errors in case a code change suddenly starts to break that assumption.



Many developers also misses all the little check-list rules that helps.

They don't know that you should strive for locality-of-reference with local variables close to their use instead of large numbers of global variables.

They don't know that similar variables should be grouped into structures.

They don't realize that "if (0 == variable)" instead of "if (variable == 0)" has the advantage that the compiler will refuce to compile if they make the common mistake of writing "=" instead of "==".

They use #define when enum or const int may be better.

They forget to const-declare function parameters or methods.

They forget the use of file-local static variables.

They don't look into smart C++ pointers that will automatically reference-count memory.

They don't design factory functions for creating dynamic objects, allowing them to control if a specific object should be a singleton or may have multiple instances.

They don't use snprintf instead of sprintf to avoid buffer overflows.

They forget about the excellent warnings most modern C compilers can help with, and that the waring system can be made even better if the code is written using suitable design rules.

...



It doesn't matter what language someone is using. What this world lacks is a good clearing house that people could visit to get links to "known good" source code to read. Reading properly crafted code is probably the fastest way to learn exactly how a programming language should be used to give programs that are easy to maintain (which implies that they are also easy to read).

But "easy to read" is not equivalent with "totally littered with comments". Everything can not be expressed in the normal language constructs - such as the reason why a delay is 150ms - but quite a lot can be self-documented. Maybe 95% of thw "what" can be self-documented. The "why" can seldom be self-documented.

Too much comments results in a reduced sw quality. On one hand, you get too much text to read, so you lose the focus. On the other hand - what to do if the comment says one thing and the code does something else? You can't really maintain larger sets of comments, while the compiler together with black-box and system testing can be used to verify/validate the actual code.

List of 70 messages in thread
TopicAuthorDate
C vs Pascal            01/01/70 00:00      
   A long time ago, in a Galaxy far, far away...            01/01/70 00:00      
      Choice ?            01/01/70 00:00      
   Chalk and Cheese            01/01/70 00:00      
      A bit too simplistic analysis            01/01/70 00:00      
         Bondage and discipline            01/01/70 00:00      
            Yes, you can            01/01/70 00:00      
               ?            01/01/70 00:00      
                  Thinking hard about writing code is essential            01/01/70 00:00      
                  blame users, not tools            01/01/70 00:00      
                     Real Programmers            01/01/70 00:00      
                        It\'s back to planning and documentation again            01/01/70 00:00      
         readibility            01/01/70 00:00      
            I have and do            01/01/70 00:00      
               I fully agree            01/01/70 00:00      
               C *is* cryptic by design            01/01/70 00:00      
                  You say cryptic, I say terse            01/01/70 00:00      
                     and what is the purpose...            01/01/70 00:00      
                        terseness/ clatity            01/01/70 00:00      
                           any language depends on naming            01/01/70 00:00      
                              i do not            01/01/70 00:00      
                                 Why not, if appropriate?            01/01/70 00:00      
                                    one-char index isn't a problem            01/01/70 00:00      
                           never say never to have a multiline C construct            01/01/70 00:00      
                              multi-line conditional            01/01/70 00:00      
                  still just symbols            01/01/70 00:00      
                  No one says you have to use every short cut in C            01/01/70 00:00      
                     it's not the shortcuts...            01/01/70 00:00      
                        whatever it is            01/01/70 00:00      
                           Just a minute ...            01/01/70 00:00      
                              C can thrill you            01/01/70 00:00      
                  Not the point            01/01/70 00:00      
            free choice            01/01/70 00:00      
               commercial?            01/01/70 00:00      
                  yes, commercial            01/01/70 00:00      
                     I did never question...            01/01/70 00:00      
                        choices are good            01/01/70 00:00      
                           yeah, yeah            01/01/70 00:00      
                              ADD 1 TO COBOL            01/01/70 00:00      
                                 On Languages            01/01/70 00:00      
                                    braces            01/01/70 00:00      
                                       I like the literal BEGIN and END much better!            01/01/70 00:00      
                                          Perhaps            01/01/70 00:00      
                                             That\'s not what I meant ...            01/01/70 00:00      
                                                There I disagree            01/01/70 00:00      
                                                   words vs symbols - maybe solution for Richard            01/01/70 00:00      
                                                   Humans have to understand it, too            01/01/70 00:00      
                                                Games are for kidz            01/01/70 00:00      
                                                   headstart            01/01/70 00:00      
                                                      still comparing grass straws            01/01/70 00:00      
                                                         you said it            01/01/70 00:00      
                                                            but you did not get it            01/01/70 00:00      
                                                               good joke            01/01/70 00:00      
                                                                  yet more extrapolations/flame baits            01/01/70 00:00      
                                          BEGIN and END            01/01/70 00:00      
                                             No .. I probably should have listened to Mom ...            01/01/70 00:00      
                                    Pascal            01/01/70 00:00      
      More than a language            01/01/70 00:00      
         some of this is language independent            01/01/70 00:00      
            I love standards            01/01/70 00:00      
               Igor recognizes this...            01/01/70 00:00      
         Answers applicable to Turbo51            01/01/70 00:00      
            don't call it IDE...            01/01/70 00:00      
               IDE vs editor            01/01/70 00:00      
                  DIY or gdb or?            01/01/70 00:00      
                     GDB?            01/01/70 00:00      
                     8051 IDE            01/01/70 00:00      
                        this one?            01/01/70 00:00      
   On T51            01/01/70 00:00      
      Some cooments            01/01/70 00:00      

Back to Subject List