YOUR FEEDBACK
AMD Wants To Depose 486 People in Intel Case
AMD News Desk wrote: Contrary to what you may have read elsewhere, AMD has...

SYS-CON.TV
TOP MICROSOFT .NET LINKS


Mercado Eletrônico Case Study
Migrating from ASP/COM to .NET using Spring.NET

Digg This!

Page 1 of 2   next page »

Mercado Eletrônico is the leading B2B company in Latin America. Founded in 1994, it provides services for supply chain management, such as e-procurement, catalog, sourcing and collaboration, based on an advanced technology platform supporting more than 30,000 transactions a day and a complex buyer/supplier user community.

The development of Mercado Eletrônico's technology platform started in 1994 using BBS software, which evolved to client/server and, in 1998, to the Web using Microsoft Active Server Pages. In 2005, with an accumulated two million lines of code ranging from stored procedures to AJAX interfaces, most of the code was complex and hard to maintain IDL/COM+ transactional components, implemented in a mix of Visual C++, Borland Delphi, and C#, and used by classic ASP and ASP.NET pages directly.

When .NET 2.0 was released, it was made the primary target for the new technology platform. It offered a great base library and excellent language support. As such, it was a natural choice since most of our code was already Windows-based. However, many years of watching and learning from the advances made in the Java community showed that application frameworks could make development simpler, faster, and easier to test compared to using the base libraries directly. Enter Spring.NET.

Architecture
Mercado Eletrônico's architecture follows a traditional layered design as shown in the diagram in Figure 1.

Previous architectures started out with the same good intentions of having cleanly separated layers, but in practice the enforcement of this fundamental architectural principal broke down. No matter how hard we tried to keep our less experienced developers from mixing together data access, business logic, and user interface code, they couldn't resist the temptation to add references that would cross layers, e.g., database-specific code inside the business logic layer. The lack of a component in the architecture to help ensure proper isolation from the start resulted in a lot of work to refactor and keep things organized before the release.
Spring.NET addresses this practical concern in a simple and easy-to-follow manner through the use of its Dependency Injection features. Just as important, it provides additional features to help implement each layer.

The central components of Mercado Eletrônico's platform architecture and how they leverage Spring.NET include:
•  Data Access: This layer is designed using Data Access Objects (DAOs) to interact with the database. The DAOs are split into two assemblies. The interfaces defining the data access contract are in one assembly and the implementations are in another separate assembly. This lets us code against the interface contracts, greatly enhancing testability and keeping the data access layer loosely coupled to the service layer. Our primary DAO implementation is built on Spring.NET's ADO.NET Framework, providing a simple yet powerful programming model that requires less code to implement typical data access operations. There is also a second DAO implementation based on the open source .NET object-relational mapping product NHibernate. Using dependency injection, swapping one implementation in and out is extremely simple. This gives us flexibility in easily changing parts of the application over time in a well-controlled manner.
•  Services: The service layer contains our business logic and is also separated into interface and implementation assemblies for each service. The implementation is coded as a standard C# class agnostic to any distributed technology, a "Plain Old C# Object" or POCO. This lets us expose the same implementation as a COM+ component, a Web Service, or via .NET Remoting using Spring.NET's portable service abstraction features. In case we don't need to distribute the object, changing the configuration to use a standard .NET local in-process instance is easy. All of the services are also configured into each other and into the UI layer using Spring.NET. Spring.NET can then also apply declarative transaction management and business logging to the service layer through the use of its Aspect Oriented Programming features.
•  UI layer: Web applications built using ASP.NET make use of Spring.NET's ASP.NET handler, so that we can configure and inject services into our pages just like any other object. Adobe Flex and AJAX applications benefit from using the configuration-exposed Web Services, saving a lot of work in repetitive coding.

Challenges and Spring.NET Benefits
Since our conversion from ASP/COM to .NET, Spring.NET has proved to be an incredibly effective tool for developing the complex, mission-critical applications required by our organization. Mercado Eletrônico has seen substantial improvements in a number of areas:

