Everyday Rule Authoring
Over the years, I have found one of the better ways to hone one’s rule authoring skills is to try and incorporate them into every day utility-oriented activities. At first, this may appear to be a bit of a reach, since even though you know how to express the logic, it might not always be apparent how to get the rules to actually perform the work. This is where InRule’s .NET assembly endpoint integration comes into play.
Dlls Are Everywhere
If you think about the sheer multitude of .NET libraries that are available, either native to the framework, commercial, or custom (from CodeProject or similar); somewhere, someone has created a utility to accomplish the very thing that you might be looking to do. This is undoubtedly the hard part, creating a .NET assembly to work some level of magic in Windows in order perform a task, such as file management, desktop customization, time tracking or anything else you might imagine. Maybe the library has a UI and maybe it doesn’t, but more often than not you want to tailor it’s functionality to suit your personal needs, which is where rules can get the job done.
The beauty of accessing these libraries through irAuthor is that right out of the gate you get to explore the methods that are available to you without having to jump into Visual Studio and establish a command line project or test UI. You can simply point to the library, select the methods of interest and start authoring user-friendly logic against them. In order to test the desired function, you can launch irVerify and selectively test the methods and view the output. Therein lies a big benefit; using irAuthor with irVerify as the execution interface absolves the user of having to build a custom UI or custom code to call the .NET library.
So How Have I Used This?
You name it! In one example, I’ve created a set of file management rules to organize and re-name files based on a number of conditions. I’m also a music nut, so I tend to get a little carried away with mp3 management using these approaches, but the same concepts apply to a variety of other functions. There are literally “oodles” of utility-oriented tasks that I either manage via rules or are on my to-do list to implement. I’ve used rules to manage ID3 settings, normalize tracks, download artist and album information, and even auto post to blogs. The basic example below cycles through an Album directory and pre-fixes the file name with cd1_ cd2_ in a multi-disc scenario (old school I know), but the point is I did not have to write an application to manage this and was able to leverage the .NET framework mscorlib.dll directly through irAuthor.
Ok, I’ll Come Clean
Invariably, when you try to do this the first couple of times for non-trivial operations, you may run into a technical situation that doesn’t necessarily have an obvious approach for how to handle. This could be caused by methods that require non-primitive types, array-based return types, dependencies on other dlls, and so on. That being said, after you resolve a few of these “devil in the details” scenarios, you begin to develop a toolset (both experience-wise and build-up of InRule technique) for handling this complexity. Depending on the library you’re working with when you encounter an issue you may be able to resolve it by applying an advanced authoring approach or in the extreme case, by creating a lightweight wrapper dll or “shim” that can expose friendlier custom methods that shield much of the underlying noise.
If You’ve Made It This Far…
Maybe you’re willing to go a bit farther (name that movie). After getting a few of these utility apps under your belt, the ideas will start flowing in and before you realize it, you might be delving into anything from personal financial calculators to rule-based home automation and web-based information aggregation. You may even notice that some of the patterns will apply back to your “real” InRule work and suddenly your next rules-based business process might not seem so overwhelming.