SlideShare a Scribd company logo
AOP mit .NET



12.04.2012
Dipl.-Inf. (FH) Johannes Hoppe
Johannes Hoppe
ASP.NET MVC Webentwickler
  www.johanneshoppe.de
01
Architektur und Patterns
Patterns
software craftsmanship
Business Code



public class CustomerProcesses
{
    public void RentBook( int bookId, int customerId )
    {
        Book book = Book.GetById( bookId );
        Customer customer = Customer.GetById( customerId );

         book.RentedTo = customer;
         customer.AccountLines.Add(
          string.Format( "Rental of book {0}.", book ), book.RentalPrice
);
         customer.Balance -= book.RentalPrice;
     }
}
Business Code
Business Code



public class CustomerProcesses
{
    public void RentBook( int bookId, int customerId )
    {
        Book book = Book.GetById( bookId );
        Customer customer = Customer.GetById( customerId );

         book.RentedTo = customer;
         customer.AccountLines.Add(
          string.Format( "Rental of book {0}.", book ), book.RentalPrice
);
         customer.Balance -= book.RentalPrice;
     }
}
Business Code
+ Logging
                internal class CustomerProcesses
                {
                    private static readonly TraceSource trace =
                        new TraceSource( typeof (CustomerProcesses).FullName );

                        public void RentBook( int bookId, int customerId )
                        {
                           trace.TraceInformation(
                                "Entering CustomerProcesses.CreateCustomer( bookId = {0},
                                 customerId = {1} )",
                                bookId, customerId );
                           try
                           {
                                Book book = Book.GetById( bookId );
                                Customer customer = Customer.GetById( customerId );

                                book.RentedTo = customer;
                                customer.AccountLines.Add(
                                    string.Format( "Rental of book {0}.", book ), book.RentalPrice );
                                customer.Balance -= book.RentalPrice;

                                trace.TraceInformation(
                                  "Leaving CustomerProcesses.CreateCustomer( bookId = {0}, customerId = {1} )",
                                  bookId, customerId );
                            }
                            catch ( Exception e )
                            {
                                trace.TraceEvent( TraceEventType.Error, 0,
                                                  "Exception: CustomerProcesses.CreateCustomer(
                                                  bookId = {0}, customerId = {1} ) failed : {2}",
                                                  bookId, customerId, e.Message );
                                 throw;
                            }
                    }
                }
Business Code
+ Logging
                   internal class CustomerProcesses

+ Vorbedingungen   {
                       private static readonly TraceSource trace =
                           new TraceSource(typeof(CustomerProcesses).FullName);

                       public void RentBook(int bookId, int customerId)
                       {
                           if (bookId <= 0) throw new ArgumentOutOfRangeException("bookId");
                           if (customerId <= 0) throw new ArgumentOutOfRangeException("customerId");

                           trace.TraceInformation(
                               "Entering CustomerProcesses.CreateCustomer( bookId = {0}, customerId = {1} )",
                               bookId, customerId);

                           try
                           {
                                 Book book = Book.GetById(bookId);
                                 Customer customer = Customer.GetById(customerId);

                                 book.RentedTo = customer;
                                 customer.AccountLines.Add(string.Format("Rental of book {0}.", book),
                                                           book.RentalPrice);
                                 customer.Balance -= book.RentalPrice;

                                 trace.TraceInformation(
                                     "Leaving CustomerProcesses.CreateCustomer( bookId = {0},
                                     customerId = {1} )“, bookId, customerId);
                           }
                           catch (Exception e)
                           {
                               trace.TraceEvent(TraceEventType.Error, 0,
                                      "Exception: CustomerProcesses.CreateCustomer( bookId = {0},
                                       customerId = {1} ) failed : {2}",
                                       bookId, customerId, e.Message);
                               throw;
                           }
                       }
                   }
Business Code
   + Logging        + Transaktionen
   + Vorbedingungen
internal class CustomerProcesses                                                                 ts.Complete();
{                                                                                            }
    private static readonly TraceSource trace =
        new TraceSource(typeof(CustomerProcesses).FullName);                                 break;
                                                                                         }
    public void RentBook(int bookId, int customerId)                                     catch (TransactionConflictException)
    {                                                                                    {
        if (bookId <= 0)                                                                     if (i < 3)
          throw new ArgumentOutOfRangeException("bookId");                                       continue;
        if (customerId <= 0)                                                                 else
          throw new ArgumentOutOfRangeException("customerId");                                   throw;
                                                                                         }
        trace.TraceInformation(                                                      }
            "Entering CustomerProcesses.CreateCustomer( bookId = {0},
            customerId = {1} )“, bookId, customerId);                                trace.TraceInformation(
                                                                                         "Leaving CustomerProcesses.CreateCustomer(
        try                                                                              bookId = {0}, customerId = {1} )",
        {                                                                                bookId, customerId);
              for (int i = 0; ; i++)                                             }
              {                                                                  catch (Exception e)
                  try                                                            {
                  {                                                                  trace.TraceEvent(TraceEventType.Error, 0,
                      using (var ts = new TransactionScope())                          "Exception: CustomerProcesses.CreateCustomer( bookId = {0},
                      {                                                                customerId = {1} ) failed : {2}",
                          Book book = Book.GetById(bookId);                            bookId, customerId, e.Message);
                          Customer customer =                                        throw;
                            Customer.GetById(customerId);                        }
                                                                             }
                         book.RentedTo = customer;
                         customer.AccountLines.Add(                      }
                           string.Format("Rental of book {0}.", book),
                           book.RentalPrice);
                         customer.Balance -= book.RentalPrice;