Loose Coupling and Dependency Injection
In addition to the practical issues previously mentioned regarding the development of a layered application architecture, there was also the common problem of how one layer gets access to its neighbors and how to swap different implementations in and out. Every team found a different way, each with its own associated problems, such as complex component registrations, failure-prone CreateObject() invocations, or even pre-processor directives.

With Spring.NET, our Data Access Objects are auto-wired into our service objects, which in turn are auto-wired into our client code, indirectly, using Spring.NET's dependency injection features. This allows for cleaner and more loosely coupled code, i.e., free of hard-coded infrastructure related lookups for collaborating classes. Since every layer only references the neighbor's interface, not a specific implementation, and gets an appropriate implementation injected via configuration, this allows for an easy external swapping of implementations. Even when there's only one implementation of a given interface, following this pattern lets us enjoy many other features of Spring.NET detailed below.

Testability
Most of our code was difficult to test due to the way data access and service classes were implemented, since it had implicit hard-coded dependencies on the runtime environment and other layers. With Spring.NET and its promotion of a code-to-interface style, we can more easily unit-test our code. For example, we could use mock implementations of our Data Access Objects to test business logic in our test cases without changing a single line of application code.

We were also able to use NUnit and its Spring.NET extensions for writing complete integration tests. These extensions can perform a transaction rollback on test case completion, allowing for more comprehensive test coverage and quicker test writing.



Page 1 of 2   next page »

About Ricardo Pardini
Ricardo Pardini has been a technical lead at Mercado Eletrônico for five years and led the developer team on this .NET migration project. He specializes in virtualization, designing and developing rich Internet applications, and enjoys being a part of the prolific .NET and Java communities.

About Eric Lemes
Eric Lemes is a lead application designer and developer at Mercado Eletrônico. He focuses on the development of Web services and code infrastructure, and implemented many of the integration aspects discussed here.

MICROSOFT .NET LATEST STORIES
Peer Networking Series - A Closer Look at PNRP vs. Bonjour/ZeroConf
It seems as though whenever I bring up PNRP and its benefits, I am immediately inundated with a list of questions or comments indicating that Microsoft is re-inventing the wheel and that PNRP has already been implemented before in the form of ZeroConf and, more specifically, Apple's im
AJAX World - Xceed Launches Microsoft Silverlight 2 Control
Xceed launched Xceed Upload for Silverlight, the commercial offering in support of Microsoft's promising new Silverlight technology. The product is available now for purchase or as a fully functional 45-day trial on Xceed's website. Xceed Upload for Silverlight lets developers add uplo
Microsoft To Keynote 4th International Virtualization Conference & Expo
Mike Neil is general manager for virtualization strategy in the Windows Server Division at Microsoft. Mike is focused on the delivery of the Windows virtualization technology, including Windows Server 2008 Hyper-V, Microsoft Hyper-V Server and Virtual PC 2007. Mike also directs the tec
Microsoft Virtualization Takes Management Cross-Platform
Microsoft is making System Center, its central management scheme, natively manage Linux, Unix and VMware virtual servers. The widgetry has always been a Windows-only affair, but now there are betas available showing off Microsoft's cross-platform prowess, important to Microsoft's place
Virtualization Conference Keynote Webcast Live on SYS-CON.TV
Brian Stevens, the Chief Technology Officer and Vice President of Engineering of Red Hat, delivered his Virtualization Keynote 'The Future of the Virtual Enterprise' at SYS-CON's Virtualization Conference & Expo 2007 West in San Francisco. 'Virtualization is the hottest subject today,
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS
SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
Click to Add our RSS Feeds to the Service of Your Choice:
Google Reader or Homepage Add to My Yahoo! Subscribe with Bloglines Subscribe in NewsGator Online
myFeedster Add to My AOL Subscribe in Rojo Add 'Hugg' to Newsburst from CNET News.com Kinja Digest View Additional SYS-CON Feeds
Publish Your Article! Please send it to editorial(at)sys-con.com!

Advertise on this site! Contact advertising(at)sys-con.com! 201 802-3021

SYS-CON FEATURED WHITEPAPERS

ADS BY GOOGLE
BREAKING NEWS FROM THE WIRES
PR Newswire Summary of Technology Copy, May 9, 2008
Following is a summary of high technology news releases transmitted today by PR Newswire. T