I had to do something like this a few years ago to add a digital signature to a message in XML format. If I remember correctly you have to get your object into a %XML.Document which works in conjunction with %XML.Node. %XML.Node is used to traverse the %XML.Document to get to the section you want in canonical form. Then you pass the Node to ##class(%XML.Writer).Canonicalize(Node) to get the XML as a string which is then passed to the encryption function you use to get your digest/signature. You can pass the whole document or just a subsection to the canonicalize function.

I can't say if it's the only or best way to do it but it was sufficiently quick enough to handle thousands of messages per minute.

Discourage the use of hard coded breaks in the first place! There are alternatives.

  • Use ZBREAK Tag+OffSet^Routine to set a break point just for the current process
  • Use the debugger in Cache´ Studio (under the Debug menu and attach to a process)
  • George James has a decent debugger in Serenjii
  • Put something in your processes to remove hard coded break points when you promote code through the development cycle (you can automate this if you try)

I've seen some places where the ^ROUTINE global is fully or partially deleted after compilation. I suspect that the same would work for ^rMAC or ^oddDEF - you'd have to test it. One company that I'm aware of encrypts the ^ROUTINE global after compilation which has the added "benefit" of making it extra difficult to debug errors! If you really want to hide your code you could compile the code on an identical system and then just deploy the object code.

Nice generation of a pandigital number with 1e20/17.

Can save a character with $zpi_0

