SlideShare a Scribd company logo
Yuriy Guts
Software Architect @ ELEKS
Clients
Application Services
Infrastructure Services
Desktop
Browser
Desktop
Application
Native
Mobile App
. . .
API
Business
Components
Reporting. . .ORM
RDBMS Cache
Search
Index
. . .Filesystem
Clients
Application Services
Infrastructure Services
Desktop
Browser
Desktop
Application
Native
Mobile App
. . .
API
Business
Components
Search. . .ORM
RDBMS Cache
Search
Index
. . .Filesystem
Cross-Cutting Concerns
Identity & Access Mgmt.
Audit
Logging
. . .
Import & Export
public class ReputationService : IReputationService
...
private readonly IUserDataService _userDataService;
public ReputationService(IUserDataService userDataService)
{
_userDataService = userDataService;
}
public int AddReputationForQuestion(Question question)
{
int pointsToAdd = question.UpVotes * 5 - question.DownVotes * 2;
int newReputation = _userDataService.AddReputationForUser(question.Author, pointsToAdd);
return newReputation;
}
public int AddReputationForAnswer(Answer answer)
{
int pointsToAdd = answer.UpVotes * 10 - answer.DownVotes * 3;
int newReputation = _userDataService.AddReputationForUser(answer.Author, pointsToAdd);
return newReputation;
}
...
public int AddReputationForQuestion(Question question)
{
int pointsToAdd = question.UpVotes * 5 - question.DownVotes * 2;
int newReputation = _userDataService.AddReputationForUser(question.Author, pointsToAdd);
return newReputation;
}
public int AddReputationForQuestion(Question question)
{
Console.WriteLine("{0:HH:mm:ss.fff}: AddReputationForQuestion started.", DateTime.Now);
int pointsToAdd = question.UpVotes * 5 - question.DownVotes * 2;
int newReputation = _userDataService.AddReputationForUser(question.Author, pointsToAdd);
Console.WriteLine("{0:HH:mm:ss.fff}: AddReputationForQuestion completed.", DateTime.Now);
return newReputation;
}
public int AddReputationForQuestion(Question question)
{
Console.WriteLine("{0:HH:mm:ss.fff}: AddReputationForQuestion started.", DateTime.Now);
if (question == null)
{
throw new ArgumentNullException("question");
}
if (question.Author == null)
{
throw new ArgumentNullException("question", "Author cannot be null.");
}
if (question.UpVotes < 0 || question.DownVotes < 0)
{
throw new ArgumentException("A question cannot have a negative number of votes");
}
int pointsToAdd = question.UpVotes * 5 - question.DownVotes * 2;
int newReputation = _userDataService.AddReputationForUser(question.Author, pointsToAdd);
Console.WriteLine("{0:HH:mm:ss.fff}: AddReputationForQuestion completed.", DateTime.Now);
return newReputation;
}
public int AddReputationForQuestion(Question question)
{
Console.WriteLine("{0:HH:mm:ss.fff}: AddReputationForQuestion started.", DateTime.Now);
if (question == null) throw new ArgumentNullException("question");
if (question.Author == null) throw new ArgumentNullException("question", "Author cannot be null.");
if (question.UpVotes < 0 || question.DownVotes < 0) throw new ArgumentException("A question cannot have a negative number of votes");
var attemptsLeft = 3;
try
{
while (attemptsLeft > 0)
{
try
{
int pointsToAdd = question.UpVotes * 5 - question.DownVotes * 2;
int newReputation = _userDataService.AddReputationForUser(question.Author, pointsToAdd);
Console.WriteLine("{0:HH:mm:ss.fff}: AddReputationForQuestion completed.", DateTime.Now);
return newReputation;
}
catch
{
attemptsLeft--;
if (attemptsLeft == 0)
{
throw;
}
}
}
}
catch (Exception ex)
{
Console.WriteLine("{0:HH:mm:ss.fff}: AddReputationForQuestion failed with exception: {1}.", DateTime.Now, ex);
}
throw new Exception();
}
public int AddReputationForQuestion(Question question)
{
QuestionValidator.ValidateQuestion(question);
return BoundaryLogging<int>.Run("AddReputationForQuestion", () =>
{
return MultipleAttemptExecutor<int>.Run(3, () =>
{
int pointsToAdd = question.UpVotes * 5 - question.DownVotes * 2;
int newReputation = _userDataService.AddReputationForUser(question.Author, pointsToAdd);
return newReputation;
});
});
}
[DomainValidation]
[BoundaryLogging]
[MultipleAttemptExecution(3)]
public int AddReputationForQuestion(Question question)
{
int pointsToAdd = question.UpVotes * 5 - question.DownVotes * 2;
int newReputation = _userDataService.AddReputationForUser(question.Author, pointsToAdd);
return newReputation;
}
Language Compiler
AOP Post-Compiler
Source Code
IL Code
IL Code with
generated aspects
IoC ContainerCalling Code
Dynamic Proxy
Original class
1
2
34
5
return this;
return F(this);
• PostSharp (IL weaving)
• Castle.DynamicProxy (call interception)
(just to name a few)
[Serializable]
public class BoundaryLogging : OnMethodBoundaryAspect
{
public override void OnEntry(MethodExecutionArgs args)
{
Console.WriteLine("{0:HH:mm:ss.fff}: {1} started.", DateTime.Now, args.Method.Name);
}
public override void OnExit(MethodExecutionArgs args)
{
Console.WriteLine("{0:HH:mm:ss.fff}: {1} completed.", DateTime.Now, args.Method.Name);
}
public override void OnException(MethodExecutionArgs args)
{
Console.WriteLine("{0:HH:mm:ss.fff}: {1} failed with exception: {2}.",
DateTime.Now, args.Method.Name, args.Exception);
}
}
[Serializable]
public class MultipleAttemptExecution : MethodInterceptionAspect
{
private readonly int _maxAttempts;
public MultipleAttemptExecution(int maxAttempts)
{
_maxAttempts = maxAttempts;
}
public override void OnInvoke(MethodInterceptionArgs args)
{
var attemptsLeft = _maxAttempts;
while (attemptsLeft > 0)
{
try
{
args.Proceed();
return;
}
catch
{
attemptsLeft--;
if (attemptsLeft == 0) throw;
}
}
throw new Exception("Maximum attempts reached.");
}
}
[DomainValidation]
[BoundaryLogging]
[MultipleAttemptExecution(3)]
public int AddReputationForQuestion(Question question)
{
int pointsToAdd = question.UpVotes * 5 - question.DownVotes * 2;
int newReputation = _userDataService.AddReputationForUser(question.Author, pointsToAdd);
return newReputation;
}
• [Authorize] attribute in ASP.NET MVC
• HttpModules in ASP.NET lifecycle
• Anything else?
• Logging & Audit
• Transactions
• Security
• Caching
• Exception Management
• Generating and validating code
1. Introduces “magic”, can reduce understanding of the big picture (*).
2. Requires special tools or code decorations.
3. Even mature frameworks have bugs.
(*) Greg Young:
www.infoq.com/presentations/8-lines-code-refactoring
yuriy.guts @ eleks.com
https://github.com/YuriyGuts/refactoring-with-aop