Business Code
   + Logging        + Transaktionen
   + Vorbedingungen + Exception Handling
internal class CustomerProcesses
{                                                                                                            ts.Complete();
    private static readonly TraceSource trace =                                                          }
        new TraceSource(typeof(CustomerProcesses).FullName);
                                                                                                          break;
    public void RentBook(int bookId, int customerId)                                                  }
    {                                                                                                 catch ( TransactionConflictException )
        if (bookId <= 0) throw new ArgumentOutOfRangeException("bookId");                             {
        if (customerId <= 0)                                                                              if ( i < 3 )
            throw new ArgumentOutOfRangeException("customerId");                                              continue;
                                                                                                          else
        try                                                                                                   throw;
        {                                                                                             }
              trace.TraceInformation(                                                             }
                  "Entering CustomerProcesses.CreateCustomer(
                   bookId = {0}, customerId = {1} )",                                             trace.TraceInformation(
                  bookId, customerId );                                                               "Leaving CustomerProcesses.CreateCustomer(
                                                                                                      bookId = {0}, customerId = {1} )",
              try                                                                                     bookId, customerId );
              {                                                                               }
                    for ( int i = 0;; i++ )                                                   catch ( Exception e )
                    {                                                                         {
                        try                                                                       trace.TraceEvent( TraceEventType.Error, 0,
                        {                                                                          "Exception: CustomerProcesses.CreateCustomer(
                            using ( var ts = new TransactionScope() )                               bookId = {0}, customerId = {1} ) failed : {2}",
                            {                                                                                       bookId, customerId, e.Message );
                                Book book = Book.GetById( bookId );                               throw;
                                Customer customer = Customer.GetById( customerId );           }
                                                                                          }
                               book.RentedTo = customer;                                  catch ( Exception e )
                               customer.AccountLines.Add(                                 {
                                  string.Format( "Rental of book {0}.", book ),               if (ExceptionManager.Handle(e)) throw;
                                  book.RentalPrice );                                     }
                               customer.Balance -= book.RentalPrice;                  }
Business Code
+ Logging        + Transaktionen
+ Vorbedingungen + Exception Handling

+ Feature X
+ Feature Y
+ Feature Z
+…
Kern-            Seperation
funktionalitäten    of Concerns
  (Core Concerns)
VS
VS
    Nicht-
  Funktionale
 Anforderungen
     (Crosscutting Concerns)
Cross-Cutting Concerns


           Security             Data Binding
           Exception Handling   Thread Sync
           Tracing              Caching
           Monitoring           Validation
           Transaction          …
OOP



 OOP
+ AOP
Spring.NET
PostSharp    LinFu    Castle
                      MS Unity




Build-Time   Hybrid   Run-Time
Build-Time: “Statisch”          Run-Time: “Dynamisch”

Erfolgt bei Kompilierung        Erfolgt zur Laufzeit
Code wird direkt verändert      Code bleibt unverändert
Zur Laufzeit keine Änderungen   Zur Laufzeit Änderungen möglich
Auch auf Properties, Felder,    Aufruf wird über Proxy
Events anwendbar                umgeleitet
Keine Interfaces erforderlich   idR. Interfaces erforderlich (Proxy)
02
Live Coding
Logging
LogTimeAspect




          webnoteaop.codeplex.com
Exceptions
ConvertExceptionAspect




                         webnoteaop.codeplex.com
Validierung
ValidationGuardAspect




                        webnoteaop.codeplex.com
Caching
SimpleCacheAspect




           webnoteaop.codeplex.com
03
AOP 1 x 1
AspectJ Begriffe




                   Join Point
                   Pointcut
                   Advice
                   Aspect
AspectJ Begriffe




                   Join Point
                   Pointcut
                   Advice
                   Aspect
IL Code Vorher




         [LogTimeAspect]
         public ActionResult Index()
         {
             IEnumerable<NoteWithCategories> notes =
                 this.WebNoteService.ReadAll();
             return View(notes);
         }
