Three types of programmers that I know of

Three types of programmers that I know of

I'm not sure how many types of programmers there are.


I used to work with a guy that believed that the only real programming language was assembly.

1) so we have those that believe its assembly or nothing.

I don't want to condone violence, specially against someone for something that in the grand scheme of things really is just a job.

But I did work with a guy that believed that anyone that didn't write test cases should be lined up against a wall and shot.

2) those that write tests case and those that don't.

And then we get to the crux of this post.

3) those who use constants and those that don't.

I think most developers would agree constants are good and help make the code more understandable. Of course that's not the same as saying everyone uses them.

We already have a rule that suggests that you need to convert "magic strings" into constants. We call it a "hard coded mapping". But in essence we are looking for strings that could be constants.

This means that we can help developers work out which pieces of code should be made into constants.

But then like anything, you can take it to far. 

I came across code like this the other day - in 3 different files:

DECLARE AUSTRALIA CONSTANT CHAR 'AUSTRALIA'; 

...

DECLARE CNTRY_AUSTRALIA CONSTANT CHAR 'AUSTRALIA'; 

.....

DECLARE COUNTRY_AUS CONSTANT CHAR 'AUSTRALIA'; 


So, if you declare something as a constant, and you have a constant for the same value 3 times, by definition, is it still a constant ?

Maybe. But I think it should fit the definition of confusing.

So we added a new rule. 

R361 – An ESQL CONSTANT with that value is already declared (WMB)

It's like code duplication checking but at a string level.

So I know next time I declare a constant in my code, I think i'll go searching for it with NotePad++ first. Just not to fall into the same trap. So hopefully someone next year isn't writing a LinkedIn post about me - or at least my code.


If you are interested in finding out more about our product or were interested in a demonstration, please drop me an email to:

[email protected]


Or contact me via the contact page on our website.

Regards

Richard

[email protected]

www.bettercodingtools.com

要查看或添加评论,请登录

Richard Huegill的更多文章

  • Opaque parsing and performance

    Opaque parsing and performance

    A while back I was asked what our tooling could do to help improve performance for ACE/IIB code. Whether that means…

    2 条评论
  • Embedding DrawIO IIB/WMB/ACE flow diagrams in Confluence

    Embedding DrawIO IIB/WMB/ACE flow diagrams in Confluence

    Happy New Year My last demonstration was all the way back in time, 2024, almost 3 months and 4 hangovers ago. Or 3…

  • Apologies for the broken webinar

    Apologies for the broken webinar

    So last week we attempted to do a webinar on creating Confluence pages to summarize WMB/IIB/ACE code. Unfortunately…

  • Something I don't know too much about

    Something I don't know too much about

    It's ACE and Java classLoader's (but I'm sure friends will be able to point out many others). Actually this is only…

  • Confluence page generation for IIB/WMB/ACE applications

    Confluence page generation for IIB/WMB/ACE applications

    The larger an organization becomes, the more challenging that it is for an organization to manage is combined knowledge…

    2 条评论
  • WMB / IIB / ACE GitLab pages (with sound this time)

    WMB / IIB / ACE GitLab pages (with sound this time)

    The recent version 17 release of GitLab has added GitLab pages. Last week we did a live demo on using GitLab Pages to…

    2 条评论
  • GitLab Pages and IIB

    GitLab Pages and IIB

    The recent version 17 release of GitLab has added some enhancements and fixed some issues. On the of the newer features…

  • SonarQube 10.6 released

    SonarQube 10.6 released

    SonarSource recently a new version of their Sonarqube platform - SonarQube 10.6 For us, we have to update some of build…

  • Squid's (not the game)

    Squid's (not the game)

    When I develop code, I have never gotten it write first time. This is compounded when you work integration tooling.

  • Information radiators for IIB/ACE/WMB projects managed in GitLab

    Information radiators for IIB/ACE/WMB projects managed in GitLab

    Some of the functionality that we have in our plugin is more the "art" side of software engineering then the hard…

社区洞察