More Related Content

What's hot

The secret unit testing tools no one ever told you about
The secret unit testing tools no one ever told you aboutThe secret unit testing tools no one ever told you about
The secret unit testing tools no one ever told you about
Dror Helper
 
Unit testing patterns for concurrent code
Unit testing patterns for concurrent codeUnit testing patterns for concurrent code
Unit testing patterns for concurrent code
Dror Helper
 
Practical Google App Engine Applications In Py
Practical Google App Engine Applications In PyPractical Google App Engine Applications In Py
Practical Google App Engine Applications In Py
Eric ShangKuan
 
Functional UIs with Java 8 and Vaadin JavaOne2014
Functional UIs with Java 8 and Vaadin JavaOne2014Functional UIs with Java 8 and Vaadin JavaOne2014
Functional UIs with Java 8 and Vaadin JavaOne2014
hezamu
 
Durable functions
Durable functionsDurable functions
Durable functions
명신 김
 
Solving the n + 1 query problem
Solving the n + 1 query problemSolving the n + 1 query problem
Solving the n + 1 query problem
Sebastien Pelletier
 
Azure Durable Functions (2019-04-27)
Azure Durable Functions (2019-04-27)Azure Durable Functions (2019-04-27)
Azure Durable Functions (2019-04-27)
Paco de la Cruz
 
Jira reporting in google sheets
Jira reporting in google sheetsJira reporting in google sheets
Jira reporting in google sheets
QA Experts.Pro
 
Tools and Techniques for Understanding Threading Behavior in Android*
Tools and Techniques for Understanding Threading Behavior in Android*Tools and Techniques for Understanding Threading Behavior in Android*
Tools and Techniques for Understanding Threading Behavior in Android*
Intel® Software
 
From clever code to better code
From clever code to better codeFrom clever code to better code
From clever code to better code
Dror Helper
 
Mirage For Beginners
Mirage For BeginnersMirage For Beginners
Mirage For Beginners
Wilson Su
 
Java practice programs for beginners
Java practice programs for beginnersJava practice programs for beginners
Java practice programs for beginners
ishan0019
 
Angular - injection tokens & Custom libraries
Angular - injection tokens & Custom librariesAngular - injection tokens & Custom libraries
Angular - injection tokens & Custom libraries
Eliran Eliassy
 
Durable functions 2.0 (2019-10-10)
Durable functions 2.0 (2019-10-10)Durable functions 2.0 (2019-10-10)
Durable functions 2.0 (2019-10-10)
Paco de la Cruz
 
Lessons Learned Implementing a GraphQL API
Lessons Learned Implementing a GraphQL APILessons Learned Implementing a GraphQL API
Lessons Learned Implementing a GraphQL API
Dirk-Jan Rutten
 
Azure Durable Functions (2019-03-30)
Azure Durable Functions (2019-03-30) Azure Durable Functions (2019-03-30)
Azure Durable Functions (2019-03-30)
Paco de la Cruz
 
Metrics 2.0 & Graph-Explorer
Metrics 2.0 & Graph-ExplorerMetrics 2.0 & Graph-Explorer
Metrics 2.0 & Graph-ExplorerDieter Plaetinck
 
Integration test framework
Integration test frameworkIntegration test framework
Integration test framework
Ilya Medvedev
 
Durable Functions
Durable FunctionsDurable Functions
Durable Functions
Matti Petrelius
 

What's hot (20)

The secret unit testing tools no one ever told you about
The secret unit testing tools no one ever told you aboutThe secret unit testing tools no one ever told you about
The secret unit testing tools no one ever told you about
 