IL Code Nachher

   public ActionResult Index()
   {
       ActionResult CS$1$2__returnValue;
       MethodExecutionArgs CS$0$3__aspectArgs =
           new MethodExecutionArgs(null, null);
       <>z__Aspects.a68.OnEntry(CS$0$3__aspectArgs);
       try
       {
           IEnumerable<NoteWithCategories> notes =
               this.WebNoteService.ReadAll();
           ActionResult CS$1$0000 = base.View(notes);
           CS$1$2__returnValue = CS$1$0000;
       }
       finally
       {
           <>z__Aspects.a68.OnExit(CS$0$3__aspectArgs);
       }
       return CS$1$2__returnValue;
   }
Originale Methode       Aspekt Klasse

                            OnEntry
  try
  {
        Method Body
                            OnSuccess
  }
  catch (Exception e)
  {
                            OnException
  }
  finally
  {
                             OnExit
  }

                        : OnMethodBoundaryAspect
04
Installation
www.sharpcrafters.com/postsharp/download
nuget
http://nuget.org/packages/PostSharp
Spring.NET            PostSharp
springframework.net   sharpcrafters.com


Castle                Demo Download
castleproject.org     webnoteaop.codeplex.com


Unity
unity.codeplex.com
FRAGEN?
Bis bald
›   10.05.2012 – .NET UG Karlsruhe: NoSQL
›   14.05.2012 – .NET Developer Conference (DDC)
                 .Nürnberg: NoSQL
Vielen Dank!
Primitive Aspekt-Typen


›   MethodBoundaryAspect       ›   LocationInterceptionAspect
    › OnEntry                       › OnGetValue
    › OnSuccess                     › OnSetValue
    › OnException
    › OnExit                   ›   EventInterceptionAspect
                                    › OnAddHandler
›   OnExceptionAspect               › OnRemoveHandler
     › OnException                  › OnInvokeHandler

›   MethodInterceptionAspect   ›   MethodImplementationAspect
    › OnInvoke                     › OnInvoke

                               ›   CompositionAspect
                                    › CreateImplementationObject
Bildnachweise
Ausgewählter Ordner © Spectral-Design – Fotolia.com
Warnhinweis-Schild © Sascha Tiebel – Fotolia.com
Liste abhaken © Dirk Schumann – Fotolia.com
3D rendering of an architecture model 2 © Franck Boston – Fotolia.com
Healthcare © ArtmannWitte – Fotolia.com
Stressed businessman © Selecstock – Fotolia.com
Funny cartoon boss © artenot – Fotolia.com

More Related Content

Viewers also liked

2012-10-12 - NoSQL in .NET - mit Redis und Mongodb
2012-10-12 - NoSQL in .NET - mit Redis und Mongodb2012-10-12 - NoSQL in .NET - mit Redis und Mongodb
2012-10-12 - NoSQL in .NET - mit Redis und MongodbJohannes Hoppe
 
2013 02-26 - Software Tests with Mongo db
2013 02-26 - Software Tests with Mongo db2013 02-26 - Software Tests with Mongo db
2013 02-26 - Software Tests with Mongo db
Johannes Hoppe
 
2012-09-17 - WDC12: Node.js & MongoDB
2012-09-17 - WDC12: Node.js & MongoDB2012-09-17 - WDC12: Node.js & MongoDB
2012-09-17 - WDC12: Node.js & MongoDB
Johannes Hoppe
 
Tema 4 conocimiento reproducción humana
Tema 4 conocimiento reproducción humanaTema 4 conocimiento reproducción humana
Tema 4 conocimiento reproducción humana
Ana María Rodriguez
 
Modelling Natural Ventilation in IES-VE: Case studies & Research Outlook
Modelling Natural Ventilation in IES-VE: Case studies & Research OutlookModelling Natural Ventilation in IES-VE: Case studies & Research Outlook
Modelling Natural Ventilation in IES-VE: Case studies & Research Outlook
IES VE
 
El Inicio De La Edad Media
El Inicio De La Edad MediaEl Inicio De La Edad Media
El Inicio De La Edad Media
zhuyibamu
 
Fibromialgia y Sindrome de Fatiga Cronica
Fibromialgia y Sindrome de Fatiga CronicaFibromialgia y Sindrome de Fatiga Cronica
Fibromialgia y Sindrome de Fatiga Cronica
Consultoris Vitae
 
2012-10-16 - WebTechCon 2012: HTML5 & WebGL
2012-10-16 - WebTechCon 2012: HTML5 & WebGL2012-10-16 - WebTechCon 2012: HTML5 & WebGL
2012-10-16 - WebTechCon 2012: HTML5 & WebGLJohannes Hoppe
 
2012-09-18 - HTML5 & WebGL
2012-09-18 - HTML5 & WebGL2012-09-18 - HTML5 & WebGL
2012-09-18 - HTML5 & WebGL
Johannes Hoppe
 

Viewers also liked (9)

