Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Code "taste", coding guidelines, and revision control systems

by afoken (Chancellor)
on Sep 16, 2016 at 21:24 UTC ( #1171965=perlmeditation: print w/replies, xml ) Need Help??

(Just thinking out lout a little bit more after writing Re: Starting a New Script ...)

A long time ago, in a galaxy company far, far away ...

Co-worker IH asks: "Who wrote this code?"

Me: "Hmm, definitively not me. And far too structured to be written by HK."

IH: "Yes, I agree. Looking at the names of the identifiers hints at DF, or maybe JF during his first months [when he learned from DF]. It's full of three letter acronyms."

Me: "But JF would have added at least some comments. There is not a single comment, and not a single bit of code that's not absolutely required. Tight, but elegant. DF?"

IH: "Yes, definitely DF. But what does it do?"

Me: "Well, let's start analysing it ..."

And of course, we were right. DF wrote the code, and nobody else touched it after that. Just for fun, we tried that with other pieces of code the team members wrote over the years, and we were often right. We could even guess who wrote the original code, and who changed it later.

When we later explained our little game and its origin to non-IT people, we compared it to wine tasting, and to guessing an author from a piece of text.

In the next episode, same galaxy company, but a different team:

JF, a hardly ever swearing co-worker, asks: "What the *BEEP*? Which *BEEP* *BEEP* has written this *BEEP* *BEEP* *BEEP* piece of code?"

Me: "Show me."

JF: "Here you are."

Me: "Argh! Get it off my screen. It hurts my eyes! It hurts my brain! Get it off! GET IT OFF!"

Me, after wiping off some tears: "Well, it roughly looks like code generated by $StupidMouseClickingCodeGenerator. But why the heck did the author use that *BEEP* tool? It's completely useless here! We are on a completely different target system!"

JF: "If your only tool is a hammer, every problem looks like a nail. Some clueless worker from the client?"

Me: "Nope, the client does not access that part of the code. It's part of our setup routine. And the client would use tools for the right target."

JF: "So AG?"

Me: "Yes, definitely AG. Who else would use a hammer for a brain surgery?"

JF: "AG definitively needs to learn $ComputerLanguage."

Me: "And our system. It's three months, and still AG has absolutely no clue of what happens here. You will tell AG. I can't do that without insults and swearing."

And of course, we were right again.

Using revision control systems makes the guessing game a lot less interesting (svn log, svn blame), and using strict coding rules and code templates generates more uniform code across the team.

But still then, without looking at the logs, you can see differences in the way team members write code. And you can often identify who wrote a piece of code: "Soft factors" like the length and complexity of subroutines, naming of identifiers, style of the embedded documentation (POD, doxygen), systematic spelling errors in identifiers and documentation, preferred algorithms, and so on.


Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

Replies are listed 'Best First'.
Re: Code "taste", coding guidelines, and revision control systems
by LanX (Saint) on Sep 16, 2016 at 21:36 UTC
    Yes and I think Perl's TIMTOWTDI makes it even easier.

    My employer prefers multi line strings, my coworker prefers qq constructs with ~ delimiters and I heredocs with content defining delimiters like __HTML__

    And all of us should use a template system... ;)

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Je suis Charlie!

Re: Code "taste", coding guidelines, and revision control systems
by wjw (Priest) on Sep 16, 2016 at 23:03 UTC
    I am so glad that I am in a situation where the only code I work on is my own anymore. I no longer need to BLEEP anyone but myself, which I still do now and again. Git, comments in code and the KISS principle keep me sane.

    I remind myself of Martelli in the old serial TV show about those kids in that New York art school (can't recall the title of the show right now). There was a scene where Martelli was playing an entire symphony on his synthesizer to show the old heavily accented orchestra director why Martelli thought learning to play the violin was a complete and utter waste of time.

    The old director said to the young artist:

    "Martelli, that is not music! It is masturbation!"

    Well, perhaps my Perl code is not music ... LMAO (at myself)

    ...the majority is always wrong, and always the last to know about it...

    A solution is nothing more than a clearly stated problem...

        Aha! Yes. Thank you.

        ...the majority is always wrong, and always the last to know about it...

        A solution is nothing more than a clearly stated problem...

      The old director said to the young artist: "Martelli, that is not music! It is masturbation!"

      As I remember that quote, it was "Martelli, that is not music! It is pseudo-intellectual masturbation!"

Re: Code "taste", coding guidelines, and revision control systems
by Discipulus (Canon) on Sep 16, 2016 at 22:45 UTC
    and you was so kind to not mention that, when you open perlmonks and you see &sub you feel the smell of the BasiliconValley :=)


    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlmeditation [id://1171965]
Approved by Discipulus
Front-paged by Discipulus
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2023-12-10 09:54 GMT
Find Nodes?
    Voting Booth?
    What's your preferred 'use VERSION' for new CPAN modules in 2023?

    Results (39 votes). Check out past polls.