Saturday, September 22, 2012

Layered Architecture Solution Guidance (LASG)

Ever think of how nice if there is a tool that able to generate code for you and shorten the application development time? Have you ever notice that when you create an application, there are a lot of code are repetitive in term of pattern (not design pattern) and the way it execute? For example pulling data and manipulating data from DB with ADO.net. Normally you would write the same style or pattern of code but what it actually does is getting the data from DB then store in different variables.

Here is the tool to generate the code for you: Layered Architecture Solution Guidance (LASG).
It is created by my mentor, Serena Yeoh (firedancer).
Download for Visual Studio 2010
Download for Visual Studio 2012

Note:
Some prerequisite components are needed to be installed first in order to install LASG.
1. Enterprise Library 5
2. Open GAX (for Visual Studio 2012)
3. GAX 2010 (for Visual Studio 2010)

Actually, the tool itself is not only meant for code automation, its main purpose is to guide developer to create application with proper and correct layering design. When you start using the tool and then create a new project with LASG template, you will see multiple projects will be created automatically and they are nicely structured into different folders which follow the layering design.
Logical Component Architecture
Physical Deployment Architecture


After installing the tool, how to use the tool?

Create a new project, then look for Guidance Packages installed template.

 

Then, enter your project namespace, then select the project type that you wish to create from the preset templates. Each template have different sets of projects to be created. The checkboxes indicate the projects that will be automatically created after you hit the OK button. Unfortunately, there has no icon or detail show in the UI saying what kind of project type is that. So, here are the details:
- When you see "Web" keyword mean ASP.net Web Forms
- "WinForm" of course is Windows Forms
- "Workflow" of course is Workflow
- "Database" of course is Database
- "Services" and "Contracts" mean WCF
- "Entities", "Process", "Data", "Framework" are Class Library
- "Test" is a Unit Test




After the projects are created, Follow the steps below:

I am not going to share the details on how to do it here. Instead, I will provide you the available link.

Step 1: Generate Business Entities
Step 2: Generate Data Access Components
Step 3: Generate Business Components
Step 4: Generate Services
Step 5: Generate Workflow Activities (optional if you do not have a workflow project)
Step 6: Generate UI Controllers

The steps without documentation require you to explore by yourself. It is not hard to use anyway.

The most interesting part to me is the auto generated code. You can do the code preview first before generate it into code file. And also, the tool automatically keep track which code had been generated before. If you go back to the tool and do some adding or removing, then regenerate the code, it actually give you an option to append or rewrite the code file.

There is one more new feature with this tool is if you happen to have your project namespace is similar to what LASG created, for example project name end with suffix "Data", "Business", "Entities", etc. You actually can enable the tool attach to your project without the need to recreate a new project with LASG template.

What you need to do is just go to the top menu, click at Tools then select Guidance Package Manager. Then, you will see the window as follow:



Then, click at the Enable / Disable Packages... button at the bottom left of the window.


Check the Layered Architecture Solution Guidance 2012 checkbox, then hit the OK button.

You will see the LASG tool menu appear after you right click at your project in the Solution Explorer.

For some reasons, you do not want LASG to attach to your project, you can do the same way, but uncheck the Layered Architecture Solution Guidance 2012 checkbox.


If you like this tool, feel free to like this facebook fan page, so if there is any new update about the tool, it will be shown in your facebook news feed.


Source and credits:
http://serena-yeoh.blogspot.com/
http://layersample.codeplex.com/
http://cloudsample.codeplex.com/
http://visualstudiogallery.msdn.microsoft.com/2dc87fb2-d6f2-4151-9dab-faad717eea41
http://visualstudiogallery.msdn.microsoft.com/c8c473b5-21a1-447a-8b24-33b43411ee7f
https://www.facebook.com/layersample#!/layersample

 

No comments:

Post a Comment

Send Transactional SMS with API

This post cover how to send transactional SMS using the Alibaba Cloud Short Message Service API. Transactional SMS usually come with One Tim...