Better references

Better references

We have developed some rules around ESQL references to make using them easier for developers.


R15 - Navigating message tree could be replaced by a reference (2 lines) (WMB)

R356 - ESQL REFERENCE TO variables should end with 'ref' (WMB)

R357 - ESQL REFERENCE TO variables should start with 'ref' (WMB)

R433 - Navigating message tree could be replaced by a reference (multiple lines) (WMB)


We have added some new ones for working with references to message trees.

The first one is where a DETACH is being called essentially without an accompanying ATTACH.

R447 - DETACH is last line of function. Could be replaced with a DELETE (WMB)


From the IBM documentation, a DETACH statement detaches a portion of a message tree without deleting it. A DELETE statement detaches and destroys a portion of a message tree, allowing its memory to be reused (resources to be recovered).

Having a DETACH as the last line of a function indicates that either you really do want to remove an element from a message tree by detaching it and you are not wanting to re-attach it later.

The suggestion here is to use a DELETE instead, so that the intention is clearer and also allows the runtime to recover resources (memory) that was consumed by the message.

It could also indicate a bug, where you have detached a section of the message and you intended to re-attach but have missed that step.?

So you are removing something from the tree that should be moved to another location in the tree.

Both situations suggest taking a closer look at the particular piece of code.


When developing ESQL code, one pattern that I have seen by some teams is that they try to keep logical operations together, so that it easier for developers to understand the code.

For example you might want to keep all file open and close operations in the same file and ideally be visible on the same page (if you were in Java, C# or Python for a more common example).


In this case here we are keeping the DETACH and ATTACH as close together as they can be (on the same line):

DETACH rCur;ATTACH rCur TO rEqual AS LASTCHILD;


So to help our developers and encourage this practice, we implemented this as a check:

R448 - Mismatch between DETACH and ATTACH reference (WMB)


But to help ensure that the DETACH and ATTACH make sense, we are looking to make sure that the same reference is ATTACH-ED as was DETACH-ED.

That way that you are less likely to ATTACH incorrect data, or forget to ATTACH the appropriate data (essentially deleting the data from the message using the DETACH rather then DELETE).


Yes, this will be incompatible with:

R47 - Multiple statements on the same line (WMB)


So we created a separate rule that complements the multiple statements issue.

R449 - Multiple statements on the same line (ignore DETACH / ATTACH) (WMB)


More information on our products and on pricing can be found on our website:

https://bettercodingtools.com


You can also reach me via email at:

[email protected]


Or contact me via the contact page on our website:

www.bettercodingtools.com/contact


Regards

Richard

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

Richard Huegill的更多文章

  • 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…

  • Uncle Ben and ACE

    Uncle Ben and ACE

    As organizations interact more and more with the public cloud (AWS, GCP, Azure) or software as a service (SaaS)…

  • Don't double up

    Don't double up

    I'd like to thank Ahmed Samy for re-highlighting some of the IIB/ACE/WMB best practices published by IBM. He published…

社区洞察

其他会员也浏览了