Unit testing patterns for concurrent code
Unit testing patterns for concurrent codeUnit testing patterns for concurrent code
Unit testing patterns for concurrent code
 
Practical Google App Engine Applications In Py
Practical Google App Engine Applications In PyPractical Google App Engine Applications In Py
Practical Google App Engine Applications In Py
 
Functional UIs with Java 8 and Vaadin JavaOne2014
Functional UIs with Java 8 and Vaadin JavaOne2014Functional UIs with Java 8 and Vaadin JavaOne2014
Functional UIs with Java 8 and Vaadin JavaOne2014
 
Durable functions
Durable functionsDurable functions
Durable functions
 
Solving the n + 1 query problem
Solving the n + 1 query problemSolving the n + 1 query problem
Solving the n + 1 query problem
 
Azure Durable Functions (2019-04-27)
Azure Durable Functions (2019-04-27)Azure Durable Functions (2019-04-27)
Azure Durable Functions (2019-04-27)
 
Jira reporting in google sheets
Jira reporting in google sheetsJira reporting in google sheets
Jira reporting in google sheets
 
Tools and Techniques for Understanding Threading Behavior in Android*
Tools and Techniques for Understanding Threading Behavior in Android*Tools and Techniques for Understanding Threading Behavior in Android*
Tools and Techniques for Understanding Threading Behavior in Android*
 
From clever code to better code
From clever code to better codeFrom clever code to better code
From clever code to better code
 
Mirage For Beginners
Mirage For BeginnersMirage For Beginners
Mirage For Beginners
 
Java practice programs for beginners
Java practice programs for beginnersJava practice programs for beginners
Java practice programs for beginners
 
Angular - injection tokens & Custom libraries
Angular - injection tokens & Custom librariesAngular - injection tokens & Custom libraries
Angular - injection tokens & Custom libraries
 
Durable functions 2.0 (2019-10-10)
Durable functions 2.0 (2019-10-10)Durable functions 2.0 (2019-10-10)
Durable functions 2.0 (2019-10-10)
 
Rx for .net
Rx for .netRx for .net
Rx for .net
 
Lessons Learned Implementing a GraphQL API
Lessons Learned Implementing a GraphQL APILessons Learned Implementing a GraphQL API
Lessons Learned Implementing a GraphQL API
 
Azure Durable Functions (2019-03-30)
Azure Durable Functions (2019-03-30) Azure Durable Functions (2019-03-30)
Azure Durable Functions (2019-03-30)
 
Metrics 2.0 & Graph-Explorer
Metrics 2.0 & Graph-ExplorerMetrics 2.0 & Graph-Explorer
Metrics 2.0 & Graph-Explorer
 
Integration test framework
Integration test frameworkIntegration test framework
Integration test framework
 
Durable Functions
Durable FunctionsDurable Functions
Durable Functions
 

Viewers also liked

中国ってどんな国?(小学生向け)
中国ってどんな国?(小学生向け)中国ってどんな国?(小学生向け)
中国ってどんな国?(小学生向け)
Keisuke Asami
 
AOP in C# 2013
AOP in C# 2013AOP in C# 2013
AOP in C# 2013Antya Dev
 
Introduction To Aspect Oriented Programming
Introduction To Aspect Oriented ProgrammingIntroduction To Aspect Oriented Programming
Introduction To Aspect Oriented Programming
saeed shargi ghazani
 
Redis for .NET Developers
Redis for .NET DevelopersRedis for .NET Developers
Redis for .NET Developers
Yuriy Guts
 
Aspect Oriented Programming
Aspect Oriented ProgrammingAspect Oriented Programming
Aspect Oriented Programming
Rajesh Ganesan
 
AOP & Patterns
AOP & PatternsAOP & Patterns
AOP & Patterns
Donald Belcham
 
Aspect Oriented Programming
Aspect Oriented ProgrammingAspect Oriented Programming
Aspect Oriented Programming
Rodger Oates
 
Introduction to Aspect Oriented Programming (DDD South West 4.0)
Introduction to Aspect Oriented Programming (DDD South West 4.0)Introduction to Aspect Oriented Programming (DDD South West 4.0)
Introduction to Aspect Oriented Programming (DDD South West 4.0)
Yan Cui
 
AOP
AOPAOP
cpp-2013 #12 Управління пам&rsquo;яттю Частина 2
cpp-2013 #12 Управління пам&rsquo;яттю Частина 2cpp-2013 #12 Управління пам&rsquo;яттю Частина 2
cpp-2013 #12 Управління пам&rsquo;яттю Частина 2Amazon Web Services
 
cpp-2013 #11 Constness and Exceptions
cpp-2013 #11 Constness and Exceptionscpp-2013 #11 Constness and Exceptions
cpp-2013 #11 Constness and ExceptionsAmazon Web Services
 
Introduction to Aspect Oriented Programming
Introduction to Aspect Oriented ProgrammingIntroduction to Aspect Oriented Programming
Introduction to Aspect Oriented Programming
Yan Cui
 
Aspect Oriented Programming
Aspect Oriented ProgrammingAspect Oriented Programming
Aspect Oriented Programming
Anumod Kumar
 
Introduction to Aspect Oriented Programming
Introduction to Aspect Oriented ProgrammingIntroduction to Aspect Oriented Programming
Introduction to Aspect Oriented Programming
Amir Kost
 