2012-10-12 - NoSQL in .NET - mit Redis und Mongodb
2012-10-12 - NoSQL in .NET - mit Redis und Mongodb2012-10-12 - NoSQL in .NET - mit Redis und Mongodb
2012-10-12 - NoSQL in .NET - mit Redis und Mongodb
 
2013 02-26 - Software Tests with Mongo db
2013 02-26 - Software Tests with Mongo db2013 02-26 - Software Tests with Mongo db
2013 02-26 - Software Tests with Mongo db
 
2012-09-17 - WDC12: Node.js & MongoDB
2012-09-17 - WDC12: Node.js & MongoDB2012-09-17 - WDC12: Node.js & MongoDB
2012-09-17 - WDC12: Node.js & MongoDB
 
Tema 4 conocimiento reproducción humana
Tema 4 conocimiento reproducción humanaTema 4 conocimiento reproducción humana
Tema 4 conocimiento reproducción humana
 
Modelling Natural Ventilation in IES-VE: Case studies & Research Outlook
Modelling Natural Ventilation in IES-VE: Case studies & Research OutlookModelling Natural Ventilation in IES-VE: Case studies & Research Outlook
Modelling Natural Ventilation in IES-VE: Case studies & Research Outlook
 
El Inicio De La Edad Media
El Inicio De La Edad MediaEl Inicio De La Edad Media
El Inicio De La Edad Media
 
Fibromialgia y Sindrome de Fatiga Cronica
Fibromialgia y Sindrome de Fatiga CronicaFibromialgia y Sindrome de Fatiga Cronica
Fibromialgia y Sindrome de Fatiga Cronica
 
2012-10-16 - WebTechCon 2012: HTML5 & WebGL
2012-10-16 - WebTechCon 2012: HTML5 & WebGL2012-10-16 - WebTechCon 2012: HTML5 & WebGL
2012-10-16 - WebTechCon 2012: HTML5 & WebGL
 
2012-09-18 - HTML5 & WebGL
2012-09-18 - HTML5 & WebGL2012-09-18 - HTML5 & WebGL
2012-09-18 - HTML5 & WebGL
 

More from Johannes Hoppe

2017 - NoSQL Vorlesung Mosbach
2017 - NoSQL Vorlesung Mosbach2017 - NoSQL Vorlesung Mosbach
2017 - NoSQL Vorlesung Mosbach
Johannes Hoppe
 
NoSQL - Hands on
NoSQL - Hands onNoSQL - Hands on
NoSQL - Hands on
Johannes Hoppe
 
Einführung in Angular 2
Einführung in Angular 2Einführung in Angular 2
Einführung in Angular 2
Johannes Hoppe
 
MDC kompakt 2014: Hybride Apps mit Cordova, AngularJS und Ionic
MDC kompakt 2014: Hybride Apps mit Cordova, AngularJS und IonicMDC kompakt 2014: Hybride Apps mit Cordova, AngularJS und Ionic
MDC kompakt 2014: Hybride Apps mit Cordova, AngularJS und Ionic
Johannes Hoppe
 
2015 02-09 - NoSQL Vorlesung Mosbach
2015 02-09 - NoSQL Vorlesung Mosbach2015 02-09 - NoSQL Vorlesung Mosbach
2015 02-09 - NoSQL Vorlesung Mosbach
Johannes Hoppe
 
2012-06-25 - MapReduce auf Azure
2012-06-25 - MapReduce auf Azure2012-06-25 - MapReduce auf Azure
2012-06-25 - MapReduce auf Azure
Johannes Hoppe
 
2013-06-25 - HTML5 & JavaScript Security
2013-06-25 - HTML5 & JavaScript Security2013-06-25 - HTML5 & JavaScript Security
2013-06-25 - HTML5 & JavaScript Security
Johannes Hoppe
 
2013-06-24 - Software Craftsmanship with JavaScript
2013-06-24 - Software Craftsmanship with JavaScript2013-06-24 - Software Craftsmanship with JavaScript
2013-06-24 - Software Craftsmanship with JavaScript
Johannes Hoppe
 
2013-06-15 - Software Craftsmanship mit JavaScript
2013-06-15 - Software Craftsmanship mit JavaScript2013-06-15 - Software Craftsmanship mit JavaScript
2013-06-15 - Software Craftsmanship mit JavaScript
Johannes Hoppe
 
2013 05-03 - HTML5 & JavaScript Security
2013 05-03 -  HTML5 & JavaScript Security2013 05-03 -  HTML5 & JavaScript Security
2013 05-03 - HTML5 & JavaScript Security
Johannes Hoppe
 
2013-03-23 - NoSQL Spartakiade
2013-03-23 - NoSQL Spartakiade2013-03-23 - NoSQL Spartakiade
2013-03-23 - NoSQL Spartakiade
Johannes Hoppe
 
