Sie sind auf Seite 1von 8

MODULE 8: EXTENSIBILITY BEST PRACTICES

Module Overview
AX Retail POS (Point of Sales) is a .Net solution which is available as part of AX
Retail installation. The SDK will be available for the implementation team to
customize further as per the specific customers requirement. With the SDK we can
customize the POS services and Triggers only.
This document provides general guidelines on how to customize the Retail
solution and overall solution approach for the POS Retail part. As this is on .Net,
.Net specific coding guidelines will be applicable by default.

Objectives

Provide best practices and guidelines/standards for Retail POS


customization.

Microsoft Official Training Materials for Microsoft Dynamics


Your use of this content is subject to your current services agreement

8-1

Microsoft Dynamics AX 2012 R2 For Retail in Brick and Mortar Stores Development and Customization

Solution Approach
There are two primary approaches for POS customization. These are:
1.

Greenfield Development

2.

Brownfield Development

Greenfield Development
The Greenfield approach for adding customizations on POS is to implement the
customization in default interfaces provided by the plugins. Then Replace the
OOB DLL provided by the Retail POS installation with the custom DLL.
For example, in order to customize the Sales Order service, load the services
solution form the Retail POS SDK(By default the SDK path will be
C:\Users\...\Documents\Retail SDK\POS Plug-ins\) folder and extend it by adding
the new classes and methods within the same SalesOrder project.

Brownfield Development
In brownfield development style, partial classes are used to keep customized
code separate from the OOB plugins code.
The advantages of using partial classes is that

Customized code resides in a separate file rather than existing plugin


code file which help in code merging during the hotfix deployment
and we will have the clear separation of code between the
customization and OOB Retail SDK.

In future, if there are any upgrades or hot fixes release, developers


can make those changes to OOB Plugin code by comparing it with
the new updates in code, while customized code can be demarked
clearly

During operations lifecycle of the system, you can more easily find if
the issue belongs to OOB Plugin code or it is customized code

In all Retail implementation of AX, each customer will have a specific requirement
for authorizing credit card payments. To do that, developer will have to modify
the EFT class provided in the EFT Project. To incorporate this change, follow the
below steps:

8-2

Microsoft Official Training Materials for Microsoft Dynamics


Your use of this content is subject to your current services agreement

Module 8: Extensibility Best Practices


Create a new C# file
Taking the Credit card Payment Processing scenario, create a new file called
_EFT.cs in the EFT project, as shown in the figure below.

Modify the class declaration and namespace


In the new class file created,

Rename the class declaration to partial class; in the current scenario, it


will be public partial class EFT : IEFT

Rename the namespace to match the OOB class, which in the current
scenario, will be namespace EFT

Copy namespaces from OOB class, to the new class file

Implement new methods or comment the existing methods in the


OOB class and implement it as required in the new partial class.

In the OOB file class,

If the class is not partial class, rename the class declaration to partial;
in the current scenario, it will be public partial class EFT: IEFT

Source Code Control


Source code control gives you the benefits of versioning, tracking and reverting
back to earlier versions. If you are part of a team customizing POS, automated
source code control provides a significant advantage. When many people work
together to create, support, and update source code files for POS, the
coordination of files and updates is a complex process. Team Foundation Server
(TFS) provides stable, easy-to-use source code management to keep the team's
developers in sync with each other's changes.

Solution Configuration
When setting the solution in TFS, the delivery team must configure the complete
Services and Triggers solution in TFS. While configuring the Services or Triggers
solution, proper version of the AX Retail POS version must be chosen (AX 2012
R2)
From the Services or Triggers solution, the project specific solution must be
configured as a branch from the main application. By doing this, we are keeping
the original source code as is in the main solution and keep only the project
specific code in the branch

Microsoft Official Training Materials for Microsoft Dynamics


Your use of this content is subject to your current services agreement

8-3