High Availability Application Architectures in Amazon VPC (ARC202) | AWS re:I...
High Availability Application Architectures in Amazon VPC (ARC202) | AWS re:I...High Availability Application Architectures in Amazon VPC (ARC202) | AWS re:I...
High Availability Application Architectures in Amazon VPC (ARC202) | AWS re:I...
Amazon Web Services
 

Viewers also liked (20)

中国ってどんな国?(小学生向け)
中国ってどんな国?(小学生向け)中国ってどんな国?(小学生向け)
中国ってどんな国?(小学生向け)
 
AOP in C# 2013
AOP in C# 2013AOP in C# 2013
AOP in C# 2013
 
Introduction To Aspect Oriented Programming
Introduction To Aspect Oriented ProgrammingIntroduction To Aspect Oriented Programming
Introduction To Aspect Oriented Programming
 
Redis for .NET Developers
Redis for .NET DevelopersRedis for .NET Developers
Redis for .NET Developers
 
Aspect Oriented Programming
Aspect Oriented ProgrammingAspect Oriented Programming
Aspect Oriented Programming
 
AOP & Patterns
AOP & PatternsAOP & Patterns
AOP & Patterns
 
Aspect Oriented Programming
Aspect Oriented ProgrammingAspect Oriented Programming
Aspect Oriented Programming
 
Introduction to Aspect Oriented Programming (DDD South West 4.0)
Introduction to Aspect Oriented Programming (DDD South West 4.0)Introduction to Aspect Oriented Programming (DDD South West 4.0)
Introduction to Aspect Oriented Programming (DDD South West 4.0)
 
AOP
AOPAOP
AOP
 
cpp-2013 #12 Управління пам&rsquo;яттю Частина 2
cpp-2013 #12 Управління пам&rsquo;яттю Частина 2cpp-2013 #12 Управління пам&rsquo;яттю Частина 2
cpp-2013 #12 Управління пам&rsquo;яттю Частина 2
 
cpp-2013 #20 Best practices
cpp-2013 #20 Best practicescpp-2013 #20 Best practices
cpp-2013 #20 Best practices
 
cpp-2013 #18 Qt Part 2
cpp-2013 #18 Qt Part 2cpp-2013 #18 Qt Part 2
cpp-2013 #18 Qt Part 2
 
cpp-2013 #16 Automated testing
cpp-2013 #16 Automated testingcpp-2013 #16 Automated testing
cpp-2013 #16 Automated testing
 
cpp-2013 #4 Memory management
cpp-2013 #4 Memory managementcpp-2013 #4 Memory management
cpp-2013 #4 Memory management
 
cpp-2013 #11 Constness and Exceptions
cpp-2013 #11 Constness and Exceptionscpp-2013 #11 Constness and Exceptions
cpp-2013 #11 Constness and Exceptions
 
cpp-2013 #17 Libraries
cpp-2013 #17 Librariescpp-2013 #17 Libraries
cpp-2013 #17 Libraries
 
Introduction to Aspect Oriented Programming
Introduction to Aspect Oriented ProgrammingIntroduction to Aspect Oriented Programming
Introduction to Aspect Oriented Programming
 
Aspect Oriented Programming
Aspect Oriented ProgrammingAspect Oriented Programming
Aspect Oriented Programming
 
Introduction to Aspect Oriented Programming
Introduction to Aspect Oriented ProgrammingIntroduction to Aspect Oriented Programming
Introduction to Aspect Oriented Programming
 
High Availability Application Architectures in Amazon VPC (ARC202) | AWS re:I...
High Availability Application Architectures in Amazon VPC (ARC202) | AWS re:I...High Availability Application Architectures in Amazon VPC (ARC202) | AWS re:I...
High Availability Application Architectures in Amazon VPC (ARC202) | AWS re:I...
 

Similar to Aspect-Oriented Programming (AOP) in .NET

L2 Web App Development Guest Lecture At University of Surrey 20/11/09
L2 Web App Development Guest Lecture At University of Surrey 20/11/09L2 Web App Development Guest Lecture At University of Surrey 20/11/09
L2 Web App Development Guest Lecture At University of Surrey 20/11/09
Daniel Bryant
 
Lviv MDDay 2014. Ігор Коробка “забезпечення базової безпеки в андроїд аплікац...
Lviv MDDay 2014. Ігор Коробка “забезпечення базової безпеки в андроїд аплікац...Lviv MDDay 2014. Ігор Коробка “забезпечення базової безпеки в андроїд аплікац...
Lviv MDDay 2014. Ігор Коробка “забезпечення базової безпеки в андроїд аплікац...
Lviv Startup Club
 
[NDC 2019] Enterprise-Grade Serverless
[NDC 2019] Enterprise-Grade Serverless[NDC 2019] Enterprise-Grade Serverless
[NDC 2019] Enterprise-Grade Serverless
KatyShimizu
 
[NDC 2019] Functions 2.0: Enterprise-Grade Serverless
[NDC 2019] Functions 2.0: Enterprise-Grade Serverless[NDC 2019] Functions 2.0: Enterprise-Grade Serverless
[NDC 2019] Functions 2.0: Enterprise-Grade Serverless
KatyShimizu
 
AOP in Python API design
AOP in Python API designAOP in Python API design
AOP in Python API design
meij200
 
Android dev toolbox
Android dev toolboxAndroid dev toolbox
Android dev toolbox
Shem Magnezi
 
Reduxing like a pro
Reduxing like a proReduxing like a pro
Reduxing like a pro
Boris Dinkevich
 