2013-02-21 - .NET UG Rhein-Neckar: JavaScript Best Practices
2013-02-21 - .NET UG Rhein-Neckar: JavaScript Best Practices2013-02-21 - .NET UG Rhein-Neckar: JavaScript Best Practices
2013-02-21 - .NET UG Rhein-Neckar: JavaScript Best Practices
Johannes Hoppe
 
2012-08-29 - NoSQL Bootcamp (Redis, RavenDB & MongoDB für .NET Entwickler)
2012-08-29 - NoSQL Bootcamp (Redis, RavenDB & MongoDB für .NET Entwickler)2012-08-29 - NoSQL Bootcamp (Redis, RavenDB & MongoDB für .NET Entwickler)
2012-08-29 - NoSQL Bootcamp (Redis, RavenDB & MongoDB für .NET Entwickler)
Johannes Hoppe
 
2012-05-14 NoSQL in .NET - mit Redis und MongoDB
2012-05-14 NoSQL in .NET - mit Redis und MongoDB2012-05-14 NoSQL in .NET - mit Redis und MongoDB
2012-05-14 NoSQL in .NET - mit Redis und MongoDB
Johannes Hoppe
 
2012-05-10 - UG Karlsruhe: NoSQL in .NET - mit Redis und MongoDB
2012-05-10 - UG Karlsruhe: NoSQL in .NET - mit Redis und MongoDB2012-05-10 - UG Karlsruhe: NoSQL in .NET - mit Redis und MongoDB
2012-05-10 - UG Karlsruhe: NoSQL in .NET - mit Redis und MongoDBJohannes Hoppe
 
2012-03-20 - Getting started with Node.js and MongoDB on MS Azure
2012-03-20 - Getting started with Node.js and MongoDB on MS Azure2012-03-20 - Getting started with Node.js and MongoDB on MS Azure
2012-03-20 - Getting started with Node.js and MongoDB on MS Azure
Johannes Hoppe
 
2012-01-31 NoSQL in .NET
2012-01-31 NoSQL in .NET2012-01-31 NoSQL in .NET
2012-01-31 NoSQL in .NET
Johannes Hoppe
 
2011-12-13 NoSQL aus der Praxis
2011-12-13 NoSQL aus der Praxis2011-12-13 NoSQL aus der Praxis
2011-12-13 NoSQL aus der Praxis
Johannes Hoppe
 
DMDW 8. Student Presentation - Groovy to MongoDB
DMDW 8. Student Presentation - Groovy to MongoDBDMDW 8. Student Presentation - Groovy to MongoDB
DMDW 8. Student Presentation - Groovy to MongoDB
Johannes Hoppe
 
DMDW 5. Student Presentation - Pentaho Data Integration (Kettle)
DMDW 5. Student Presentation - Pentaho Data Integration (Kettle)DMDW 5. Student Presentation - Pentaho Data Integration (Kettle)
DMDW 5. Student Presentation - Pentaho Data Integration (Kettle)
Johannes Hoppe
 

More from Johannes Hoppe (20)

2017 - NoSQL Vorlesung Mosbach
2017 - NoSQL Vorlesung Mosbach2017 - NoSQL Vorlesung Mosbach
2017 - NoSQL Vorlesung Mosbach
 
NoSQL - Hands on
NoSQL - Hands onNoSQL - Hands on
NoSQL - Hands on
 
Einführung in Angular 2
Einführung in Angular 2Einführung in Angular 2
Einführung in Angular 2
 
MDC kompakt 2014: Hybride Apps mit Cordova, AngularJS und Ionic
MDC kompakt 2014: Hybride Apps mit Cordova, AngularJS und IonicMDC kompakt 2014: Hybride Apps mit Cordova, AngularJS und Ionic
MDC kompakt 2014: Hybride Apps mit Cordova, AngularJS und Ionic
 
2015 02-09 - NoSQL Vorlesung Mosbach
2015 02-09 - NoSQL Vorlesung Mosbach2015 02-09 - NoSQL Vorlesung Mosbach
2015 02-09 - NoSQL Vorlesung Mosbach
 
2012-06-25 - MapReduce auf Azure
2012-06-25 - MapReduce auf Azure2012-06-25 - MapReduce auf Azure
2012-06-25 - MapReduce auf Azure
 
2013-06-25 - HTML5 & JavaScript Security
2013-06-25 - HTML5 & JavaScript Security2013-06-25 - HTML5 & JavaScript Security
2013-06-25 - HTML5 & JavaScript Security
 
2013-06-24 - Software Craftsmanship with JavaScript
2013-06-24 - Software Craftsmanship with JavaScript2013-06-24 - Software Craftsmanship with JavaScript
2013-06-24 - Software Craftsmanship with JavaScript
 
2013-06-15 - Software Craftsmanship mit JavaScript
2013-06-15 - Software Craftsmanship mit JavaScript2013-06-15 - Software Craftsmanship mit JavaScript
2013-06-15 - Software Craftsmanship mit JavaScript
 
