Slide 1

Slide 1 text

Refactoring with AOP *Aspect Oriented Programming

Slide 2

Slide 2 text

Blog - https://mertmtn.blogspot.com/ 1 Github - https://github.com/mertmtn 2 LinkedIn - https://www.linkedin.com/in/mrtmtn/ 3 Twitter - https://twitter.com/_mertmetin 4 About Me Mert Metin Software Engineer @Sompo Sigorta MSc. in Information Technologies @Yildiz Technical University

Slide 3

Slide 3 text

Agenda What is AOP? 1 Some AOP Terminogies 2 Benefits of AOP 6 Sample Codes 5 Refactoring 4 Interceptors 3

Slide 4

Slide 4 text

AOP is an approach that separates functional and common non functional codes. Functional codes perform main business logic of an application. Non functional codes are cross cutting concerns which can be used everywhere or every layer are meaningful as an individual module. In other words; increases modularity by allowing the separation of cross-cutting concerns. What is AOP - Aspect Oriented Programming

Slide 5

Slide 5 text

Some AOP Terminologies Cross Cutting Concern Aspects of a program that affect other concerns. E.g. Validation, Logging, Caching, Exception, etc. Join point A candidate point in the program execution where an aspect can be plugged in. E.g. OnBefore, OnAfter, OnSuccess, OnException Pointcut Which method does executes on join point? E.g: Logging Method Aspect Implemented the concern as programmatically e.g: ValidationAspect, ExceptionAspect Advice Additional logic or code called from a join point.

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

.NET: Postsharp-Autofac Java: Spring-AspectJ-JBoss PHP: Go AOP If you would like to add extra functionality when method execution any where, you need interceptors. They allow inject logic on before, after, exception, success the method execution. Most frequently uses by languages/frameworks Interceptors

Slide 9

Slide 9 text

Each aspect inherits MethodInterception class and override its methods

Slide 10

Slide 10 text

A systematic process of improving code without creating new functionality that can transform a mess into clean code and simple design. Refactoring

Slide 11

Slide 11 text

Before Refactoring Single Responsibility Principle Separation of Concern Does this method satisfy

Slide 12

Slide 12 text

Before Refactoring

Slide 13

Slide 13 text

Sample Codes

Slide 14

Slide 14 text

After Refactoring

Slide 15

Slide 15 text

After Refactoring

Slide 16

Slide 16 text

Benefits of AOP Reusability Single Responsibility Principle (SRP) Do Not Repeat Yourself (DRY) Separation of Concerns Adhering to important software principles. Maintability Modularity Readability

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

No content

Slide 19

Slide 19 text

Thanks all for listening!