Best Practices for LAA Friendly Client Development

General

  1. Most latest tooldisk version should be used.
  2. Default (parameter-less constructor) constructor should not be removed.
  3. Default constructor (parameter-less constructor) logic should not be changed unless essential. Initialization logic should be written in overridden OnPamCreate() instead.

 

Avoiding Inheritance issues

Using Access Modifiers

  1. For controls added via Visual Studio Toolbox, access modifier should be manually changed from "private" to "protected" for them to be visible in the extended layers.
  2. For controls added via Dataset Toolbox, access modifier is automatically set to "protected".

  3. Methods should be made "public virtual" or "protected virtual" for them to be accessible and overridden in the extended layers. (If not it is detected by APF Refactoring tool).
  4. If an instance variable needs to be declared "private" or "internal" it should reside inside "KeepPrivate" region. Note that "KeepPrivate" region is applicable only for variables and not for methods.
  5. If an instance variable should be made possible to extend by the extended layers one of the below actions should be followed.
    1. Make the variable public, protected or protected internal.
    2. Expose the variable as a property with a get and set method. You can avoid extended layers from modifying the variable and only retain the possibility of reading it by declaring only a getter and not a setter.

    * Note that variables that do not have any access modifier are considered as private variables and hence they need to be made public, protected or protected internal. Make sure that there are no instance variables without any access modifier specified.

     

  6. Resources defined in your visual studio project should be "public" for them to be used by extended layers. VS projects made with latest APF development tooldisks will have the access modifier already as public. In case there are private resources make sure to set the access modifier to public.

Using controls that do not support visual inheritance

Avoid using controls that do not support visual inheritance if the form is intended to be customized. The reason is that these controls in the extended form are always read-only regardless of the access modifiers you use.

Following controls do not support visual inheritance.

  1. TableLayoutPanel
  2. FlowLayoutPanel
  3. WebBrowser
  4. ToolStrip
  5. ToolStripPanel
  6. DataGridView

KeepPrivate region

Access Modifier option in the APF Refactoring tool will report private variables as a help for developers to identify them and make them "protected" or public". But in case developer decide a variable should actually be "private" and extended layers should not access it, he can move the variable to KeepPrivate region. APF Refactoring tool will ignore scanning variables residing inside KeepPrivate region. Note that "KeepPrivate" region is applicable only for variables and not for methods. Further note that even if the variable is private the access modifier has to be explicitly defined for the variables residing inside the "KeepPrivate" region.

Ex:

#region KeepPrivate
    private SalArray<SalString> sRecords = new SalArray<SalString>();
#endregion
public SalArray<SalString> Records
{
    get { return sRecords; }
    set { sRecords = value; }
}

Avoiding Navigation issues

  1. When form names and names of child tables are used in the code consider using "Pal.GetActiveInstanceName" in order to fetch the extended form name at runtime. (If not it is detected by APF Refactoring tool)
  2. If you find a piece of code with a form name where it does not need to fetch the extended version of the form at runtime it should be annotated with //APFRefactoringTool.IgnoreNavigationScan in order to avoid them get reported by APF Refactoring tool.
  3. When using picTab control never use form name as the tab’s ‘Name’ property.

     

Using Pal.GetActiveInstanceName

In certain cases where form names and names of child tables are used it may require to fetch the extended form name at runtime. In such scenarios the form name must be used with "Pal.GetActiveInstanceName"

SessionNavigate(Pal.GetActiveInstanceName("tbwAccountOverview"));

if (Ifs.Fnd.ApplicationForms.Int.QualifiedItemNameGet(this.hWndOwner) == Pal.GetActiveInstanceName("frmAllocationPartDetails")+".tblPartDetails")

Some methods still expect the core version of the form name. Some of such methods are skipped in APF Refactoring tool when adding "Pal.GetActiveInstanceName".Ex: picTab.TabControl.TabPages.ContainsKey, picTab.FindName.

IgnoreNavigationScan annotation

There could still be scenarios where a form name is made to use through Pal.GetActiveInstanceName by the refactoring tool but should not be used as such. Given that the particular scenario cannot be detected by the APF refactoring tool in a generic way you can prefix the relevant line with "//APFRefactoringTool.IgnoreNavigationScan". The line immediately next to this comment will not be scanned under navigation option in the APF Refactoring tool.

//APFRefactoringTool.IgnoreNavigationScan
picTab.TabSetup = picTab.TabSetup.Replace("tbwInquirySupplier", "frmInquirySupplierActivities");