Cnam azure 2014 mobile services
Cnam azure 2014   mobile servicesCnam azure 2014   mobile services
Cnam azure 2014 mobile services
Aymeric Weinbach
 
Microsoft Azure Mobile Services
Microsoft Azure Mobile ServicesMicrosoft Azure Mobile Services
Microsoft Azure Mobile Services
Olga Lavrentieva
 
Protractor framework – how to make stable e2e tests for Angular applications
Protractor framework – how to make stable e2e tests for Angular applicationsProtractor framework – how to make stable e2e tests for Angular applications
Protractor framework – how to make stable e2e tests for Angular applications
Ludmila Nesvitiy
 
Maximizer 2018 API training
Maximizer 2018 API trainingMaximizer 2018 API training
Maximizer 2018 API training
Murylo Batista
 
Functional Vaadin talk at OSCON 2014
Functional Vaadin talk at OSCON 2014Functional Vaadin talk at OSCON 2014
Functional Vaadin talk at OSCON 2014
hezamu
 
Reactive programming every day
Reactive programming every dayReactive programming every day
Reactive programming every day
Vadym Khondar
 
Using xUnit as a Swiss-Aarmy Testing Toolkit
Using xUnit as a Swiss-Aarmy Testing ToolkitUsing xUnit as a Swiss-Aarmy Testing Toolkit
Using xUnit as a Swiss-Aarmy Testing Toolkit
Chris Oldwood
 
VPN Access Runbook
VPN Access RunbookVPN Access Runbook
VPN Access RunbookTaha Shakeel
 
GraphQL Bangkok Meetup 2.0
GraphQL Bangkok Meetup 2.0GraphQL Bangkok Meetup 2.0
GraphQL Bangkok Meetup 2.0
Tobias Meixner
 
Knockoutjs UG meeting presentation
Knockoutjs UG meeting presentationKnockoutjs UG meeting presentation
Knockoutjs UG meeting presentation
Valdis Iljuconoks
 
Sebastian Schmidt, Rachel Myers - How To Go Serverless And Not Violate The GD...
Sebastian Schmidt, Rachel Myers - How To Go Serverless And Not Violate The GD...Sebastian Schmidt, Rachel Myers - How To Go Serverless And Not Violate The GD...
Sebastian Schmidt, Rachel Myers - How To Go Serverless And Not Violate The GD...
Codemotion
 
Introdução à programação orientada para aspectos
Introdução à programação orientada para aspectosIntrodução à programação orientada para aspectos
Introdução à programação orientada para aspectos
Manuel Menezes de Sequeira
 

Similar to Aspect-Oriented Programming (AOP) in .NET (20)

L2 Web App Development Guest Lecture At University of Surrey 20/11/09
L2 Web App Development Guest Lecture At University of Surrey 20/11/09L2 Web App Development Guest Lecture At University of Surrey 20/11/09
L2 Web App Development Guest Lecture At University of Surrey 20/11/09
 
Lviv MDDay 2014. Ігор Коробка “забезпечення базової безпеки в андроїд аплікац...
Lviv MDDay 2014. Ігор Коробка “забезпечення базової безпеки в андроїд аплікац...Lviv MDDay 2014. Ігор Коробка “забезпечення базової безпеки в андроїд аплікац...
Lviv MDDay 2014. Ігор Коробка “забезпечення базової безпеки в андроїд аплікац...
 
[NDC 2019] Enterprise-Grade Serverless
[NDC 2019] Enterprise-Grade Serverless[NDC 2019] Enterprise-Grade Serverless
[NDC 2019] Enterprise-Grade Serverless
 
[NDC 2019] Functions 2.0: Enterprise-Grade Serverless
[NDC 2019] Functions 2.0: Enterprise-Grade Serverless[NDC 2019] Functions 2.0: Enterprise-Grade Serverless
[NDC 2019] Functions 2.0: Enterprise-Grade Serverless
 
AOP in Python API design
AOP in Python API designAOP in Python API design
AOP in Python API design
 
Android dev toolbox
Android dev toolboxAndroid dev toolbox
Android dev toolbox
 
Reduxing like a pro
Reduxing like a proReduxing like a pro
Reduxing like a pro
 
Cnam azure 2014 mobile services
Cnam azure 2014   mobile servicesCnam azure 2014   mobile services
Cnam azure 2014 mobile services
 
Microsoft Azure Mobile Services
Microsoft Azure Mobile ServicesMicrosoft Azure Mobile Services
Microsoft Azure Mobile Services
 
Protractor framework – how to make stable e2e tests for Angular applications
Protractor framework – how to make stable e2e tests for Angular applicationsProtractor framework – how to make stable e2e tests for Angular applications
Protractor framework – how to make stable e2e tests for Angular applications
 
Maximizer 2018 API training
Maximizer 2018 API trainingMaximizer 2018 API training
Maximizer 2018 API training
 
Functional Vaadin talk at OSCON 2014
Functional Vaadin talk at OSCON 2014Functional Vaadin talk at OSCON 2014
Functional Vaadin talk at OSCON 2014
 
Reactive programming every day
Reactive programming every dayReactive programming every day
Reactive programming every day
 
Anti patterns
Anti patternsAnti patterns
Anti patterns
 
