Presented by Raman But-Husaim
A design principle for separating a computer program into distinct sections, so that each section addresses a separate concern.
API
logic
+ modularity;
+ boundaries;
+ encapsulation;
functions, methods, classes
modules, projects
individuals
teams
services, applications, features
units, sub-organisations
public class Math {
public int Abs(...) {
...
}
public double Pow(...) {
...
}
}UI
Business
DAL
more maintainable
more stable
more extensible
more reusable
more marketable
Aspect
Oriented
Programming
(AOP)
A programming paradigm that aims to increase modularity by allowing the separation of cross-cutting concerns.
@wikipedia
Allows behavior to be added to an individual object, dynamically, without affecting the behavior of other objects from the same class.
@wikipedia
A decorator pattern is one of the best ways to add features to an object without changing its interface.
@yegor256
extend functionality of a class, module, etc. at run-time
need flexible alternative to subclassing
public interface IMessageFormatter {
string Format(Message message);
}
public class MessageFormatter : IMessageFormatter {
private readonly IJsonSerializer serializer;
...
public string Format(Message message) {
return serializer.Serialize(message);
}
}public class AnonymizingMessageFormatter : IMessageFormatter {
private readonly IMessageFormatter inner;
...
public string Format(Message message) {
var anonymizedMessage = this.Anonymize(message);
return this.inner.Format(anonymizedMessage);
}
private Message Anonymize(Message message) {
// some code to perform anonymization
}
}Pattern that is used when software systems or frameworks want to offer a way to change, or augment, their usual processing cycle.
@wikipedia
component A
component B
API
component A
component B
API
component C
<interceptor>
public interface IInterceptor {
void Intercept(IInvocation inv);
}A proxy, in its most general form, is a class functioning as an interface to another thing.
@wikipedia
control the access to an object, eg.
additional functionality when accessing the object
3rd party service
API
autogenerated
client-proxy
<your code here>
A library for generating lightweight proxies at runtime. Proxy objects allow calls to members of an object to be intercepted without modifying the code of the class.
@official docs
Real Object
interceptor 1
interceptor 2
interceptor n
interceptor 3
Proxy
Real World