SlideShare ist ein Scribd-Unternehmen logo
1 von 62
Besseres C#
Workshop
BASTA! Spring 2014

Rainer Stropek
software architects gmbh

Modularisierung

Web http://www.timecockpit.com
Mail rainer@timecockpit.com
Twitter @rstropek

Workshop
Saves the day.
Modularisierung
Grundlagen
Warum modulare Programmierung?
The benefits expected of modular programming are:


Managerial - development time should be shortened because separate
groups would work on each module with little need for communication



Product flexibility - it should be possible to make drastic changes to one
module without a need to change others



Comprehensibility - it should be possible to study the system one module
at a time. The whole system can therefore be better designed because it is
better understood.

Quelle: Parnas, On the Criteria To Be Used in Decomposing Systems into Modules, Carnegie-Mellon University, 1972
Was ist eine Softwarefabrik?
A software factory is an organizational structure that specializes in
producing computer software applications or software components […]
through an assembly process.
The software is created by assembling predefined components.
Traditional coding, is left only for creating new components or services.
A composite application is the end result of manufacturing in a
software factory.

Quelle: “Software Factory” in Wikipedia
Vorteile einer Softwarefabrik (1/2
 Kernkompetenzen

der Mitarbeiter werden

hervorgehoben
Fachlich orientierte Berater konfigurieren (Vokabular näher bei der jeweiligen Domäne
des Kunden)
Softwareentwickler erstellen Basiskomponenten

 Steigerung

der Effizienz

Das Rad wird weniger oft neu erfunden

 Steigerung

der Qualität

Anspruchsvolle QS-Maßnahmen für Basiskomponenten
Vorteile einer Softwarefabrik (2/2
 Reduktion

der Projektrisiken

Fachberater mit besserem Kundenverständnis
Höhere Qualität der Basiskomponenten

 Steigerung

des Firmenwerts

Systematisches Festhalten von Wissen über die Herstellung einer Familie von
Softwarelösungen
Design Patterns, Frameworks, Modelle, DSLs, Tools

 Vereinfachung

des Vertriebs- und
Spezifikationsprozesses

Konzentration auf projektspezifische Lösungsteile
Quick Wins durch Standardkomponenten
Was eine Softwarefabrik nicht will…


Reduktion des Entwicklungsprozesses auf standardisierte,
mechanische Prozesse
Im Gegenteil, mechanische Prozesse sollen Tool überlassen werden



Verringerung der Bedeutung von Menschen im Entwicklungsprozess



„Handwerk“ der Softwareentwicklung wird nicht gering geschätzt
sondern gezielt eingesetzt



Entwicklung von Frameworks statt Lösungen für Kunden
Software Factories  Economy of Scop
Economy of Scale


Multiple implementations
(=Copies) of the same design



Mehr oder weniger mechanische
Vervielfältigung von Prototypen
Massengüter
Software (z.B. Auslieferung auf Datenträger)

Economy of Scope


Production of multiple designs
and their initial
implementations



Ähnliche Designs (=Familien
von Anwendungen) auf
Grundlage gemeinsamer
Techniken und Technologien
Individuelle physische Güter (z.B. Brücken,
Hochhäuser)
Individualsoftware, Softwareplattformen (vgl.
PaaS)

Quelle: Greenfield J., Short K.: Software Factories
Kosten/Nutzen
Abwägung
Kosten der
Erstellung
der Software
Factory

Vorteile bei
der
Herstellung
mehrerer
ähnlicher
Produkte

Spezialisierung als
zentraler Erfolgsfaktor
beim Einsatz der
Software Factory
Prinzipien
Entwicklung einer Software Factory
Projekt A

Projekt B

Custom Code

Custom Code

Base Class Library
Entwicklung einer Software Factory
Projekt A

Projekt B

Custom Code

Custom Code

Common Components

Base Class Library
Entwicklung einer Software Factory
Projekt A

Projekt B

Model, Extensions, Configuration, Scripts

Custom
Component

Custom
Component

Model, Extensions, Configuration, Scripts

Common Components

Base Class Library

Custom
Component

Custom
Component

Standard components will be
commoditized
 3rd party components
 make-or-buy decisions
Entwicklung einer Software Factory
Projekt A

Projekt B

Model, Extensions, Configuration, Scripts

Model, Extensions, Configuration, Scripts

Patterns, Practices, Guidelines

Custom
Component

Custom
Component

Common Components

Base Class Library

Custom
Component

Custom
Component
Nette Theorie, aber in der Praxis??


Abstraktionsgrad
Je abstrakter desto mächtiger 
Je abstrakter desto spezifischer 



Abhängigkeiten
Vertrauen in Werkzeuge
Vertrauen in Lieferanten
Vertrauen in Mitarbeiter



Kleinster gemeinsamer Nenner
Ausnutzung aller Möglichkeiten der zugrunde liegenden Plattform
Performanceprobleme (Beispiel: OR-Mapper vs. T-SQL)
Werkzeuge


Klassenbibliotheken



Dokumentation
Statische Codeanalyse
Deployment


Codegeneratoren



Vorlagen
Patterns in Form von Assistenten


Domänenspezifische Sprachen

MS Framework Design Guidelines
Sandcastle
StyleCop, Code Analysis, 3rd party tools
NuGet

Codegeneratoren
T4, ANTLR StringTemplates
Visual Studio Templates



XML-basierend oder
individuell (Compiler-Compiler)
Compiler (Codegenerator) vs. interpretiert

Domänenspezifische Sprachen
XAML (UI und Workflows), EF
ANTLR (Compiler-Compiler)



Scriptsprachen



DLR, Project „Roslin“



Anwendungsmodularisierung



MEF, MAF

Prozessautomatisierung





Qualitätssicherung
Build

Prozessautomatisierung
Visual Studio Unit Tests
TFS Buildautomatisierung
NuGet
Package Manager für die Microsoft-Entwicklungsplattform
Was ist NuGet?


Werkzeug zur einfachen Verteilung von Paketen (=Libraries und
Tools)



Alles Notwendige in einem Paket
Binaries für verschiedene Plattformen
Optional Symbole und Sourcen
Anpassungen am Projekt (z.B. Referenzen, Änderungen am app/web.config)



UI-Integration in Visual Studio
Ab VS2010, eingeschränkt auch in Mono
Express-Editionen werden unterstützt



http://www.nuget.org
http://nuget.codeplex.com/ (Sourcecode)
NuGet in Visual Studio
NuGet in Visual Studio


Package Manager Console



PowerShell console in Visual Studio



Automate Visual Studio and NuGet



NuGet PowerShell Reference
NuGet Pakete erstellen
 Kommandozeilentool

nuget.exe

Pakete erstellen (Pack Command)
Pakete veröffentlichen (Push, Delete Command)
Paket installieren (Install, Restore, Update Command)
Generieren eines nuspec-Files (Spec Command)
Wichtig für Buildautomatisierung
Kommandozeilenreferenz

 NuGet

Package Explorer

Grafisches UI zur Erstellung/Bearbeitung von NuGet Paketen und nuspec Files
http://npe.codeplex.com/
<?xml version="1.0" encoding="utf-16"?>
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
<metadata>
<id>CockpitFramework.Data</id>
<version>$version$</version>
<title>Cockpit Framework Data Layer</title>
<authors>software architects gmbh</authors>
<owners>software architects gmbh</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>...</description>
<releaseNotes></releaseNotes>
<dependencies>
<group targetFramework=".NETFramework4.0">
<dependency id="CockpitFramework.Dependencies"
version="[$version$]" />
</group>
<group targetFramework="sl5">
<dependency id="CockpitFramework.Dependencies"
version="[$version$]" />
</group>
</dependencies>
</metadata>

Example
nuspec File
<dependencies>
<group targetFramework=".NETFramework4.0">
<dependency id="log4net" version="[1.2.11]" />
<dependency id="Microsoft.SqlServer.Compact.Private"
version="[4.0.8482.1]" />
<dependency id="AvalonEdit" version="[4.2.0.8783]" />
<dependency id="ClosedXML" version="[0.68.1]" />
<dependency id="DocumentFormat.OpenXml" version="[1.0]" />
<dependency id="IronPython" version="[2.7.3]" />
<dependency id="LumenWorks.Framework.IO" version="[1.0.0]" />
<dependency id="Newtonsoft.Json" version="[5.0.6]" />
<dependency id="WindowsAzure.Storage" version="[2.0.5.1]" />
<dependency id="Microsoft.Bcl.Async" version="[1.0.16]" />
</group>

<group targetFramework="sl5">
…
</group>
</dependencies>

Example
nuspec File

Version range syntax
<files>
<!-- net4 -->
<file src=".$configuration$TimeCockpit.Common.dll"
target="libnet4" />
<file src=".$configuration$TimeCockpit.Data.dll"
target="libnet4"/>
…
<!-- sl5 -->
<file src=".SL$configuration$TimeCockpit.Common.dll"
target="libsl5" />
<file src=".SL$configuration$TimeCockpit.Data.dll"
target="libsl5" />
…
<!-- include source code for symbols -->
<file src="....*.cs" target="srcTimeCockpit.Common" />
<file src="....*.cs" target="srcTimeCockpit.Data" />
</package>

Example
nuspec File
Folder Structure
For Details see NuGet Docs
Versioning Notes


Things to remember
NuGet never installs assemblies machine-wide (i.e. not in GAC)
You cannot have multiple versions of the same DLL in one AppDomain



DLL Hell
Policy too loose: Problems with breaking changes
Policy too tight: Problems with library having dependencies on other libraries
(e.g. ANTLR and ASP.NET MVC, everyone depending on Newtonsoft JSON)



For Library Publishers: SemVer
X.Y.Z (Major.Minor.Patch)
Rethink your strong naming policies
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="mscorcfg"
publicKeyToken="b03f5f7f11d50a3a" culture=""/>
<bindingRedirect
oldVersion="0.0.0.0-65535.65535.65535.65535"
newVersion="1.0.3300.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>

Binding Redirects
Note: NuGet can generate
this for you
Add-BindingRedirect Command
See online reference for details
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="SomePackage"
version="2.1.0"
allowedVersions="[2,3)" />
</packages>

Versioning
Constraings in packges.config

Manual editing necessary
ILMerge
Newtonsoft.JSO
N 4.0.2

ILMerge

Soliving version conflicts

Google API

Newtonsoft.JSO
N 5.0.6

My Library

My App

Microsoft Download
ILMerge
"AssembliesGoogle.Apis.Authentication.OAuth2.dll"
"AssembliesGoogle.Apis.dll"
"AssembliesGoogle.Apis.Latitude.v1.dll"
"AssembliesDotNetOpenAuth.dll" "Assemblieslog4net.dll"
"AssembliesNewtonsoft.Json.Net35.dll"
/out:"c:tempGoogle.Apis.All.dll" /lib:"Lib„
extern alias MyConfig;
using Conf = MyConfig::System.Configuration;
namespace MyTinyMvvmToolkit
{
public class NotificationObject
{
public void ReadConfiguration()
{
var setting =
Conf.ConfigurationManager.AppSettings["MyDB"];
}
}
}

ILMerge
Soliving version conflicts

C# extern alias
<?xml version="1.0" encoding="utf-16"?>
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
<metadata>…</metadata>

Content Files
New in NuGet 2.6: XDT

<files>
<file src="contentapp.config.transform"
target="content" />
<file src="contentTimeCockpitInitialization.cs.pp"
target="content" />
</files>
</package>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
<system.data>
<DbProviderFactories>
<remove invariant="System.Data.SqlServerCe.4.0"/>
<add name="Microsoft SQL Server Compact Data Provider 4.0"
invariant="System.Data.SqlServerCe.4.0"
description=".NET Framework Data Provider for Microsoft SQL Server Compact"
type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe,
Version=4.0.0.1, Culture=neutral, PublicKeyToken=89845dcd8080cc91"/>
</DbProviderFactories>
</system.data>
</configuration>
…
namespace $rootnamespace$
{
using System;
/// <summary>
/// Class taking care of cockpit framework initialization
/// </summary>
public class TimeCockpitInitialization
{
…
}

}

Content Files
Sourcecode Transformations in .cs.pp
File

Available properties see
MSDN
User PowerShell scripts to
modify project properties
NuGet Docs
Nuget in Practice
Nuget at software architects

Nuspec files
Files
Dependencies
Build

Packages in NuGet
Explorer
Packages in VS

Demo
Publishing NuGet Packages
 http://www.nuget.org
Public NuGet Feed

 Create

your private feed

File system
Private NuGet Server
For details see NuGet Help

 Use

a NuGet SaaS like MyGet

http://www.myget.org/
MEF
Managed Extensibility Framework
Original Goals
 Before

MEF

Multiple extensibility mechanism for different Microsoft tools (e.g. Visual Studio, Trace
Listeners, etc.)
Developers outside of MS had the same problem

 MEF:

Provide standard mechanisms for hooks for 3rd
party extensions

 Goal:

Open and Dynamic Applications

Make it easier and cheaper to build extensible applications and extensions
MEF vs. MAF
 Managed AddIn

Framework

System.AddIn

 MAF

has higher-level goals

Isolate extension
Load and unload extensions
API Compatibility

 Adding

MAF leads to higher effort than adding MEF

A single application can use both
[Export(typeof(Shape))]
public class Square : Shape
{
// Implementation
}
[Export(typeof(Shape))]
public class Circle : Shape
{
// Implementation
}

Export with
name or type

MEF „Hello World“
Anatomy of a program with MEF

Defaults to
typeof(Toolbox)

[Export]
public class Toolbox
{
[ImportMany]
public Shape[] Shapes { get; set; }
// Additional implementation...
}
[…]
var catalog = new AssemblyCatalog(typeof(Square).Assembly);
var container = new CompositionContainer(catalog);
Toolbox toolbox = container.GetExportedValue<Toolbox>();

Attributed Programming
Model
MEF „Hello World“
 Parts
Square, Circle and Toolbox

 Dependencies
Imports (Import-Attribute)
E.g. Toolbox.Shapes

 Capabilities
Exports (Export-Attribute)
E.g. Square, Circle
MEF „Hello World“
MEF Basics
Basic Exports
Basic Imports
Catalogs
Composition

Demo
Exports And Imports


Export attribute
Class
Field
Property
Method



Import attribute
Field
Property
Constructor parameter



Export and import must have the same contract
Contract name and contract type
Contract name and type can be inferred from the decorated element
[Export]
public class NumOne
{
[Import]
public IMyData MyData
{ get; set; }
}

Inherited Exports
Import automatically
inherited
Export NOT inherited
 NumTwo has no exports

public class NumTwo : NumOne
{
}
[InheritedExport]
public class NumThree
{
[Export]
Public IMyData MyData { get; set; }
}
public class NumFour : NumThree
{
}

Member-level exports
are never inherited

Inherits export with
contract NumThree
(including all metadata)
MEF Catalogs
 Catalogs

provide components

 Derived

from System.ComponentModel.Composition.
Primitives.ComposablePartCatalog

AssemblyCatalog
Parse all the parts present in a specified assembly

DirectoryCatalog
Parses the contents of a directory

TypeCatalog
Accepts type array or a list of managed types

AggregateCatalog
Collection of ComposablePartCatalog objects
Catalogs
Loading of modules using
DirectoryCatalog

Demo
public class MyClass
{
[Import]
public Lazy<IMyAddin> MyAddin
{ get; set; }
}

Lazy Imports
Imported object is not
instantiated immediately
Imported (only) when accessed
[ImportingConstructor]
public MyClass(
[Import(typeof(IMySubAddin))]
IMyAddin MyAddin)
{
Could be removed
here; automatically
_theAddin = MyAddin;
imported
}

Prerequisite
Imports
Composition engine uses
parameter-less
constructor by default
Use a different constructor
with
ImportingConstructor
attribute
public class MyClass
{
[Import(AllowDefault = true)]
public Plugin thePlugin { get; set; }
}

Optional Imports
By default composition
fails if an import could
not be fulfilled
Use AllowDefault property
to specify optional
imports
Creation Policy
 RequiredCreationPolicy

property

 CreationPolicy.Any
Shared if importer does not explicitly request NonShared

 CreationPolicy.Shared
Single shared instance of the part will be created for all requestors

 CreationPolicy.NonShared
New non-shared instance of the part will be created for every requestor
MEF Object Lifetime
 Container

holds references to all disposable parts

Only container can call Dispose on these objects

 Manage

lifetime of disposable objects

Dispose the container  it will dispose all managed objects
Call ReleaseExport on a non-shared object to dispose just this object
Use ExportFactory<T> to control lifetime

 IPartImportsSatisfiedNotification
Implement if you need to get informed when composition has been completed
Part Lifecycle

Demo
Metadata and Metadata views
Advanced exports
Goal
 Export

provides additional metadata so that importing
part can decide which one to use

 Import

can inspect metadata without creating exporting

part
 Prerequisite:

Lazy import
namespace MetadataSample
{
public interface ITranslatorMetadata
{
string SourceLanguage { get; }
[DefaultValue("en-US")]
string TargetLanguage { get; }

}
}

Metadata
Export Metadata can
be mapped to
metadata view
interface

namespace MetadataSample
{
[Export(typeof(ITranslator))]
[ExportMetadata("SourceLanguage", "de-DE")]
[ExportMetadata("TargetLanguage", "en-US")]
public class GermanEnglishTranslator : ITranslator
{
public string Translate(string source)
{
throw new NotImplementedException();
}
}
}
namespace MetadataSample
{
class Program
{
static void Main(string[] args)
{
var catalog = new AssemblyCatalog( typeof(ITranslator).Assembly);
var container = new CompositionContainer(catalog);
// We need a translator from hungarian to english
Lazy<ITranslator, ITranslatorMetadata> translator =
container
.GetExports<ITranslator, ITranslatorMetadata>()
.Where(t => t.Metadata.SourceLanguage == "hu-HU"
&& t.Metadata.TargetLanguage == "en-US")
.FirstOrDefault();
}
}
}

Metadata
(Continued)
[Export(typeof(ITranslator))]
[ExportMetadata("SourceLanguage", "de-DE")]
[ExportMetadata("TargetLanguage", "en-US")]
public class GermanEnglishTranslator
: ITranslator
{
public string Translate(
string source)
{
throw new NotImplementedException();
}
}

[TranslatorExport("de-DE", "en-US")]
public class GermanEnglishTranslator
: ITranslator
{
public string Translate(
string source)
{
throw new NotImplementedException();
}
}

Custom Export Attributes

Custom export
attributes makes code
much cleaner.
[MetadataAttribute]
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
public class TranslatorExportAttribute
: ExportAttribute, ITranslatorMetadata
{
public TranslatorExportAttribute(
string sourceLanguage, string targetLanguage)
: base(typeof(ITranslator))
{
this.SourceLanguage = sourceLanguage;
this.TargetLanguage = targetLanguage;
}

public string SourceLanguage { get; private set; }
public string TargetLanguage { get; private set; }
}
}

Custom Export Attributes
(Continued)
Convention-Based Programming
New in .NET 4.5
Goals


Reduce the need for attributes
Note that attributes in the source code override conventions



Convention-based coupling
Infer MEF attributes for objects‘ types
Example: Export all classes derived from Controller



System.ComponentModel.Composition.Registration.
RegistrationBuilder
ForType – creates a rule for a single type
ForTypesDerivedFrom – creates a rule for all types derived from a certain type
ForTypesMatching – creates a custom rule based on a predicate
Returns a PartBuilder object that is used to configure imports and exports
public interface IShapeMetadata { bool Is2D { get; } };
public class Shape { }
public class Circle : Shape { }
public class Rectangle : Shape { }

Example

[…]

[ImportMany(typeof(Shape))]
private Shape[] shapes;

Export all descendants of
a given class

[…]
// Export all descendants of Shape and add some metadata
var rb = new RegistrationBuilder();
var pb = rb.ForTypesDerivedFrom<Shape>();
pb.Export<Shape>(eb => eb.AddMetadata("Is2D", true))
.SetCreationPolicy(CreationPolicy.NonShared);
// Use registration builder with catalog
var me = new Program();
var container = new CompositionContainer(
new AssemblyCatalog(me.GetType().Assembly, rb));
container.ComposeParts(me);

Add some metadata
Set a creation policy
BASTA! Spring 2014

Rainer Stropek
software architects gmbh

Q&A

Mail rainer@timecockpit.com
Web http://www.timecockpit.com
Twitter @rstropek

Thank your for coming!
Saves the day.
is the leading time tracking solution for knowledge workers.
Graphical time tracking calendar, automatic tracking of your work using
signal trackers, high level of extensibility and customizability, full support to
work offline, and SaaS deployment model make it the optimal choice
especially in the IT consulting business.
Try
for free and without any risk. You can get your trial
account at http://www.timecockpit.com. After the trial period you can use
for only 0,20€ per user and day without a minimal subscription time and
without a minimal number of users.
ist die führende Projektzeiterfassung für Knowledge Worker.
Grafischer Zeitbuchungskalender, automatische Tätigkeitsaufzeichnung
über Signal Tracker, umfassende Erweiterbarkeit und Anpassbarkeit, volle
Offlinefähigkeit und einfachste Verwendung durch SaaS machen es zur
Optimalen Lösung auch speziell im IT-Umfeld.
Probieren Sie
kostenlos und ohne Risiko einfach aus. Einen
Testzugang erhalten Sie unter http://www.timecockpit.com. Danach nutzen
Sie
um nur 0,20€ pro Benutzer und Tag ohne Mindestdauer
und ohne Mindestbenutzeranzahl.

Weitere ähnliche Inhalte

Was ist angesagt?

From Ant to Maven to Gradle a tale of CI tools for JVM
From Ant to Maven to Gradle a tale of CI tools for JVMFrom Ant to Maven to Gradle a tale of CI tools for JVM
From Ant to Maven to Gradle a tale of CI tools for JVMBucharest Java User Group
 
StdAfx.h for Novices
StdAfx.h for NovicesStdAfx.h for Novices
StdAfx.h for NovicesAndrey Karpov
 
Get Started with Zend Framework 2
Get Started with Zend Framework 2Get Started with Zend Framework 2
Get Started with Zend Framework 2Mindfire Solutions
 
Automated Historical Performance Analysis with kmemtracer
Automated Historical Performance Analysis with kmemtracerAutomated Historical Performance Analysis with kmemtracer
Automated Historical Performance Analysis with kmemtracerKyungmin Lee
 
Deprecated: Foundations of Zend Framework 2
Deprecated: Foundations of Zend Framework 2Deprecated: Foundations of Zend Framework 2
Deprecated: Foundations of Zend Framework 2Adam Culp
 
Introduction to the Android NDK
Introduction to the Android NDKIntroduction to the Android NDK
Introduction to the Android NDKSebastian Mauer
 
A quick start on Zend Framework 2
A quick start on Zend Framework 2A quick start on Zend Framework 2
A quick start on Zend Framework 2Enrico Zimuel
 
WordPress and Zend Framework Integration with Vulnero
WordPress and Zend Framework Integration with VulneroWordPress and Zend Framework Integration with Vulnero
WordPress and Zend Framework Integration with VulneroAndrew Kandels
 
Using the Android Native Development Kit (NDK)
Using the Android Native Development Kit (NDK)Using the Android Native Development Kit (NDK)
Using the Android Native Development Kit (NDK)DroidConTLV
 

Was ist angesagt? (12)

From Ant to Maven to Gradle a tale of CI tools for JVM
From Ant to Maven to Gradle a tale of CI tools for JVMFrom Ant to Maven to Gradle a tale of CI tools for JVM
From Ant to Maven to Gradle a tale of CI tools for JVM
 
StdAfx.h for Novices
StdAfx.h for NovicesStdAfx.h for Novices
StdAfx.h for Novices
 
BDD using Cucumber JVM
BDD using Cucumber JVMBDD using Cucumber JVM
BDD using Cucumber JVM
 
Get Started with Zend Framework 2
Get Started with Zend Framework 2Get Started with Zend Framework 2
Get Started with Zend Framework 2
 
Automated Historical Performance Analysis with kmemtracer
Automated Historical Performance Analysis with kmemtracerAutomated Historical Performance Analysis with kmemtracer
Automated Historical Performance Analysis with kmemtracer
 
Deprecated: Foundations of Zend Framework 2
Deprecated: Foundations of Zend Framework 2Deprecated: Foundations of Zend Framework 2
Deprecated: Foundations of Zend Framework 2
 
Introduction to the Android NDK
Introduction to the Android NDKIntroduction to the Android NDK
Introduction to the Android NDK
 
Android NDK
Android NDKAndroid NDK
Android NDK
 
A quick start on Zend Framework 2
A quick start on Zend Framework 2A quick start on Zend Framework 2
A quick start on Zend Framework 2
 
WordPress and Zend Framework Integration with Vulnero
WordPress and Zend Framework Integration with VulneroWordPress and Zend Framework Integration with Vulnero
WordPress and Zend Framework Integration with Vulnero
 
NDK Introduction
NDK IntroductionNDK Introduction
NDK Introduction
 
Using the Android Native Development Kit (NDK)
Using the Android Native Development Kit (NDK)Using the Android Native Development Kit (NDK)
Using the Android Native Development Kit (NDK)
 

Ähnlich wie Workshop: Modularization of .NET Applications

Atmel - Next-Generation IDE: Maximizing IP Reuse [WHITE PAPER]
Atmel - Next-Generation IDE: Maximizing IP Reuse [WHITE PAPER]Atmel - Next-Generation IDE: Maximizing IP Reuse [WHITE PAPER]
Atmel - Next-Generation IDE: Maximizing IP Reuse [WHITE PAPER]Atmel Corporation
 
VS Code and Modern Development Environment Preview
VS Code and Modern Development Environment PreviewVS Code and Modern Development Environment Preview
VS Code and Modern Development Environment PreviewRoberto Stefanetti
 
Part 2 improving your software development v1.0
Part 2   improving your software development v1.0Part 2   improving your software development v1.0
Part 2 improving your software development v1.0Jasmine Conseil
 
Visual Studio commands
Visual Studio commandsVisual Studio commands
Visual Studio commandsPVS-Studio
 
Creating, debugging and deploying extension packages for Microsoft Visual Stu...
Creating, debugging and deploying extension packages for Microsoft Visual Stu...Creating, debugging and deploying extension packages for Microsoft Visual Stu...
Creating, debugging and deploying extension packages for Microsoft Visual Stu...PVS-Studio
 
DevExForPlatformEngineers, introducing Kratix
DevExForPlatformEngineers, introducing KratixDevExForPlatformEngineers, introducing Kratix
DevExForPlatformEngineers, introducing KratixAbigail Bangser
 
Best software development tools in 2021
Best software development tools in 2021Best software development tools in 2021
Best software development tools in 2021Samaritan InfoTech
 
Presentation 1 open source tools in continuous integration environment v1.0
Presentation 1   open source tools in continuous integration environment v1.0Presentation 1   open source tools in continuous integration environment v1.0
Presentation 1 open source tools in continuous integration environment v1.0Jasmine Conseil
 
[Portland 365Sat] PCF Custom Controls
[Portland 365Sat] PCF Custom Controls[Portland 365Sat] PCF Custom Controls
[Portland 365Sat] PCF Custom Controls⚡ Danish Naglekar
 
A Software Factory Integrating Rational & WebSphere Tools
A Software Factory Integrating Rational & WebSphere ToolsA Software Factory Integrating Rational & WebSphere Tools
A Software Factory Integrating Rational & WebSphere Toolsghodgkinson
 
Extend Eclipse p2 framework capabilities: Add your custom installation steps
Extend Eclipse p2 framework capabilities: Add your custom installation stepsExtend Eclipse p2 framework capabilities: Add your custom installation steps
Extend Eclipse p2 framework capabilities: Add your custom installation stepsDragos_Mihailescu
 
Managing Your Runtime With P2
Managing Your Runtime With P2Managing Your Runtime With P2
Managing Your Runtime With P2Pascal Rapicault
 
A Sneak Peek At Visual Studio 2010 And .Net Framework 4.0
A Sneak Peek At Visual Studio 2010 And .Net Framework 4.0A Sneak Peek At Visual Studio 2010 And .Net Framework 4.0
A Sneak Peek At Visual Studio 2010 And .Net Framework 4.0Antonio Chagoury
 
Asp.net Web Development.pdf
Asp.net Web Development.pdfAsp.net Web Development.pdf
Asp.net Web Development.pdfSonia Simi
 

Ähnlich wie Workshop: Modularization of .NET Applications (20)

Atmel - Next-Generation IDE: Maximizing IP Reuse [WHITE PAPER]
Atmel - Next-Generation IDE: Maximizing IP Reuse [WHITE PAPER]Atmel - Next-Generation IDE: Maximizing IP Reuse [WHITE PAPER]
Atmel - Next-Generation IDE: Maximizing IP Reuse [WHITE PAPER]
 
VS Code and Modern Development Environment Preview
VS Code and Modern Development Environment PreviewVS Code and Modern Development Environment Preview
VS Code and Modern Development Environment Preview
 
Part 2 improving your software development v1.0
Part 2   improving your software development v1.0Part 2   improving your software development v1.0
Part 2 improving your software development v1.0
 
Visual Studio commands
Visual Studio commandsVisual Studio commands
Visual Studio commands
 
Creating, debugging and deploying extension packages for Microsoft Visual Stu...
Creating, debugging and deploying extension packages for Microsoft Visual Stu...Creating, debugging and deploying extension packages for Microsoft Visual Stu...
Creating, debugging and deploying extension packages for Microsoft Visual Stu...
 
DevExForPlatformEngineers, introducing Kratix
DevExForPlatformEngineers, introducing KratixDevExForPlatformEngineers, introducing Kratix
DevExForPlatformEngineers, introducing Kratix
 
What's new in p2 (2009)?
What's new in p2 (2009)?What's new in p2 (2009)?
What's new in p2 (2009)?
 
Best software development tools in 2021
Best software development tools in 2021Best software development tools in 2021
Best software development tools in 2021
 
Software engineering
Software engineeringSoftware engineering
Software engineering
 
Final ppt
Final pptFinal ppt
Final ppt
 
.Net Core
.Net Core.Net Core
.Net Core
 
Android crash course
Android crash courseAndroid crash course
Android crash course
 
Presentation 1 open source tools in continuous integration environment v1.0
Presentation 1   open source tools in continuous integration environment v1.0Presentation 1   open source tools in continuous integration environment v1.0
Presentation 1 open source tools in continuous integration environment v1.0
 
[Portland 365Sat] PCF Custom Controls
[Portland 365Sat] PCF Custom Controls[Portland 365Sat] PCF Custom Controls
[Portland 365Sat] PCF Custom Controls
 
A Software Factory Integrating Rational & WebSphere Tools
A Software Factory Integrating Rational & WebSphere ToolsA Software Factory Integrating Rational & WebSphere Tools
A Software Factory Integrating Rational & WebSphere Tools
 
Extend Eclipse p2 framework capabilities: Add your custom installation steps
Extend Eclipse p2 framework capabilities: Add your custom installation stepsExtend Eclipse p2 framework capabilities: Add your custom installation steps
Extend Eclipse p2 framework capabilities: Add your custom installation steps
 
Visual Studio 2012 introduction
Visual Studio  2012 introductionVisual Studio  2012 introduction
Visual Studio 2012 introduction
 
Managing Your Runtime With P2
Managing Your Runtime With P2Managing Your Runtime With P2
Managing Your Runtime With P2
 
A Sneak Peek At Visual Studio 2010 And .Net Framework 4.0
A Sneak Peek At Visual Studio 2010 And .Net Framework 4.0A Sneak Peek At Visual Studio 2010 And .Net Framework 4.0
A Sneak Peek At Visual Studio 2010 And .Net Framework 4.0
 
Asp.net Web Development.pdf
Asp.net Web Development.pdfAsp.net Web Development.pdf
Asp.net Web Development.pdf
 

Kürzlich hochgeladen

Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 

Kürzlich hochgeladen (20)

Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 

Workshop: Modularization of .NET Applications

  • 2. BASTA! Spring 2014 Rainer Stropek software architects gmbh Modularisierung Web http://www.timecockpit.com Mail rainer@timecockpit.com Twitter @rstropek Workshop Saves the day.
  • 4. Warum modulare Programmierung? The benefits expected of modular programming are:  Managerial - development time should be shortened because separate groups would work on each module with little need for communication  Product flexibility - it should be possible to make drastic changes to one module without a need to change others  Comprehensibility - it should be possible to study the system one module at a time. The whole system can therefore be better designed because it is better understood. Quelle: Parnas, On the Criteria To Be Used in Decomposing Systems into Modules, Carnegie-Mellon University, 1972
  • 5. Was ist eine Softwarefabrik? A software factory is an organizational structure that specializes in producing computer software applications or software components […] through an assembly process. The software is created by assembling predefined components. Traditional coding, is left only for creating new components or services. A composite application is the end result of manufacturing in a software factory. Quelle: “Software Factory” in Wikipedia
  • 6. Vorteile einer Softwarefabrik (1/2  Kernkompetenzen der Mitarbeiter werden hervorgehoben Fachlich orientierte Berater konfigurieren (Vokabular näher bei der jeweiligen Domäne des Kunden) Softwareentwickler erstellen Basiskomponenten  Steigerung der Effizienz Das Rad wird weniger oft neu erfunden  Steigerung der Qualität Anspruchsvolle QS-Maßnahmen für Basiskomponenten
  • 7. Vorteile einer Softwarefabrik (2/2  Reduktion der Projektrisiken Fachberater mit besserem Kundenverständnis Höhere Qualität der Basiskomponenten  Steigerung des Firmenwerts Systematisches Festhalten von Wissen über die Herstellung einer Familie von Softwarelösungen Design Patterns, Frameworks, Modelle, DSLs, Tools  Vereinfachung des Vertriebs- und Spezifikationsprozesses Konzentration auf projektspezifische Lösungsteile Quick Wins durch Standardkomponenten
  • 8. Was eine Softwarefabrik nicht will…  Reduktion des Entwicklungsprozesses auf standardisierte, mechanische Prozesse Im Gegenteil, mechanische Prozesse sollen Tool überlassen werden  Verringerung der Bedeutung von Menschen im Entwicklungsprozess  „Handwerk“ der Softwareentwicklung wird nicht gering geschätzt sondern gezielt eingesetzt  Entwicklung von Frameworks statt Lösungen für Kunden
  • 9. Software Factories  Economy of Scop Economy of Scale  Multiple implementations (=Copies) of the same design  Mehr oder weniger mechanische Vervielfältigung von Prototypen Massengüter Software (z.B. Auslieferung auf Datenträger) Economy of Scope  Production of multiple designs and their initial implementations  Ähnliche Designs (=Familien von Anwendungen) auf Grundlage gemeinsamer Techniken und Technologien Individuelle physische Güter (z.B. Brücken, Hochhäuser) Individualsoftware, Softwareplattformen (vgl. PaaS) Quelle: Greenfield J., Short K.: Software Factories
  • 10. Kosten/Nutzen Abwägung Kosten der Erstellung der Software Factory Vorteile bei der Herstellung mehrerer ähnlicher Produkte Spezialisierung als zentraler Erfolgsfaktor beim Einsatz der Software Factory Prinzipien
  • 11. Entwicklung einer Software Factory Projekt A Projekt B Custom Code Custom Code Base Class Library
  • 12. Entwicklung einer Software Factory Projekt A Projekt B Custom Code Custom Code Common Components Base Class Library
  • 13. Entwicklung einer Software Factory Projekt A Projekt B Model, Extensions, Configuration, Scripts Custom Component Custom Component Model, Extensions, Configuration, Scripts Common Components Base Class Library Custom Component Custom Component Standard components will be commoditized  3rd party components  make-or-buy decisions
  • 14. Entwicklung einer Software Factory Projekt A Projekt B Model, Extensions, Configuration, Scripts Model, Extensions, Configuration, Scripts Patterns, Practices, Guidelines Custom Component Custom Component Common Components Base Class Library Custom Component Custom Component
  • 15. Nette Theorie, aber in der Praxis??  Abstraktionsgrad Je abstrakter desto mächtiger  Je abstrakter desto spezifischer   Abhängigkeiten Vertrauen in Werkzeuge Vertrauen in Lieferanten Vertrauen in Mitarbeiter  Kleinster gemeinsamer Nenner Ausnutzung aller Möglichkeiten der zugrunde liegenden Plattform Performanceprobleme (Beispiel: OR-Mapper vs. T-SQL)
  • 16. Werkzeuge  Klassenbibliotheken  Dokumentation Statische Codeanalyse Deployment  Codegeneratoren  Vorlagen Patterns in Form von Assistenten  Domänenspezifische Sprachen MS Framework Design Guidelines Sandcastle StyleCop, Code Analysis, 3rd party tools NuGet Codegeneratoren T4, ANTLR StringTemplates Visual Studio Templates  XML-basierend oder individuell (Compiler-Compiler) Compiler (Codegenerator) vs. interpretiert Domänenspezifische Sprachen XAML (UI und Workflows), EF ANTLR (Compiler-Compiler)  Scriptsprachen  DLR, Project „Roslin“  Anwendungsmodularisierung  MEF, MAF Prozessautomatisierung   Qualitätssicherung Build Prozessautomatisierung Visual Studio Unit Tests TFS Buildautomatisierung
  • 17. NuGet Package Manager für die Microsoft-Entwicklungsplattform
  • 18. Was ist NuGet?  Werkzeug zur einfachen Verteilung von Paketen (=Libraries und Tools)  Alles Notwendige in einem Paket Binaries für verschiedene Plattformen Optional Symbole und Sourcen Anpassungen am Projekt (z.B. Referenzen, Änderungen am app/web.config)  UI-Integration in Visual Studio Ab VS2010, eingeschränkt auch in Mono Express-Editionen werden unterstützt  http://www.nuget.org http://nuget.codeplex.com/ (Sourcecode)
  • 19. NuGet in Visual Studio
  • 20. NuGet in Visual Studio  Package Manager Console  PowerShell console in Visual Studio  Automate Visual Studio and NuGet  NuGet PowerShell Reference
  • 21. NuGet Pakete erstellen  Kommandozeilentool nuget.exe Pakete erstellen (Pack Command) Pakete veröffentlichen (Push, Delete Command) Paket installieren (Install, Restore, Update Command) Generieren eines nuspec-Files (Spec Command) Wichtig für Buildautomatisierung Kommandozeilenreferenz  NuGet Package Explorer Grafisches UI zur Erstellung/Bearbeitung von NuGet Paketen und nuspec Files http://npe.codeplex.com/
  • 22. <?xml version="1.0" encoding="utf-16"?> <package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd"> <metadata> <id>CockpitFramework.Data</id> <version>$version$</version> <title>Cockpit Framework Data Layer</title> <authors>software architects gmbh</authors> <owners>software architects gmbh</owners> <requireLicenseAcceptance>false</requireLicenseAcceptance> <description>...</description> <releaseNotes></releaseNotes> <dependencies> <group targetFramework=".NETFramework4.0"> <dependency id="CockpitFramework.Dependencies" version="[$version$]" /> </group> <group targetFramework="sl5"> <dependency id="CockpitFramework.Dependencies" version="[$version$]" /> </group> </dependencies> </metadata> Example nuspec File
  • 23. <dependencies> <group targetFramework=".NETFramework4.0"> <dependency id="log4net" version="[1.2.11]" /> <dependency id="Microsoft.SqlServer.Compact.Private" version="[4.0.8482.1]" /> <dependency id="AvalonEdit" version="[4.2.0.8783]" /> <dependency id="ClosedXML" version="[0.68.1]" /> <dependency id="DocumentFormat.OpenXml" version="[1.0]" /> <dependency id="IronPython" version="[2.7.3]" /> <dependency id="LumenWorks.Framework.IO" version="[1.0.0]" /> <dependency id="Newtonsoft.Json" version="[5.0.6]" /> <dependency id="WindowsAzure.Storage" version="[2.0.5.1]" /> <dependency id="Microsoft.Bcl.Async" version="[1.0.16]" /> </group> <group targetFramework="sl5"> … </group> </dependencies> Example nuspec File Version range syntax
  • 24. <files> <!-- net4 --> <file src=".$configuration$TimeCockpit.Common.dll" target="libnet4" /> <file src=".$configuration$TimeCockpit.Data.dll" target="libnet4"/> … <!-- sl5 --> <file src=".SL$configuration$TimeCockpit.Common.dll" target="libsl5" /> <file src=".SL$configuration$TimeCockpit.Data.dll" target="libsl5" /> … <!-- include source code for symbols --> <file src="....*.cs" target="srcTimeCockpit.Common" /> <file src="....*.cs" target="srcTimeCockpit.Data" /> </package> Example nuspec File
  • 26. Versioning Notes  Things to remember NuGet never installs assemblies machine-wide (i.e. not in GAC) You cannot have multiple versions of the same DLL in one AppDomain  DLL Hell Policy too loose: Problems with breaking changes Policy too tight: Problems with library having dependencies on other libraries (e.g. ANTLR and ASP.NET MVC, everyone depending on Newtonsoft JSON)  For Library Publishers: SemVer X.Y.Z (Major.Minor.Patch) Rethink your strong naming policies
  • 27. <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="mscorcfg" publicKeyToken="b03f5f7f11d50a3a" culture=""/> <bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/> </dependentAssembly> </assemblyBinding> </runtime> Binding Redirects Note: NuGet can generate this for you Add-BindingRedirect Command See online reference for details
  • 28. <?xml version="1.0" encoding="utf-8"?> <packages> <package id="SomePackage" version="2.1.0" allowedVersions="[2,3)" /> </packages> Versioning Constraings in packges.config Manual editing necessary
  • 29. ILMerge Newtonsoft.JSO N 4.0.2 ILMerge Soliving version conflicts Google API Newtonsoft.JSO N 5.0.6 My Library My App Microsoft Download
  • 30. ILMerge "AssembliesGoogle.Apis.Authentication.OAuth2.dll" "AssembliesGoogle.Apis.dll" "AssembliesGoogle.Apis.Latitude.v1.dll" "AssembliesDotNetOpenAuth.dll" "Assemblieslog4net.dll" "AssembliesNewtonsoft.Json.Net35.dll" /out:"c:tempGoogle.Apis.All.dll" /lib:"Lib„ extern alias MyConfig; using Conf = MyConfig::System.Configuration; namespace MyTinyMvvmToolkit { public class NotificationObject { public void ReadConfiguration() { var setting = Conf.ConfigurationManager.AppSettings["MyDB"]; } } } ILMerge Soliving version conflicts C# extern alias
  • 31. <?xml version="1.0" encoding="utf-16"?> <package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd"> <metadata>…</metadata> Content Files New in NuGet 2.6: XDT <files> <file src="contentapp.config.transform" target="content" /> <file src="contentTimeCockpitInitialization.cs.pp" target="content" /> </files> </package> <configuration> <startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/> </startup> <system.data> <DbProviderFactories> <remove invariant="System.Data.SqlServerCe.4.0"/> <add name="Microsoft SQL Server Compact Data Provider 4.0" invariant="System.Data.SqlServerCe.4.0" description=".NET Framework Data Provider for Microsoft SQL Server Compact" type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=4.0.0.1, Culture=neutral, PublicKeyToken=89845dcd8080cc91"/> </DbProviderFactories> </system.data> </configuration>
  • 32. … namespace $rootnamespace$ { using System; /// <summary> /// Class taking care of cockpit framework initialization /// </summary> public class TimeCockpitInitialization { … } } Content Files Sourcecode Transformations in .cs.pp File Available properties see MSDN User PowerShell scripts to modify project properties NuGet Docs
  • 33. Nuget in Practice Nuget at software architects Nuspec files Files Dependencies Build Packages in NuGet Explorer Packages in VS Demo
  • 34. Publishing NuGet Packages  http://www.nuget.org Public NuGet Feed  Create your private feed File system Private NuGet Server For details see NuGet Help  Use a NuGet SaaS like MyGet http://www.myget.org/
  • 36. Original Goals  Before MEF Multiple extensibility mechanism for different Microsoft tools (e.g. Visual Studio, Trace Listeners, etc.) Developers outside of MS had the same problem  MEF: Provide standard mechanisms for hooks for 3rd party extensions  Goal: Open and Dynamic Applications Make it easier and cheaper to build extensible applications and extensions
  • 37. MEF vs. MAF  Managed AddIn Framework System.AddIn  MAF has higher-level goals Isolate extension Load and unload extensions API Compatibility  Adding MAF leads to higher effort than adding MEF A single application can use both
  • 38. [Export(typeof(Shape))] public class Square : Shape { // Implementation } [Export(typeof(Shape))] public class Circle : Shape { // Implementation } Export with name or type MEF „Hello World“ Anatomy of a program with MEF Defaults to typeof(Toolbox) [Export] public class Toolbox { [ImportMany] public Shape[] Shapes { get; set; } // Additional implementation... } […] var catalog = new AssemblyCatalog(typeof(Square).Assembly); var container = new CompositionContainer(catalog); Toolbox toolbox = container.GetExportedValue<Toolbox>(); Attributed Programming Model
  • 39. MEF „Hello World“  Parts Square, Circle and Toolbox  Dependencies Imports (Import-Attribute) E.g. Toolbox.Shapes  Capabilities Exports (Export-Attribute) E.g. Square, Circle
  • 40. MEF „Hello World“ MEF Basics Basic Exports Basic Imports Catalogs Composition Demo
  • 41. Exports And Imports  Export attribute Class Field Property Method  Import attribute Field Property Constructor parameter  Export and import must have the same contract Contract name and contract type Contract name and type can be inferred from the decorated element
  • 42. [Export] public class NumOne { [Import] public IMyData MyData { get; set; } } Inherited Exports Import automatically inherited Export NOT inherited  NumTwo has no exports public class NumTwo : NumOne { } [InheritedExport] public class NumThree { [Export] Public IMyData MyData { get; set; } } public class NumFour : NumThree { } Member-level exports are never inherited Inherits export with contract NumThree (including all metadata)
  • 43. MEF Catalogs  Catalogs provide components  Derived from System.ComponentModel.Composition. Primitives.ComposablePartCatalog AssemblyCatalog Parse all the parts present in a specified assembly DirectoryCatalog Parses the contents of a directory TypeCatalog Accepts type array or a list of managed types AggregateCatalog Collection of ComposablePartCatalog objects
  • 44. Catalogs Loading of modules using DirectoryCatalog Demo
  • 45. public class MyClass { [Import] public Lazy<IMyAddin> MyAddin { get; set; } } Lazy Imports Imported object is not instantiated immediately Imported (only) when accessed
  • 46. [ImportingConstructor] public MyClass( [Import(typeof(IMySubAddin))] IMyAddin MyAddin) { Could be removed here; automatically _theAddin = MyAddin; imported } Prerequisite Imports Composition engine uses parameter-less constructor by default Use a different constructor with ImportingConstructor attribute
  • 47. public class MyClass { [Import(AllowDefault = true)] public Plugin thePlugin { get; set; } } Optional Imports By default composition fails if an import could not be fulfilled Use AllowDefault property to specify optional imports
  • 48. Creation Policy  RequiredCreationPolicy property  CreationPolicy.Any Shared if importer does not explicitly request NonShared  CreationPolicy.Shared Single shared instance of the part will be created for all requestors  CreationPolicy.NonShared New non-shared instance of the part will be created for every requestor
  • 49. MEF Object Lifetime  Container holds references to all disposable parts Only container can call Dispose on these objects  Manage lifetime of disposable objects Dispose the container  it will dispose all managed objects Call ReleaseExport on a non-shared object to dispose just this object Use ExportFactory<T> to control lifetime  IPartImportsSatisfiedNotification Implement if you need to get informed when composition has been completed
  • 51. Metadata and Metadata views Advanced exports
  • 52. Goal  Export provides additional metadata so that importing part can decide which one to use  Import can inspect metadata without creating exporting part  Prerequisite: Lazy import
  • 53. namespace MetadataSample { public interface ITranslatorMetadata { string SourceLanguage { get; } [DefaultValue("en-US")] string TargetLanguage { get; } } } Metadata Export Metadata can be mapped to metadata view interface namespace MetadataSample { [Export(typeof(ITranslator))] [ExportMetadata("SourceLanguage", "de-DE")] [ExportMetadata("TargetLanguage", "en-US")] public class GermanEnglishTranslator : ITranslator { public string Translate(string source) { throw new NotImplementedException(); } } }
  • 54. namespace MetadataSample { class Program { static void Main(string[] args) { var catalog = new AssemblyCatalog( typeof(ITranslator).Assembly); var container = new CompositionContainer(catalog); // We need a translator from hungarian to english Lazy<ITranslator, ITranslatorMetadata> translator = container .GetExports<ITranslator, ITranslatorMetadata>() .Where(t => t.Metadata.SourceLanguage == "hu-HU" && t.Metadata.TargetLanguage == "en-US") .FirstOrDefault(); } } } Metadata (Continued)
  • 55. [Export(typeof(ITranslator))] [ExportMetadata("SourceLanguage", "de-DE")] [ExportMetadata("TargetLanguage", "en-US")] public class GermanEnglishTranslator : ITranslator { public string Translate( string source) { throw new NotImplementedException(); } } [TranslatorExport("de-DE", "en-US")] public class GermanEnglishTranslator : ITranslator { public string Translate( string source) { throw new NotImplementedException(); } } Custom Export Attributes Custom export attributes makes code much cleaner.
  • 56. [MetadataAttribute] [AttributeUsage(AttributeTargets.Class, AllowMultiple = false)] public class TranslatorExportAttribute : ExportAttribute, ITranslatorMetadata { public TranslatorExportAttribute( string sourceLanguage, string targetLanguage) : base(typeof(ITranslator)) { this.SourceLanguage = sourceLanguage; this.TargetLanguage = targetLanguage; } public string SourceLanguage { get; private set; } public string TargetLanguage { get; private set; } } } Custom Export Attributes (Continued)
  • 58. Goals  Reduce the need for attributes Note that attributes in the source code override conventions  Convention-based coupling Infer MEF attributes for objects‘ types Example: Export all classes derived from Controller  System.ComponentModel.Composition.Registration. RegistrationBuilder ForType – creates a rule for a single type ForTypesDerivedFrom – creates a rule for all types derived from a certain type ForTypesMatching – creates a custom rule based on a predicate Returns a PartBuilder object that is used to configure imports and exports
  • 59. public interface IShapeMetadata { bool Is2D { get; } }; public class Shape { } public class Circle : Shape { } public class Rectangle : Shape { } Example […] [ImportMany(typeof(Shape))] private Shape[] shapes; Export all descendants of a given class […] // Export all descendants of Shape and add some metadata var rb = new RegistrationBuilder(); var pb = rb.ForTypesDerivedFrom<Shape>(); pb.Export<Shape>(eb => eb.AddMetadata("Is2D", true)) .SetCreationPolicy(CreationPolicy.NonShared); // Use registration builder with catalog var me = new Program(); var container = new CompositionContainer( new AssemblyCatalog(me.GetType().Assembly, rb)); container.ComposeParts(me); Add some metadata Set a creation policy
  • 60. BASTA! Spring 2014 Rainer Stropek software architects gmbh Q&A Mail rainer@timecockpit.com Web http://www.timecockpit.com Twitter @rstropek Thank your for coming! Saves the day.
  • 61. is the leading time tracking solution for knowledge workers. Graphical time tracking calendar, automatic tracking of your work using signal trackers, high level of extensibility and customizability, full support to work offline, and SaaS deployment model make it the optimal choice especially in the IT consulting business. Try for free and without any risk. You can get your trial account at http://www.timecockpit.com. After the trial period you can use for only 0,20€ per user and day without a minimal subscription time and without a minimal number of users.
  • 62. ist die führende Projektzeiterfassung für Knowledge Worker. Grafischer Zeitbuchungskalender, automatische Tätigkeitsaufzeichnung über Signal Tracker, umfassende Erweiterbarkeit und Anpassbarkeit, volle Offlinefähigkeit und einfachste Verwendung durch SaaS machen es zur Optimalen Lösung auch speziell im IT-Umfeld. Probieren Sie kostenlos und ohne Risiko einfach aus. Einen Testzugang erhalten Sie unter http://www.timecockpit.com. Danach nutzen Sie um nur 0,20€ pro Benutzer und Tag ohne Mindestdauer und ohne Mindestbenutzeranzahl.