Are you a software architect?
If you are a software architect, you expect developers implement the software with the layer architecture you have designed.
What happens today?
In the past you had to validate the code yourself, but now everything is changed. Fortunately, VS2010 provides an architecture tool which can check whether the code is in accordance with the layer architecture diagram.
Typical-Three-Layer Architecture & IOC Container Architecture.
During SharePoint development, we usually use two types of layer architectures. One is Typical-Three-Layer Architecture, the other is IOC Container Architecture.
The two architecture diagrams are as follows:
I recommend the IOC Container Architecture. If the system interface definition is ready, the Presentation Layer (PL) and the Business Logic Layer (BLL) can be developed together by Front SDE and Business SDE. In other words, one employee develops the UI and UI Logic, another employee develops the Business Logic, and when the PL and BLL are completed the development team can use the IOC Container framework to assemble the System Interface and the Domain Model. It will take low coupling. We can reuse the code and change the B/S architecture to C/S architecture or SOA freely.
How to use the layer diagram to validate the architecture.
Step1. Create the Layer diagram
Click [Architecture] menu button-> Click [ New Diagram… ] dropdown menu button. You will get the dialog as following:
Rename the diagram. Click OK button, a blank layer diagram is created.
Step2. Design your own Layer architecture
You can design the architecture in Layer diagram. Our IOC Container layer diagram is as follows:
Please pay attention to the numeral at top right corner, it indicates the number of assembly, you can drag the assembly from solution explorer to the layer figure. It is that easy. You can also explore the assemblies which are in a specific layer, click on the layer figure and you will see the assemblies in layer explorer.
Step3. Develop the product
Below is a short example of code.
PL:
Main method
Step4. Validate Architecture
Right click the layer diagram and click the [Validate Architecture] context menu.
Then validation will be executed automatically, see result below.
You can see the code is in accordance with the Layer architecture.
Let’s try to change the Main method as follows:
Now the PL will dependent on the DAL directly, therefore the code does not conform the layer architecture. When we validate the layer architecture, the result is:
As you can see, the tool is reporting the Invalid Dependency issue.
You are now able to validate the architecture with a Layer diagram of your own design, enjoy~