Using xUnit as a Swiss-Aarmy Testing Toolkit
Using xUnit as a Swiss-Aarmy Testing ToolkitUsing xUnit as a Swiss-Aarmy Testing Toolkit
Using xUnit as a Swiss-Aarmy Testing Toolkit
 
VPN Access Runbook
VPN Access RunbookVPN Access Runbook
VPN Access Runbook
 
GraphQL Bangkok Meetup 2.0
GraphQL Bangkok Meetup 2.0GraphQL Bangkok Meetup 2.0
GraphQL Bangkok Meetup 2.0
 
Knockoutjs UG meeting presentation
Knockoutjs UG meeting presentationKnockoutjs UG meeting presentation
Knockoutjs UG meeting presentation
 
Sebastian Schmidt, Rachel Myers - How To Go Serverless And Not Violate The GD...
Sebastian Schmidt, Rachel Myers - How To Go Serverless And Not Violate The GD...Sebastian Schmidt, Rachel Myers - How To Go Serverless And Not Violate The GD...
Sebastian Schmidt, Rachel Myers - How To Go Serverless And Not Violate The GD...
 
Introdução à programação orientada para aspectos
Introdução à programação orientada para aspectosIntrodução à programação orientada para aspectos
Introdução à programação orientada para aspectos
 

More from Yuriy Guts

Target Leakage in Machine Learning (ODSC East 2020)
Target Leakage in Machine Learning (ODSC East 2020)Target Leakage in Machine Learning (ODSC East 2020)
Target Leakage in Machine Learning (ODSC East 2020)
Yuriy Guts
 
Automated Machine Learning
Automated Machine LearningAutomated Machine Learning
Automated Machine Learning
Yuriy Guts
 
Target Leakage in Machine Learning
Target Leakage in Machine LearningTarget Leakage in Machine Learning
Target Leakage in Machine Learning
Yuriy Guts
 
Paraphrase Detection in NLP
Paraphrase Detection in NLPParaphrase Detection in NLP
Paraphrase Detection in NLP
Yuriy Guts
 
UCU NLP Summer Workshops 2017 - Part 2
UCU NLP Summer Workshops 2017 - Part 2UCU NLP Summer Workshops 2017 - Part 2
UCU NLP Summer Workshops 2017 - Part 2
Yuriy Guts
 
Natural Language Processing (NLP)
Natural Language Processing (NLP)Natural Language Processing (NLP)
Natural Language Processing (NLP)
Yuriy Guts
 
