Thursday, March 15, 2007

Building Composite Applications

Jeremy Boyd

Mindscape

Lots of ground to cover!

New concepts, code!

Look for code, samples and presentation downloads

http://turtle.net.nz/blog/

Jeremy@mindscape.co.nz

Composite Applications

  • The whole is greater than the sum of its parts
  • Composed of a number of discrete and independent pieces, aggregating this functionality through a software interface.
  • Break free from “silo” issues
  • Lower cost of development
  • Consistency
Tradition Applications
  • An encapsulated system providing its own self sufficiency
What’s enabled all this?
  • Services
  • Software over services
    • Lightweight
    • Loosely coupled
    • 3 tier architecture
  • Result: Reuse of software!
Traps to watch for
  • Maturity for integration
    • Must be able to leverage services for direct integration for greatest benefit
  • External Trust
    • External data lives in the cloud
    • Reliance on provider for business operations
Example: Exchange Server 2007 is used by
  • Outlook
  • Outlook Web Access
  • Outlook Voice Access
  • Outlook Mobile
Background Motion
  • Lightweight build: 3 weeks
  • Consumes resources from
    • Flickr
    • Soapbox
    • GeoTagIt
  • Also publishes services and data
Architecture
  • Presentation Layer = ASP.Net 2.0 & AJAX
  • Business Layer = Content Service, controllers & Model
  • Resource Layer = Service Proxies & LINQ to SQL Server
But How?
  • Start with the problem e.g. Provide a community site to provide content for DreamScene
  • Focus on the interface
  • Work out who is already offering functionality
    • Flickr works well for images
    • Soapbox works well for videos
We already had great tools
  • .NET 2.0 and .NET 3.0 Frameworks
  • ASP.Net AJAX
  • Composite Web Block
  • Enterprise Library
  • Don’t forget about 3rd party!
    • RSS Toolkit
    • Lucene.NET
    • 2 way data-binding
Some tips from the Background Motion build
  • WebDataBinder
    • DataBinder.DataBind()
    • DataBinder.Unbind()
  • Microsoft.Practices.EnterpriseLibrary.Validation
    • [RequireValidator]
    • Presenter.Save()


Supervising Controller (MVP)
  • View (GET http://site/pages.aspx)
  • Presenter (View is based on the PageBase class which wires it up to the Presenter)
  • Model (View can work with the Model but calls back to Presenter to perform process flow)
  • “Factor the UI into a view and controller where the view handles simple mapping to the underlying model and the controller handles input response and complex view logic.” Martin Fowlerwww.martinfowler.com
  • Cleanly separates UI process form binding/event logic
  • Improves testability
Dependency Injection
  • Establish a level of abstraction via a public interface, and remove dependency on components by (for example) supplying a plug-in architecture – Wiki
  • Allows for loose coupling
  • Abstraction through interfaces
  • Composite Web Block uses
  • ServiceLocator approach
Service Locators
  • I need an instance of IDataLayer class! (Consumer to Interface)
  • I can ask the ServiceLocator to give me an instance of IDatalayer
  • ServiceLocator holds an instance of Factory <IDataLayer>
  • Factory <IDataLayer> assembles a Concrete class instance
  • Concrete instance is returned to the Consumer
  • Consumer always calls through the IDataLayer interface
So What?
  • Solid foundation leads to flexibility – supports change!
  • Lower development complexity – modularity!
  • Testability of solution
    • More effective integration
    • Shorter cycles
    • Always building working code!
Unit Testing…
  • Create a separate library (project in the solution)
  • NUnit – a free testing framework
  • Define [Test] methods
    • Assert.IsFalse(contribution.ValidationResults.IsValid);
    • (do some work)
    • Assert.IsTrue(contribution.ValidationResults.IsValid);
  • Where might these be useful?
    • When a field length changes, the Unit Test will fail the Validator.
    • Helps save you a lot of time by capturing these types of failures
Continuous Integration
  • Developer checks in to source control
  • The BuildServer monitors the source control
  • The BuildServer builds the application
  • The BuildServer runs the unit tests
  • The BuildServer notifies whether all tests passed
Resources
  • External from this application
    • Active Directory
    • Web Services
    • Legacy System
  • Contract based consumption
    • Loose coupling
    • Flexibility in plug and play
But how?
  • Windows Communication Foundation
  • The Unified Framework for rapidly building service oriented applications
WCF
  • Building block for building Connected Systems
  • Designed around messages!
  • Full standards/specifications support (WS-* oriented)
  • Provide consistent API regardless of messaging requirement
  • Part of .Net 3.0 Framework
Software + Services
  • ASP.NET AJAX. The free framework for quickly creating a new generation of more efficient, more interactive and highly personalized Web experiences
  • Building a mash-up using ASP.NET AJAX
  • Web Service can output AJAX (JavaScript)!
AJAX with Services
  • ASP.Net AJAX allows native call
  • Too fast


Call to Action
  • Read about Patterns
  • Look at Unit Tests and CI http://ccnet.thoughtworks.com
  • Download the Composite Web Block
    • And the Validation Block
    • And the Enterprise Library
  • Publish services in your enterprise to allow composite applications to flourish!

No comments:

Post a Comment