Search code examples
javadesign-patternsdomain-driven-designobserver-pattern

A good design pattern for documenting every operation


What is a good design pattern to document or log every operation (business logic) that is done inside the system?

Let's say I want to write a small log or notify the user about every operation? For instance, in the system you may order a cleaning service for your house and I want to give the user feedback after each step:

Cleaning service ordered > cleaning is being done > cleaning is finished

I was thinking about Observer pattern but I'm a bit confused. Thanks.


Solution

  • If you wish to log every time /something/ happens then it's what's called a cross cutting concern. By this I mean something that happens /outside normal operation/ - it happens everywhere. Look at Aspecxt orientated programming (AOP) - logging is a classic AOP problem. http://en.wikipedia.org/wiki/Aspect-oriented_programming for more info.