500 likes | 596 Views
VBUG Talks in Bristol http://cms.vbug.net. Coordinators David Ringsell david@talk-it.biz www.talk-it.biz Steve Hallam steve@plumsoft.co.uk. Talks in Bristol. Ain’t No Mountain High Enough .Net Case Study Matt Link Wednesday February 15th What?!? C# Could Do That???
E N D
VBUG Talks in Bristolhttp://cms.vbug.net Coordinators David Ringsell david@talk-it.biz www.talk-it.biz Steve Hallam steve@plumsoft.co.uk
Talks in Bristol Ain’t No Mountain High Enough .Net Case Study Matt Link Wednesday February 15th • What?!? C# Could Do That??? Shay Friedman Tuesday March 27th
Matt Link Ain’t No Mountain High Enough - a product case study
Covering…….. • Challenges in writing a product vs. bespoke • Customisations • Version Control • Deployment • Security
What is Parnassus? • A mountain of limestone in central Greece
What is Parnassus? Awarding Body Management Software
What is Parnassus? To Parnassus…..
Challenges in writing a product • Versioning & Deployment • Many installations, not all upgraded at the same time • Integrations • Many require integration with other systems • Customisations • UI • Business Logic • Security
Challenges in writing a product • How to handle these issues whilst: • Keeping the code maintainable • One code base • Ensure changes for one customer don’t adversely affect another customer
Plug-ins • Improved Maintainability of code • Customer Specific code doesn’t end up in core Parnassus • Fewer settings • Easier to test • Additional code is self-contained in the Plug-in • Greater Flexibility • Not all code changes now require a new version of Parnassus to be created
MEF (Managed Extensibility Framework) • A bit like
MEF • A Composable Part is something which either • Needs (Imports) something • Offers (Exports) something • Both! These “needs” and “offers” are matched based on Contracts by a Container We use Interfaces, but you can just use a string……..
MEF A Part Specifies what it wants to Import [ImportMany(typeof(IQualificationRegistrationCreated))] A Part specifies what it can Export [Export(typeof(IQualificationRegistrationCreated))] The Container matches the two together A Catalogue is used to discover the Parts
MEF public static CompositionContainerContainer { get { string dir = PluginDirectory; DirectoryCatalogcat = new DirectoryCatalog(dir); varcontainer = new CompositionContainer(cat); return container; } } DirectoryCatalog scans a given directory for Parts public static void Compose(object toCompose) { try { CompositionContainerc = Container; c.ComposeParts(toCompose); } catch (Exception ex1) { throw new Exception("Error Composing Object: " +toCompose.GetType().Name,ex1); } } Calling “ComposeParts” on a Container matches Imports to Exports
MEF - A Quick demo ImportedPlugins Class [ImportMany(typeof(IQualificationRegistrationCreated))] public FilteredExportCollection<IQualificationRegistrationCreated> QualificationRegistrationCreated { get; internal set; } Contract FilteredExportCollection<T> : ICollection QualificationRegistrationCreated_Demo Class [Export(typeof(IQualificationRegistrationCreated))] public class QualificationRegistrationCreated_Demo: IQualificationRegistrationCreated
MEF - A Quick Demo • To the Code………..
MEF When the Compose Method is called on the Container, MEF matches Imports to Exports based on the Contracts. This populates a collection (in our case a generic FilteredExportCollection<T>) Any Exports matching the Contract are now available in the collection
MEF – Example Uses • Custom Validation • Normally involves • Yet another setting / Code into core Parnassus • Finance • Address Lookup • Integration • E.g. On learner save send details to another system
Translations • Every customer calls things by different names • Translations needs to be applied everywhere with minimum of developer effort • Every customer has a different set of translations
Translations • Extension Method • “Add" methods to existing types • Enables you to do:
Translations • On every page: • For each Control on the page… • Get Control Type • Change a property to the translated version…
Security • Similar challenge with security • Every customer has different rules • asp.net Page level security not fine grained enough Only controls access to whole pages / folders • Field level security required • Minimise developer effort (make security easy)
Security • Gets cached security rules for the page • For each Control on the page… • Get Control Type • Apply security rules based on control type • E.g. GridView - Adds an Event Handler to DataBound event
Security • Parnassus as a Centre User…. • Limited menu options • Restricted to seeing limited details of own centre • Restricted to viewing only their learners • Customer decides how much each User / Role can see and do in Parnassus • To Parnassus…… • User: Centre1 • Pass: Centre1
Deployment • Many customers, many versions • About 4 different versions being supported • Initially struggled with upgrade paths • DB change scripts from one specific version another specific version Feb December Customer A - Jan April December Customer B - Jan
Deployment • Problems: • Almost no reuse of upgrade scripts • Customer A’s V3.0 not quite the same as Customer B’s • OK when fairly regular updates, harder when big jumps
Deployment Solution = Database Projects • No more schema upgrade scripts • Will upgrade any version of Parnassus • Quicker than producing upgrade scripts • Potential to use them for Source Control of the Database
SQL Deployment – Database Projects Visual Studio • 1) Database Synced with Database Project BuildOutput • 2) DB Project produces .dbschema
Deployment • To a quick Parnassus Upgrade…..
Versioning – What changed / changing when • Work Items in TFS for us • Assign work to Versions / Iterations • Track work status (Design / Coding / Testing) • Associate code check-in with work items • Change Log comments for the customer • Viewer App to extract them • Quickly generate a change log for a version
Branching & Merging • Need to be able to release patch versions • Fix once, apply to all versions • Allow ongoing development at the same time • Requires • Source Control Software (TFS) • Compare / Merge tool (DiffMerge) • A branching strategy…..
Branch Label
Branches are duplications of an object under revision control so that modifications can happen in parallel along both branches.
Branching & Merging • Visual Studio TFS Branching Guide http://vsarbranchingguide.codeplex.com/
Other things to talk about…. • Custom User Controls • Settings • Code Generation • Auditing