ClassMethod Order(As %String) As %String
{
 r=i=1:1:5e5{s=$p(a," ",i),w=$tr(s,$zpi_0),$p(r," ",$tr(s,w))=wr
}

This was mine also at 78:

ClassMethod Order(As %String) As %String
{
 i=1:1 s=$p(a," ",i),n=$zstrip(s,"*a"),$p(z," ",n)=$tr(s,n) ret:'$g(z)
}
 

And if you find the job is starting (from evidence provided by $T and $ZCHILD) then ensure you have an error trap in your class to catch why it's falling over. At the very least make it Set ^tempGlo($H)=$ZE or DO ^%ET when it encounters an error.

If you can't edit the class for any reason then JOB a routine that you can edit and make that call your class after setting up an error trap.

#1) Why did you choose to become a software engineer / developer?

I was at University when introduced to COBOL. Found it really easy and natural while my friends appeared to struggle. Some of them offered to pay me to write their coursework. The first program I sold was to the nephew of the manager of a Scottish pop group (The Bay City Rollers). He gave me a 3 month supply of potatoes for one program! When I found I could make an easy living writing code there was no looking back. (And I haven't been paid in potatoes since I was a student)

#2) How and when did you start to generate a "flow state of mind" during your career?

We were taught Jackson Structured Programming at Uni. A short time drawing on a large sheet of paper how a program should flow works wonders for getting it right first time. (Right first time saves money). If you start off as you mean to go on it very quickly becomes the natural way to do things. I don't use JSP now but its basic principles are the basis for how my programming mind thinks. I'd say you should pick a programming methodology and stick to it until you are competent. As @Robert Cemper said, learn your language fluently.
 

#3)What are recommended habits inside and outside, during you own time and during
your work time, to be focused during your coding session and daily tasks?

Write re-useable code that can be called to do small or big repetitive tasks.

Don't try to write anything that is all things to all people. If you write code well then it should be easy to add new functionality.

When you are happy that your code is doing the job, don't seek the approval of someone with a big ego - they will try to make you re-write it. And related to this, if someone else writes code that works yet you don't understand it realise that it's your time to learn, don't try to make them change it.

Comment your code then go back and re-read it the next day. If it doesn't make sense to you then it won't make sense to anyone else. Write the gist of a program at the top of the code.

Your code is going to have your name on it for years. Make it a good advert for your skills.

If you find something repetitive and/or annoying, automate it. It might cost you a couple of hours in the short term but in the long term it will save you years.

Don't allow yourself to be distracted by valueless tripe while at work (eg social media)

Find a way to make things fun and enjoy yourself.

Here's my answer. Looks like I'm playing on my own. 242 Chars, not including comments.

/// For rules see https://community.intersystems.com/post/code-golf-zcvtstr-leet
/// Build a list where each letter that is to be replaced
/// is followed in the list by its two possible replacements.
/// The next piece indicates which was the last replacement used.
/// Note: Only uppercase letters are in the list so need to
/// translate before searching, using $ZU(28,L,5) to translate.
/// For each character in the input string find its list position.
/// Use $LISTFIND to find its position.
/// Test the position found with Position-1#4
/// Not found characters return 0, and 0-1#4 is non zero so do nothing with them
/// Positions 1,5,9,11,15,19,23,27,31,35,39,43, and 47 contain characters
/// that must be replaced. Position-1#4 is zero for these.
/// No test case or rule for any of the destination symbols already existing in
/// the input string. Introducing that will complicate things as would need to test
/// character before and after current one to try to avoid double letters.
/// When each character is found change the last used replacement indicator.
/// Then return the replacement characters.
/// If the replacement characters contained any of the replaceable characters
/// then you would have to work backwards from the end of the input string
/// to avoid getting in a loop. This would cost 1 character.
ClassMethod Convert(As %String) As %String
{
A=$lfs("A,4,@,,B,|3,8,,C,(,<,,E,3,€,,G,9,6,,I,|,],,K,|<,|{,,L,1,£,,O,0,*,,S,5,$,,T,7,+,,X,><,}{,,Z,2,~/_")
i=1:1:$l(x){$E(x,i)=$$r($e(x,i))x
r(L)P=$lf(A,$zu(28,L,5)) q:P-1#4 $LI(A,P+3)='$LG(A,P+3) $LI(A,P+2-$LG(A,P+3))
}

I've got an answer in 242 characters but I think there's a mistake in the test case:

Do $$$AssertEquals(##class(CodeGolf.Leet).Convert("no no no no "), "n0 n* n0 n*")

Do $$$AssertEquals(##class(CodeGolf.Leet).Convert("Iris"), "|R]5")

The "n" doesn't get converted to uppercase but the "r" does. Surely it should be

Do $$$AssertEquals(##class(CodeGolf.Leet).Convert("Iris"), "|r]5")

and there's a rogue space at the end of "no no no no ".

185 - with an unusual use of $PIECE instead of $SELECT to save 2 characters, which would also shorten yours to 184

c=",",x=$p(a,c,$i(i)) q:x="" f{y=$p(a,c,$i(j)+i),g=$g(g,y-x) q:j*g+x'=y  l="-"_yg=$zabs(g),$p(o,c,$i(p))=s:2-'g<o=o_$s(g:l_$p("/"_g,c,g>1),1:"*"_j),i=i+j-1 g,1

i=1:1:2e6{x=",",a=$p(s,x,i),d=$p(s,x,i+1)-c=1:1{q:d*c+a'=$p(s,x,i+c)q=$zabs(d),v=$s(c>2&d:"-"_(c-1*d+a)_$p("/"_q,x,q>1),c>1&'d:"*"_c,1:0) s:v'=0 $p(s,x,i,i+c-1)=a_vs

Hi Vitaliy,

Out of curiosity I had a go at this. I can't get under 188 using my own ideas and code:

c=",",x=$p(a,c,$i(i)) q:x="" f{y=$p(a,c,$i(j)+i),g=$g(g,y-x) q:j*g+x'=y  l=yg=$zabs(g),$p(o,c,$i(p))=s:2-'g<j o=o_$s(g:"-"_l_$s(g>1:"/"_g,1:""),1:"*"_j),i=i+j-1g,1

You could shave 2 characters off each of your versions by having a variable contain the comma:

x=",",a=$p(s,x,$i(i)),d=$p(s,x,i+1)-c=1:1{q:d*c+a'=$p(s,x,i+c)q=$zabs(d),v=$s(c>2&d:"-"_(c-1*d+a)_$s(q=1:"",1:"/"_q),c>1&'d:"*"_c,1:0) s:v'=0 $p(s,x,i,i+c-1)=a_q:a="" a

I should pay more attention to the $$$MACROs in future!

$ZU(28 is great, it's a shame that Intersystems don't document enough $ZU functions?

The FOR loops that range from 0 to 90/91 don't work with anagrams that contain different numbers of spaces because i=32 checks spaces. E.g. w ##class(CodeGolf.Anagram).Detector("New York Times","monkeys write")

Ah! I stand corrected. Just read %SYSTEM.Util  ALPHAUP removes spaces!

Here is the code for a 69 character answer

/// 73 characters:
/// f x=a,b{f i=65:1:90{s $li(x(x),i)=$l($zcvt(x,"u"),$c(i))}} q x(a)=x(b)
/// 
/// but this one is 69:
/// 
/// loop ascii number from "A" to "Z" and "[", that's 65 to 91
/// if count of each letter in each string is different then quit loop
/// if loop reached 91 then loop completed and letter counts must be same in both strings
/// if loop didn't reach 91 then must be counts must be different
ClassMethod Detector(As %String, As %String) As %Boolean
{
 i=65:1:91{q:$$r(a)'=$$r(b)i=91
r(x)$l($zcvt(x,"u"),$c(i))
}