NoSQL (ELEKS DevTalks #1 - Jan 2015)
NoSQL (ELEKS DevTalks #1 - Jan 2015)NoSQL (ELEKS DevTalks #1 - Jan 2015)
NoSQL (ELEKS DevTalks #1 - Jan 2015)
Yuriy Guts
 
Experiments with Machine Learning - GDG Lviv
Experiments with Machine Learning - GDG LvivExperiments with Machine Learning - GDG Lviv
Experiments with Machine Learning - GDG Lviv
Yuriy Guts
 
A Developer Overview of Redis
A Developer Overview of RedisA Developer Overview of Redis
A Developer Overview of RedisYuriy Guts
 
[JEEConf 2015] Lessons from Building a Modern B2C System in Scala
[JEEConf 2015] Lessons from Building a Modern B2C System in Scala[JEEConf 2015] Lessons from Building a Modern B2C System in Scala
[JEEConf 2015] Lessons from Building a Modern B2C System in Scala
Yuriy Guts
 
Non-Functional Requirements
Non-Functional RequirementsNon-Functional Requirements
Non-Functional RequirementsYuriy Guts
 
Introduction to Software Architecture
Introduction to Software ArchitectureIntroduction to Software Architecture
Introduction to Software ArchitectureYuriy Guts
 
UML for Business Analysts
UML for Business AnalystsUML for Business Analysts
UML for Business AnalystsYuriy Guts
 
Intro to Software Engineering for non-IT Audience
Intro to Software Engineering for non-IT AudienceIntro to Software Engineering for non-IT Audience
Intro to Software Engineering for non-IT AudienceYuriy Guts
 
ELEKS DevTalks #4: Amazon Web Services Crash Course
ELEKS DevTalks #4: Amazon Web Services Crash CourseELEKS DevTalks #4: Amazon Web Services Crash Course
ELEKS DevTalks #4: Amazon Web Services Crash Course
Yuriy Guts
 
ELEKS Summer School 2012: .NET 09 - Databases
ELEKS Summer School 2012: .NET 09 - DatabasesELEKS Summer School 2012: .NET 09 - Databases
ELEKS Summer School 2012: .NET 09 - Databases
Yuriy Guts
 
ELEKS Summer School 2012: .NET 06 - Multithreading
ELEKS Summer School 2012: .NET 06 - MultithreadingELEKS Summer School 2012: .NET 06 - Multithreading
ELEKS Summer School 2012: .NET 06 - Multithreading
Yuriy Guts
 
ELEKS Summer School 2012: .NET 04 - Resources and Memory
ELEKS Summer School 2012: .NET 04 - Resources and MemoryELEKS Summer School 2012: .NET 04 - Resources and Memory
ELEKS Summer School 2012: .NET 04 - Resources and Memory
Yuriy Guts
 

More from Yuriy Guts (18)

Target Leakage in Machine Learning (ODSC East 2020)
Target Leakage in Machine Learning (ODSC East 2020)Target Leakage in Machine Learning (ODSC East 2020)
Target Leakage in Machine Learning (ODSC East 2020)
 
Automated Machine Learning
Automated Machine LearningAutomated Machine Learning
Automated Machine Learning
 
Target Leakage in Machine Learning
Target Leakage in Machine LearningTarget Leakage in Machine Learning
Target Leakage in Machine Learning
 
Paraphrase Detection in NLP
Paraphrase Detection in NLPParaphrase Detection in NLP
Paraphrase Detection in NLP
 
UCU NLP Summer Workshops 2017 - Part 2
UCU NLP Summer Workshops 2017 - Part 2UCU NLP Summer Workshops 2017 - Part 2
UCU NLP Summer Workshops 2017 - Part 2
 
Natural Language Processing (NLP)
Natural Language Processing (NLP)Natural Language Processing (NLP)
Natural Language Processing (NLP)
 
NoSQL (ELEKS DevTalks #1 - Jan 2015)
NoSQL (ELEKS DevTalks #1 - Jan 2015)NoSQL (ELEKS DevTalks #1 - Jan 2015)
NoSQL (ELEKS DevTalks #1 - Jan 2015)
 
Experiments with Machine Learning - GDG Lviv
Experiments with Machine Learning - GDG LvivExperiments with Machine Learning - GDG Lviv
Experiments with Machine Learning - GDG Lviv
 
A Developer Overview of Redis
A Developer Overview of RedisA Developer Overview of Redis
A Developer Overview of Redis
 
[JEEConf 2015] Lessons from Building a Modern B2C System in Scala
[JEEConf 2015] Lessons from Building a Modern B2C System in Scala[JEEConf 2015] Lessons from Building a Modern B2C System in Scala
[JEEConf 2015] Lessons from Building a Modern B2C System in Scala
 
Non-Functional Requirements
Non-Functional RequirementsNon-Functional Requirements
Non-Functional Requirements
 
Introduction to Software Architecture
Introduction to Software ArchitectureIntroduction to Software Architecture
Introduction to Software Architecture
 
UML for Business Analysts
UML for Business AnalystsUML for Business Analysts
UML for Business Analysts
 
Intro to Software Engineering for non-IT Audience
Intro to Software Engineering for non-IT AudienceIntro to Software Engineering for non-IT Audience
Intro to Software Engineering for non-IT Audience
 
ELEKS DevTalks #4: Amazon Web Services Crash Course
ELEKS DevTalks #4: Amazon Web Services Crash CourseELEKS DevTalks #4: Amazon Web Services Crash Course
ELEKS DevTalks #4: Amazon Web Services Crash Course
 
ELEKS Summer School 2012: .NET 09 - Databases
ELEKS Summer School 2012: .NET 09 - DatabasesELEKS Summer School 2012: .NET 09 - Databases
ELEKS Summer School 2012: .NET 09 - Databases
 
ELEKS Summer School 2012: .NET 06 - Multithreading
ELEKS Summer School 2012: .NET 06 - MultithreadingELEKS Summer School 2012: .NET 06 - Multithreading
ELEKS Summer School 2012: .NET 06 - Multithreading
 
ELEKS Summer School 2012: .NET 04 - Resources and Memory
ELEKS Summer School 2012: .NET 04 - Resources and MemoryELEKS Summer School 2012: .NET 04 - Resources and Memory
ELEKS Summer School 2012: .NET 04 - Resources and Memory
 

Recently uploaded

Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
Cyanic lab
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
rickgrimesss22
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
Matt Welsh
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
Globus
 
Graphic Design Crash Course for beginners
Graphic Design Crash Course for beginnersGraphic Design Crash Course for beginners
Graphic Design Crash Course for beginners
e20449
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Globus
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
Globus
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Globus
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Natan Silnitsky
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Anthony Dahanne
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
Globus
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
IES VE
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
Adele Miller
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Globus
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
informapgpstrackings
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
Globus
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Globus
 

Recently uploaded (20)

Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
 
Graphic Design Crash Course for beginners
Graphic Design Crash Course for beginnersGraphic Design Crash Course for beginners
Graphic Design Crash Course for beginners
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
 

Aspect-Oriented Programming (AOP) in .NET

  • 2. Clients Application Services Infrastructure Services Desktop Browser Desktop Application Native Mobile App . . . API Business Components Reporting. . .ORM RDBMS Cache Search Index . . .Filesystem
  • 3. Clients Application Services Infrastructure Services Desktop Browser Desktop Application Native Mobile App . . . API Business Components Search. . .ORM RDBMS Cache Search Index . . .Filesystem Cross-Cutting Concerns Identity & Access Mgmt. Audit Logging . . . Import & Export
  • 4. public class ReputationService : IReputationService ... private readonly IUserDataService _userDataService; public ReputationService(IUserDataService userDataService) { _userDataService = userDataService; } public int AddReputationForQuestion(Question question) { int pointsToAdd = question.UpVotes * 5 - question.DownVotes * 2; int newReputation = _userDataService.AddReputationForUser(question.Author, pointsToAdd); return newReputation; } public int AddReputationForAnswer(Answer answer) { int pointsToAdd = answer.UpVotes * 10 - answer.DownVotes * 3; int newReputation = _userDataService.AddReputationForUser(answer.Author, pointsToAdd); return newReputation; } ...
  • 5. public int AddReputationForQuestion(Question question) { int pointsToAdd = question.UpVotes * 5 - question.DownVotes * 2; int newReputation = _userDataService.AddReputationForUser(question.Author, pointsToAdd); return newReputation; }
  • 6. public int AddReputationForQuestion(Question question) { Console.WriteLine("{0:HH:mm:ss.fff}: AddReputationForQuestion started.", DateTime.Now); int pointsToAdd = question.UpVotes * 5 - question.DownVotes * 2; int newReputation = _userDataService.AddReputationForUser(question.Author, pointsToAdd); Console.WriteLine("{0:HH:mm:ss.fff}: AddReputationForQuestion completed.", DateTime.Now); return newReputation; }
  • 7. public int AddReputationForQuestion(Question question) { Console.WriteLine("{0:HH:mm:ss.fff}: AddReputationForQuestion started.", DateTime.Now); if (question == null) { throw new ArgumentNullException("question"); } if (question.Author == null) { throw new ArgumentNullException("question", "Author cannot be null."); } if (question.UpVotes < 0 || question.DownVotes < 0) { throw new ArgumentException("A question cannot have a negative number of votes"); } int pointsToAdd = question.UpVotes * 5 - question.DownVotes * 2; int newReputation = _userDataService.AddReputationForUser(question.Author, pointsToAdd); Console.WriteLine("{0:HH:mm:ss.fff}: AddReputationForQuestion completed.", DateTime.Now); return newReputation; }
  • 8. public int AddReputationForQuestion(Question question) { Console.WriteLine("{0:HH:mm:ss.fff}: AddReputationForQuestion started.", DateTime.Now); if (question == null) throw new ArgumentNullException("question"); if (question.Author == null) throw new ArgumentNullException("question", "Author cannot be null."); if (question.UpVotes < 0 || question.DownVotes < 0) throw new ArgumentException("A question cannot have a negative number of votes"); var attemptsLeft = 3; try { while (attemptsLeft > 0) { try { int pointsToAdd = question.UpVotes * 5 - question.DownVotes * 2; int newReputation = _userDataService.AddReputationForUser(question.Author, pointsToAdd); Console.WriteLine("{0:HH:mm:ss.fff}: AddReputationForQuestion completed.", DateTime.Now); return newReputation; } catch { attemptsLeft--; if (attemptsLeft == 0) { throw; } } } } catch (Exception ex) { Console.WriteLine("{0:HH:mm:ss.fff}: AddReputationForQuestion failed with exception: {1}.", DateTime.Now, ex); } throw new Exception(); }
  • 9. public int AddReputationForQuestion(Question question) { QuestionValidator.ValidateQuestion(question); return BoundaryLogging<int>.Run("AddReputationForQuestion", () => { return MultipleAttemptExecutor<int>.Run(3, () => { int pointsToAdd = question.UpVotes * 5 - question.DownVotes * 2; int newReputation = _userDataService.AddReputationForUser(question.Author, pointsToAdd); return newReputation; }); }); }
  • 10. [DomainValidation] [BoundaryLogging] [MultipleAttemptExecution(3)] public int AddReputationForQuestion(Question question) { int pointsToAdd = question.UpVotes * 5 - question.DownVotes * 2; int newReputation = _userDataService.AddReputationForUser(question.Author, pointsToAdd); return newReputation; }
  • 11.
  • 12. Language Compiler AOP Post-Compiler Source Code IL Code IL Code with generated aspects
  • 13. IoC ContainerCalling Code Dynamic Proxy Original class 1 2 34 5
  • 15. • PostSharp (IL weaving) • Castle.DynamicProxy (call interception) (just to name a few)
  • 16. [Serializable] public class BoundaryLogging : OnMethodBoundaryAspect { public override void OnEntry(MethodExecutionArgs args) { Console.WriteLine("{0:HH:mm:ss.fff}: {1} started.", DateTime.Now, args.Method.Name); } public override void OnExit(MethodExecutionArgs args) { Console.WriteLine("{0:HH:mm:ss.fff}: {1} completed.", DateTime.Now, args.Method.Name); } public override void OnException(MethodExecutionArgs args) { Console.WriteLine("{0:HH:mm:ss.fff}: {1} failed with exception: {2}.", DateTime.Now, args.Method.Name, args.Exception); } }
  • 17. [Serializable] public class MultipleAttemptExecution : MethodInterceptionAspect { private readonly int _maxAttempts; public MultipleAttemptExecution(int maxAttempts) { _maxAttempts = maxAttempts; } public override void OnInvoke(MethodInterceptionArgs args) { var attemptsLeft = _maxAttempts; while (attemptsLeft > 0) { try { args.Proceed(); return; } catch { attemptsLeft--; if (attemptsLeft == 0) throw; } } throw new Exception("Maximum attempts reached."); } }
  • 18. [DomainValidation] [BoundaryLogging] [MultipleAttemptExecution(3)] public int AddReputationForQuestion(Question question) { int pointsToAdd = question.UpVotes * 5 - question.DownVotes * 2; int newReputation = _userDataService.AddReputationForUser(question.Author, pointsToAdd); return newReputation; }
  • 19.
  • 20. • [Authorize] attribute in ASP.NET MVC • HttpModules in ASP.NET lifecycle • Anything else?
  • 21. • Logging & Audit • Transactions • Security • Caching • Exception Management • Generating and validating code
  • 22. 1. Introduces “magic”, can reduce understanding of the big picture (*). 2. Requires special tools or code decorations. 3. Even mature frameworks have bugs. (*) Greg Young: www.infoq.com/presentations/8-lines-code-refactoring