Marking overridden logic with snippets

With the new LAA Code Layer approach, developers can override or overtake core logic in derived classes (forms table windows dialog windows etc.). With this, the requirement arises to locate and compare overridden or overtaken logic. This is especially vital when applying IFS Application Updates. To do this analysis and to aid application of R&D updates, a new tool, IFS Update Analyzer will be introduced with IFS Applications 9. This tool is capable of analyzing the code base and finding any conflicts between customizations and core corrections. In order for the tool to work, client logic must be properly annotated with override or overtake marker snippets. The Update Analyzer will be made available in F1 Tools (IFS internal) prior to the release of IFS Applications Update 1

Snippet concept is a way of documenting what the developer had done i.e. snippet concept will not affect c# logic written and developers won't get any compilation errors or runtime errors if snippets are missing or added in an improper way. Currently these override and overtake marker snippets will only be used by the Update Analyzer to find possible conflicts in parent and customized logic.

Contents

 

Locating the snippets

This section describes how to locate the snippets in visual studio and add the relevant snippet to your code. Make sure you have latest APF tools installed.

Procedure:

Mark the code section by selecting the code, then RMB and select -> Surround With -> My Code Snippets -> IFS-APF -> LAA Overide marker snippet or LAA Overtake marker snippet as required.

How should I mark?

Developer should mark all overridden and overtaken methods using snippets. This includes all methods having Override keyword and also event handler implementations that already have implementations in parent layers. Good rule of thumb is to see if core logic change in a method can break customization logic in the corresponding method in customization layer. If the answer is yes, you should mark the method with snippets using the signature of the core method. Please refer to special cases section to see some additional scenarios that the developer might have to consider.

Marking a method

Lets think that a developer had overridden a method called ConstructName in his code and after the implementation, looks as follows:

public override SalString ConstructName(SalString sFirstName, SalString sMiddleName, SalString sLastName)
{
   string name = base.ConstructName(sFirstName, sMiddleName, sLastName);
   return string.Join(" ", name.Split(new char[] { ' '}, StringSplitOptions.RemoveEmptyEntries).Reverse());
}

Notice that above method have a call to its base implementation! Thus developer should mark this method using LAA Override marker snippet as follows:

#region Override: public virtual SalString ConstructName(SalString sFirstName, SalString sMiddleName, SalString sLastName)
public override SalString ConstructName(SalString sFirstName, SalString sMiddleName, SalString sLastName)
{
   string name = base.ConstructName(sFirstName, sMiddleName, sLastName);
   return string.Join(" ", name.Split(new char[] { ' '}, StringSplitOptions.RemoveEmptyEntries).Reverse());
}
#endregion

After adding the snippet, as in above, developer should add entire method signature appeared in the base implementation (available in parent layer) after #region Override:. If the new method doesn't have a call to its base implementation, care should be taken to mark it with LAA Overtake marker snippet instead.

Marking an event handler implementation

Lets assume that a developer had added a event handler implementation for cmdUpdatedCompany_Execute (Added using command manager and already available in parent layer) as follows:

private void cmdUpdatedCompany_Execute(object sender, Fnd.Windows.Forms.FndCommandExecuteEventArgs e)
{
   e.Handled = true;
   MessageBox.Show("frmCompany_Cust: cmdUpdatedCompany_Execute");
}

Notice that in the event handler implementation, the e.Handled property is set to true indicating that the chain of event handling is broken. I.e. after calling cmdUpdatedCompany_Execute, .Net framework will not execute base implementation of this event. So this is an overtake and the code should be marked with LAA Overtake marker snippet as follows:

#region Overtake: cmdUpdatedCompany_Execute(object sender, Fnd.Windows.Forms.FndCommandExecuteEventArgs e)
private void cmdUpdatedCompany_Execute(object sender, Fnd.Windows.Forms.FndCommandExecuteEventArgs e)
{
   e.Handled = true;
   MessageBox.Show("frmCompany_Cust: cmdUpdatedCompany_Execute");
}
#endregion

After adding the method, as in above, signature of the base event handler implementation should be added after #region Overtake:. Also keep in mind to use LAA Override marker snippet in case the e.Handled property is not set.

Special cases

There could be scenarios where sometimes developers need to add snippets always and cases where developers don't need to do so. Those scenarios are discussed here.

Massage handling

When catching massages and implementing a massage handling method, it is best to always use snippets. If the parent class don't have an implementation, put the name of the method that should appear if standards are followed in R&D code. This is because there is a slight chance where in future, R&D catches the message and add the method. If that happens, Update Analyzer may fail to find any conflicts. Refer following example where logic resides in a form called frmAbc_Ext which inherits Core form frmAbc.

#region Override: private void frmAbc_OnPM_DataRecordRemove(object sender, WindowActionsEventArgs e)
private void frmAbc_Ext_OnPM_DataRecordRemove(object sender, WindowActionsEventArgs e)
{
   e.Handled = true;
   //Some localized code
   e.Return = Sal.SendClassMessage(Ifs.Fnd.ApplicationForms.Const.PM_DataRecordRemove, Sys.wParam, Sys.lParam);
}
#endregion

In above example, assume that the parent form frmAbc is not catching PM_DataRecordRemove message. Still it is best to add the snippet by guessing what will be the signature according to standards. In this case, it is private void frmAbc_OnPM_DataRecordRemove(object sender, WindowActionsEventArgs e)

Another important thing here to note is that the developer is not required to add marker snippets to the <form name>_WindowActions method, as it is only there to dispatch the message handling logic to appropriate handler method. However bad code constructions can lead to functionality related logic inside <form name>_WindowActions method in core form. In that case, the best way forward is to report the problem to R&D and correcting it before continue.