tags:

views:

141

answers:

3

These I come across this term a lot "crosscutting requirements/concerns" in programming world.

Although I think I have an idea what it means still I do not have a clear idea. I hear it a lot in web service and SOA in general.

Can this be explained using a hello world example?

+5  A: 

It tends to mean "stuff that you want to do in lots of places, which doesn't have an awful lot to do with the real meat of that piece of code".

Common examples are:

  • Transaction handling
  • Security
  • Logging
  • Error handling

I find it's usually mentioned in respect to Aspect-Oriented Programming (AOP) which usually attempts to handle things like this declaratively, e.g. with attributes/annotations. As a gross simplification, it's a case of applying boiler-plate code (e.g. to verify the identity/authority of the user in the current context, or to log entry/exit of the method) automatically without making the code itself messy.

Jon Skeet
+2  A: 

I recommend you look at a framework like Postsharp and try out this example from the postsharp site. If you know java a lok into AspectJ is worth a look. But first you may want to read the link posted by Jon Skeet :)

Perpetualcoder
+2  A: 

The standard "hello world" example for crosscutting is logging: You have an error in your production system and you have no clue what is going on. To solve it, you really need to see which functions in your code are called and what parameters they get and what they return.

This is a simple task that can be fully automated: Locate all functions (or a subset using a filter of some kind) and add a logging call to them which prints the name and the parameters. Since the code contains all the information you need to complete this task, what you really want is a tool that does it for you and which does it in a single place (instead of having you edit thousands of source files adding log statements everywhere).

Aaron Digulla