2013 05-03 - HTML5 & JavaScript Security
2013 05-03 -  HTML5 & JavaScript Security2013 05-03 -  HTML5 & JavaScript Security
2013 05-03 - HTML5 & JavaScript Security
 
2013-03-23 - NoSQL Spartakiade
2013-03-23 - NoSQL Spartakiade2013-03-23 - NoSQL Spartakiade
2013-03-23 - NoSQL Spartakiade
 
2013-02-21 - .NET UG Rhein-Neckar: JavaScript Best Practices
2013-02-21 - .NET UG Rhein-Neckar: JavaScript Best Practices2013-02-21 - .NET UG Rhein-Neckar: JavaScript Best Practices
2013-02-21 - .NET UG Rhein-Neckar: JavaScript Best Practices
 
2012-08-29 - NoSQL Bootcamp (Redis, RavenDB & MongoDB für .NET Entwickler)
2012-08-29 - NoSQL Bootcamp (Redis, RavenDB & MongoDB für .NET Entwickler)2012-08-29 - NoSQL Bootcamp (Redis, RavenDB & MongoDB für .NET Entwickler)
2012-08-29 - NoSQL Bootcamp (Redis, RavenDB & MongoDB für .NET Entwickler)
 
2012-05-14 NoSQL in .NET - mit Redis und MongoDB
2012-05-14 NoSQL in .NET - mit Redis und MongoDB2012-05-14 NoSQL in .NET - mit Redis und MongoDB
2012-05-14 NoSQL in .NET - mit Redis und MongoDB
 
2012-05-10 - UG Karlsruhe: NoSQL in .NET - mit Redis und MongoDB
2012-05-10 - UG Karlsruhe: NoSQL in .NET - mit Redis und MongoDB2012-05-10 - UG Karlsruhe: NoSQL in .NET - mit Redis und MongoDB
2012-05-10 - UG Karlsruhe: NoSQL in .NET - mit Redis und MongoDB
 
2012-03-20 - Getting started with Node.js and MongoDB on MS Azure
2012-03-20 - Getting started with Node.js and MongoDB on MS Azure2012-03-20 - Getting started with Node.js and MongoDB on MS Azure
2012-03-20 - Getting started with Node.js and MongoDB on MS Azure
 
2012-01-31 NoSQL in .NET
2012-01-31 NoSQL in .NET2012-01-31 NoSQL in .NET
2012-01-31 NoSQL in .NET
 
2011-12-13 NoSQL aus der Praxis
2011-12-13 NoSQL aus der Praxis2011-12-13 NoSQL aus der Praxis
2011-12-13 NoSQL aus der Praxis
 
DMDW 8. Student Presentation - Groovy to MongoDB
DMDW 8. Student Presentation - Groovy to MongoDBDMDW 8. Student Presentation - Groovy to MongoDB
DMDW 8. Student Presentation - Groovy to MongoDB
 
DMDW 5. Student Presentation - Pentaho Data Integration (Kettle)
DMDW 5. Student Presentation - Pentaho Data Integration (Kettle)DMDW 5. Student Presentation - Pentaho Data Integration (Kettle)
DMDW 5. Student Presentation - Pentaho Data Integration (Kettle)
 

Recently uploaded

Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
MichaelKnudsen27
 
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying AheadDigital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Wask
 
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
Jason Yip
 
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
Edge AI and Vision Alliance
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
Pixlogix Infotech
 
GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)
Javier Junquera
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Tosin Akinosho
 
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their MainframeDigital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Precisely
 
The Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptxThe Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptx
operationspcvita
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
Jason Packer
 
WeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation TechniquesWeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation Techniques
Postman
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
DanBrown980551
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
Zilliz
 
Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
Zilliz
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
panagenda
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
akankshawande
 
FREE A4 Cyber Security Awareness Posters-Social Engineering part 3
FREE A4 Cyber Security Awareness  Posters-Social Engineering part 3FREE A4 Cyber Security Awareness  Posters-Social Engineering part 3
FREE A4 Cyber Security Awareness Posters-Social Engineering part 3
Data Hops
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 
Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |
AstuteBusiness
 

Recently uploaded (20)

Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
 
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying AheadDigital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying Ahead
 
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
 
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
 
GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
 
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their MainframeDigital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
 
The Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptxThe Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptx
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
 
WeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation TechniquesWeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation Techniques
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
 
Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
 
FREE A4 Cyber Security Awareness Posters-Social Engineering part 3
FREE A4 Cyber Security Awareness  Posters-Social Engineering part 3FREE A4 Cyber Security Awareness  Posters-Social Engineering part 3
FREE A4 Cyber Security Awareness Posters-Social Engineering part 3
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 
Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |
 

