Teach the Code to Hack Itself...
And the more it hacks itself, the more secure it becomes. Compilers are hard task masters. They cut out a distinct path for the application execution and force it to run that way, come hell or high water. Letting an application change its behavior by teaching it to understand itself has been a fairly less explored subject.
One main reason being, mainstream software developers typically confine themselves to the assortment of data structures provided by their favorite language. Say, a nice C# developer sticks to Hash Tables, Dictionaries and Generic entities or a hybrid collection of all these to represent all sorts of rules, constraints or any knowledge pertaining to the domain. But such objects aren’t mature enough to represent the kind of rules which can dynamically define the behavior of the application.
Let’s talk in non-technology terms. Here’s the most famous syllogism from the college-days.
Rule 1: All men are mortal
Rule 2: Socrates is a man
Question: Tell me about Socrates.
Answer: Socrates is mortal
How do you represent this when coded in your favorite language? If a software can be intelligent enough to automatically infer the Answer based on Rules 1 and 2, that would be its first step to modify its own behavior based on the business rules.
Let’s take the Outlook example we discussed in a previous post. We need to represent a rule where the software monitors a user’s actions of moving his emails from “Barack Obama” to the outlook archive “Obamaniac”. The software finds that the user always does this move, decides that this is his pattern of behavior, and it automatically creates an Outlook rule which moves all mails from “Barack Obama” to the “Obmaniac” folder.
One very useful method of representing such rules is the First-Order Logic. Mathematically, the rule for our Outlook example could be represented as below using First Order Logic. (
= There Exists,
=And,
= For All)
Implementing first-order logic in code is never simple. Prolog is one excellent language to represent first-order logic, but is too general purpose for our interest. What could be helpful, is something which, in principle, is similar to Prolog, but is more driven by the domain.
In the next post, we’ll explore the idea of domain driven representation of logic.



Comments
"Let’s take the Outlook example we discussed in a previous post."
It will be great if a link is provided to the previous post.
Posted by: John Wesley | April 28, 2009 8:49 AM