Microsoft Dynamics AX 2012 R2 For Retail in Brick and Mortar Stores Development and Customization
The projects which we are not used for customization from the Retail SDK can be
removed from the TFS branch. In this way, the delivery team will be focused only
on the items they will be modifying and delivering to the customer. The solution
available in the branch should comply with the coding standards of .Net like
FxCop, StyleCop, VS Code analysis and Code metric standards. For detailed
information on these standards please refer the link in the reference section.

TFS for Version control .NET solution


Daily builds
Use Release version of the dlls for deploying to testing, Staging and Production
environments

Unit Testing
It is usually conducted by the development team. This testing is to verify and
validate that the individual units of source code are fit for use.
Considerations:

The ability of the system to properly process erroneous transactions

systems or components pass data and control correctly to one


another

Using Test Driven Development (TDD) developer can write unit test cases for
solution before actually writing that code. By writing a test and then writing the
code to make that test pass developers have a much better idea of what the goal
and purpose of the code is. Also, a TDD comprehensive suite of unit tests can be
run at any time to provide feedback that the software is still working. It improves
the quality of code and ensures total code coverage of custom code. The
developer can use Visual T#, NUnit, MS Test, xUnit or any other viable unit test
framework for TDD driven unit testing. For detailed information on the unit
testing please refer the link in the reference section

8-4

Microsoft Official Training Materials for Microsoft Dynamics


Your use of this content is subject to your current services agreement

Module 8: Extensibility Best Practices

Reference
Partial Classes and Methods (C# Programming Guide) http://msdn.microsoft.com/en-us/library/wa80x488(v=VS.100).aspx
AX for Retail: A Better Sample for EFT plug-in (Credit Card processing)
http://blogs.msdn.com/b/axsupport/archive/2012/01/14/ax-for-retail-a-bettersample-for-eft-plug-in-credit-card-processing.aspx
C# coding guidelines
http://msdn.microsoft.com/en-US/library/vstudio/ms229042(v=vs.100).aspx
Guidelines for Test-Driven Development
http://msdn.microsoft.com/en-us/library/aa730844(VS.80).aspx
Test Driven Development
http://msdn.microsoft.com/en-us/library/aa730844(v=vs.80).aspx
Visual Studio 2010: Test Driven Development
http://msdn.microsoft.com/en-us/gg454254
FxCop
http://msdn.microsoft.com/en-US/library/bb429476(v=vs.80).aspx
Code analysis
http://msdn.microsoft.com/en-us/library/3z0aeatx.aspx
StyleCop
http://archive.msdn.microsoft.com/sourceanalysis
Code Metrics:
http://msdn.microsoft.com/en-us/library/bb385914.aspx

Microsoft Official Training Materials for Microsoft Dynamics


Your use of this content is subject to your current services agreement

8-5

Microsoft Dynamics AX 2012 R2 For Retail in Brick and Mortar Stores Development and Customization

Module Review
Best Practice:
1.

Follow C# coding guidelines

2.

Follow FxCop and StyleCop standards

3.

Enable static code analysis in VS

4.

Follow the below code metrics:

Maintainability Index per method > 20

Cyclomatic Complexity per method <= 20

Class Coupling per class or type <= 20

Depth Of Inheritance per class or type <= 6

Lines of code per method <= 40

Test Your Knowledge


Test your knowledge with the following questions.

8-6

1.

What is Greenfield development

2.

What is Brownfield development

Microsoft Official Training Materials for Microsoft Dynamics


Your use of this content is subject to your current services agreement

Module 8: Extensibility Best Practices

Test Your Knowledge Solutions


MODEL ANSWER:
1.

In Greenfield approach all the customization is done in new classes or


projects and added as reference

2.

In Brownfield approach customizations are done in partial classes.

Microsoft Official Training Materials for Microsoft Dynamics


Your use of this content is subject to your current services agreement

8-7

Microsoft Dynamics AX 2012 R2 For Retail in Brick and Mortar Stores Development and Customization

8-8

Microsoft Official Training Materials for Microsoft Dynamics


Your use of this content is subject to your current services agreement

Das könnte Ihnen auch gefallen