2012-04-12 - AOP .NET UserGroup Niederrhein

  • 2. Johannes Hoppe ASP.NET MVC Webentwickler www.johanneshoppe.de
  • 5. Business Code public class CustomerProcesses { public void RentBook( int bookId, int customerId ) { Book book = Book.GetById( bookId ); Customer customer = Customer.GetById( customerId ); book.RentedTo = customer; customer.AccountLines.Add( string.Format( "Rental of book {0}.", book ), book.RentalPrice ); customer.Balance -= book.RentalPrice; } }
  • 7.
  • 8. Business Code public class CustomerProcesses { public void RentBook( int bookId, int customerId ) { Book book = Book.GetById( bookId ); Customer customer = Customer.GetById( customerId ); book.RentedTo = customer; customer.AccountLines.Add( string.Format( "Rental of book {0}.", book ), book.RentalPrice ); customer.Balance -= book.RentalPrice; } }
  • 9. Business Code + Logging internal class CustomerProcesses { private static readonly TraceSource trace = new TraceSource( typeof (CustomerProcesses).FullName ); public void RentBook( int bookId, int customerId ) { trace.TraceInformation( "Entering CustomerProcesses.CreateCustomer( bookId = {0}, customerId = {1} )", bookId, customerId ); try { Book book = Book.GetById( bookId ); Customer customer = Customer.GetById( customerId ); book.RentedTo = customer; customer.AccountLines.Add( string.Format( "Rental of book {0}.", book ), book.RentalPrice ); customer.Balance -= book.RentalPrice; trace.TraceInformation( "Leaving CustomerProcesses.CreateCustomer( bookId = {0}, customerId = {1} )", bookId, customerId ); } catch ( Exception e ) { trace.TraceEvent( TraceEventType.Error, 0, "Exception: CustomerProcesses.CreateCustomer( bookId = {0}, customerId = {1} ) failed : {2}", bookId, customerId, e.Message ); throw; } } }
  • 10. Business Code + Logging internal class CustomerProcesses + Vorbedingungen { private static readonly TraceSource trace = new TraceSource(typeof(CustomerProcesses).FullName); public void RentBook(int bookId, int customerId) { if (bookId <= 0) throw new ArgumentOutOfRangeException("bookId"); if (customerId <= 0) throw new ArgumentOutOfRangeException("customerId"); trace.TraceInformation( "Entering CustomerProcesses.CreateCustomer( bookId = {0}, customerId = {1} )", bookId, customerId); try { Book book = Book.GetById(bookId); Customer customer = Customer.GetById(customerId); book.RentedTo = customer; customer.AccountLines.Add(string.Format("Rental of book {0}.", book), book.RentalPrice); customer.Balance -= book.RentalPrice; trace.TraceInformation( "Leaving CustomerProcesses.CreateCustomer( bookId = {0}, customerId = {1} )“, bookId, customerId); } catch (Exception e) { trace.TraceEvent(TraceEventType.Error, 0, "Exception: CustomerProcesses.CreateCustomer( bookId = {0}, customerId = {1} ) failed : {2}", bookId, customerId, e.Message); throw; } } }
  • 11. Business Code + Logging + Transaktionen + Vorbedingungen internal class CustomerProcesses ts.Complete(); { } private static readonly TraceSource trace = new TraceSource(typeof(CustomerProcesses).FullName); break; } public void RentBook(int bookId, int customerId) catch (TransactionConflictException) { { if (bookId <= 0) if (i < 3) throw new ArgumentOutOfRangeException("bookId"); continue; if (customerId <= 0) else throw new ArgumentOutOfRangeException("customerId"); throw; } trace.TraceInformation( } "Entering CustomerProcesses.CreateCustomer( bookId = {0}, customerId = {1} )“, bookId, customerId); trace.TraceInformation( "Leaving CustomerProcesses.CreateCustomer( try bookId = {0}, customerId = {1} )", { bookId, customerId); for (int i = 0; ; i++) } { catch (Exception e) try { { trace.TraceEvent(TraceEventType.Error, 0, using (var ts = new TransactionScope()) "Exception: CustomerProcesses.CreateCustomer( bookId = {0}, { customerId = {1} ) failed : {2}", Book book = Book.GetById(bookId); bookId, customerId, e.Message); Customer customer = throw; Customer.GetById(customerId); } } book.RentedTo = customer; customer.AccountLines.Add( } string.Format("Rental of book {0}.", book), book.RentalPrice); customer.Balance -= book.RentalPrice;
  • 12. Business Code + Logging + Transaktionen + Vorbedingungen + Exception Handling internal class CustomerProcesses { ts.Complete(); private static readonly TraceSource trace = } new TraceSource(typeof(CustomerProcesses).FullName); break; public void RentBook(int bookId, int customerId) } { catch ( TransactionConflictException ) if (bookId <= 0) throw new ArgumentOutOfRangeException("bookId"); { if (customerId <= 0) if ( i < 3 ) throw new ArgumentOutOfRangeException("customerId"); continue; else try throw; { } trace.TraceInformation( } "Entering CustomerProcesses.CreateCustomer( bookId = {0}, customerId = {1} )", trace.TraceInformation( bookId, customerId ); "Leaving CustomerProcesses.CreateCustomer( bookId = {0}, customerId = {1} )", try bookId, customerId ); { } for ( int i = 0;; i++ ) catch ( Exception e ) { { try trace.TraceEvent( TraceEventType.Error, 0, { "Exception: CustomerProcesses.CreateCustomer( using ( var ts = new TransactionScope() ) bookId = {0}, customerId = {1} ) failed : {2}", { bookId, customerId, e.Message ); Book book = Book.GetById( bookId ); throw; Customer customer = Customer.GetById( customerId ); } } book.RentedTo = customer; catch ( Exception e ) customer.AccountLines.Add( { string.Format( "Rental of book {0}.", book ), if (ExceptionManager.Handle(e)) throw; book.RentalPrice ); } customer.Balance -= book.RentalPrice; }
  • 13. Business Code + Logging + Transaktionen + Vorbedingungen + Exception Handling + Feature X + Feature Y + Feature Z +…
  • 14. Kern- Seperation funktionalitäten of Concerns (Core Concerns)
  • 15. VS
  • 16. VS Nicht- Funktionale Anforderungen (Crosscutting Concerns)
  • 17. Cross-Cutting Concerns Security Data Binding Exception Handling Thread Sync Tracing Caching Monitoring Validation Transaction …
  • 19. Spring.NET PostSharp LinFu Castle MS Unity Build-Time Hybrid Run-Time
  • 20. Build-Time: “Statisch” Run-Time: “Dynamisch” Erfolgt bei Kompilierung Erfolgt zur Laufzeit Code wird direkt verändert Code bleibt unverändert Zur Laufzeit keine Änderungen Zur Laufzeit Änderungen möglich Auch auf Properties, Felder, Aufruf wird über Proxy Events anwendbar umgeleitet Keine Interfaces erforderlich idR. Interfaces erforderlich (Proxy)
  • 22.
  • 23. Logging LogTimeAspect webnoteaop.codeplex.com
  • 24. Exceptions ConvertExceptionAspect webnoteaop.codeplex.com
  • 25. Validierung ValidationGuardAspect webnoteaop.codeplex.com
  • 26. Caching SimpleCacheAspect webnoteaop.codeplex.com
  • 27.
  • 29. AspectJ Begriffe Join Point Pointcut Advice Aspect
  • 30. AspectJ Begriffe Join Point Pointcut Advice Aspect
  • 31. IL Code Vorher [LogTimeAspect] public ActionResult Index() { IEnumerable<NoteWithCategories> notes = this.WebNoteService.ReadAll(); return View(notes); }
  • 32. IL Code Nachher public ActionResult Index() { ActionResult CS$1$2__returnValue; MethodExecutionArgs CS$0$3__aspectArgs = new MethodExecutionArgs(null, null); <>z__Aspects.a68.OnEntry(CS$0$3__aspectArgs); try { IEnumerable<NoteWithCategories> notes = this.WebNoteService.ReadAll(); ActionResult CS$1$0000 = base.View(notes); CS$1$2__returnValue = CS$1$0000; } finally { <>z__Aspects.a68.OnExit(CS$0$3__aspectArgs); } return CS$1$2__returnValue; }
  • 33. Originale Methode Aspekt Klasse OnEntry try { Method Body OnSuccess } catch (Exception e) { OnException } finally { OnExit } : OnMethodBoundaryAspect
  • 37. Spring.NET PostSharp springframework.net sharpcrafters.com Castle Demo Download castleproject.org webnoteaop.codeplex.com Unity unity.codeplex.com
  • 39. Bis bald › 10.05.2012 – .NET UG Karlsruhe: NoSQL › 14.05.2012 – .NET Developer Conference (DDC) .Nürnberg: NoSQL
  • 41. Primitive Aspekt-Typen › MethodBoundaryAspect › LocationInterceptionAspect › OnEntry › OnGetValue › OnSuccess › OnSetValue › OnException › OnExit › EventInterceptionAspect › OnAddHandler › OnExceptionAspect › OnRemoveHandler › OnException › OnInvokeHandler › MethodInterceptionAspect › MethodImplementationAspect › OnInvoke › OnInvoke › CompositionAspect › CreateImplementationObject
  • 42. Bildnachweise Ausgewählter Ordner © Spectral-Design – Fotolia.com Warnhinweis-Schild © Sascha Tiebel – Fotolia.com Liste abhaken © Dirk Schumann – Fotolia.com 3D rendering of an architecture model 2 © Franck Boston – Fotolia.com Healthcare © ArtmannWitte – Fotolia.com Stressed businessman © Selecstock – Fotolia.com Funny cartoon boss © artenot – Fotolia.com