Today I had the task of removing a few entries from a CSV file based on another CSV file. It was only about 300 rows that needed to be removed in a file of about 2000 rows, so I could have manually done it in about an hour. Since it is Saturday, I decided to have fun, write a Perl script to do it even if it took longer than doing it manually.
Before you laugh at the fact that I thought it might take me over an hour to write a Perl script, understand I haven’t done anything in Perl in about 2 years.
After about 15 minutes, I had a perfectly working script. Perl really is one of the easiest and fastest ways to do file and string manipulation. Unfortunately, it might be another 2 years before I need to use it again. Either way, it feels great to complete a task quickly and efficiently, which is probably the entire reason Larry Wall created Perl.
I just started using the Policy Injection Application Block from Microsoft’s Enterprise library. At first, I thought it was worthless and overly complex. I was wrong. It is a very powerful programming tool that allows me to develop a lot faster and cleaner.
Policy Injection is similar to aspect-oriented programming in that it helps to break away cross-cutting concerns (authorization, logging) from the actual business logic. And yes, I basically copied that from the documentation.
Here is what policy injection means for me. I can build business logic, which performs only what I want it to. So I can have a function called AddUser and all that is done is the actual operation of adding that user. I can then attach policies to that function, which specify how to authorize and log it. This has a couple effects. One, it reduces the amount of code which in turn cleans up the code. Second, it allows me to customize cross-cutting concerns for different projects. If I have an administrative application, I need to authorize differently than a user application. Policy injection makes this possible without dirtying up the code.
After the initial few hours of getting used to using it, I am a huge proponent. I definitely recommend checking it out.