mercredi 28 août 2019

What is the correct way of structuring this block of repetitive code?

In my job my colleague and I spend a lot of time automating SAP processes through the SAP GUI. This involves a lot of repetitive code with almost no difference between the lines. This code is impossible or pointless to unit test, and I believe that it should not be in the code itself but in a separate XML/other storage file.

One issue that my colleague raised was that storing this as XML would make it a bit tedious to work with this code. He prefers that we keep these interactions inside the code and that moving it outside would introduce unnecessary complexity. I can understand his point but it just doesn't look right to me.

'basic example 
 Public Sub TCODE()
        setText("TXT1","00000")
        press("BTN1")
        setText("TXT2","99999")
        setText("TXT3","Desc")
        setText("TXT4","B")
        setText("TXT5","A")
        press("BTN2")
        press("BTN3")
        press("BTN4")
        .....more of the same....
End Sub

I would like somehow to take these repetitive actions out of the code and into a separate file. This would allow the code to keep the logical functionality, and the all these routine instructions would be stored separately. This would separate issues with the code from issues with instructions list.

Are there any better solutions to this problem than these two? If someone could help identify pros and cons of each approach and/or suggest improvements I would appreciate that a lot. Both of us are junior software developers and haven't dealt with issues like these previously.

Aucun commentaire:

Enregistrer un commentaire