31 Replies - 1734 Views - Last Post: 22 November 2012 - 06:51 AM

Abstract article (as in law) class? [OOP design]

I was wondering if it would be possible to create an abstract (not in the sense: "to be inherited", but more like generic) Article class in the OO programming language. Let me explain:

Act (or is it more appropriate to say regulation) has articles, and each of them has at least one paragraph. Some of them are declarative, some executive (sanctions...). Some refer to other articles and regulations, etc..

Suppose you wanted to simulate the tax rules of law. Or the traffic rules. Not simplistic, but true simulation of the rules, that would be tested with different scenarios.

Would you consider it is possible to construct such an abstract (generic) Article class, which would ultimately allow for the simulation of the laws of the whole country?

Or is law so complicated, that each article (or most of them) would represent mini program itself?

Re: Abstract article (as in law) class? [OOP design]

Posted 15 November 2012 - 10:01 AM

I would incline towards a tree structure. Try a class embodying "legal texts" which can either be literal text or a list of legal texts - think of it as a directory listing, where the literal texts are leaf nodes, or files. No need for separate classes, I'd think, just use an enumeration of section types - "Law", "Article", "Section", "Sub-section", "Clause", etc.
Let the section numbers be generated from the text's position in the list, don't try to keep track of them in the text itself.

Re: Abstract article (as in law) class? [OOP design]

Posted 15 November 2012 - 10:10 AM

Hmmmm... perhaps I wasn't clear, or I just don't understand your answers. It's not just a text representation of individual paragraphs, or searching for particular string occurrence inside its instances. It should act and interact with other articles, and with others, form intelligent entity.

Suppose we have traffic regulation act from such Article classes. And we hook it to a traffic simulation. It should autonomously detect all traffic regulation offenses, and report them. For example.

Re: Abstract article (as in law) class? [OOP design]

I'd be thinking markup. Isn't this one of the problems that to SGML, the ancient ancestor HTML, was used for?

Now it's more common to XML for such documents, basically a simplified version of SGML. A document is a document, even if it has lots of meta data, bullet points, and nuances peculiar to it. XML can handle it, validate it, and is a ubiquitous format with a plethora of available resources.

( I just got to use "ubiquitous" and "plethora" in the same sentence. )

Re: Abstract article (as in law) class? [OOP design]

Posted 15 November 2012 - 10:18 AM

Woah woah woah... trying to mesh the words of a law and the actual reality/events of a possible infraction are quite difficult.

Jon's right - there's a tree structure to be followed. For example - my state's laws are organized into chapters. Each chapter has sub chapters. Subchapters have sections. Subchapters have citations of the bill passed to create that section of the law. There are addendums that can be attached to sub chapters, repeals, and annotations.

Re: Abstract article (as in law) class? [OOP design]

Posted 15 November 2012 - 10:20 AM

lucky3, on 15 November 2012 - 12:10 PM, said:

Hmmmm... perhaps I wasn't clear, or I just don't understand your answers. It's not just a text representation of individual paragraphs, or searching for particular string occurrence inside its instances. It should act and interact with other articles, and with others, form intelligent entity.

Suppose we have traffic regulation act from such Article classes. And we hook it to a traffic simulation. It should autonomously detect all traffic regulation offenses, and report them. For example.

Re: Abstract article (as in law) class? [OOP design]

Posted 15 November 2012 - 10:37 AM

It's not the text that matters, it's what it represents. Ultimately, class instance that would hold action(s) for particular offense would trigger event that would be listened by another type of class, responsible for text representation. Let's not focus on text, but the system and actions, the act represents.

Re: Abstract article (as in law) class? [OOP design]

Posted 15 November 2012 - 10:41 AM

This raises all sorts of questions about representation. What does a traffic violation look like in your code?
for example, how are you representing a running of a red light or a speeding violation?
And how does that get applied to an actual violation?

Re: Abstract article (as in law) class? [OOP design]

Posted 15 November 2012 - 10:48 AM

Quote

how are you representing a running of a red light or a speeding violation

With interfaces. For example each of traffic sign objects should implement particular interface(s). In practice, we are seeing standard traffic signs that comply with the law. You could say they implement certain interface.

Re: Abstract article (as in law) class? [OOP design]

Laws forbid/allow actions, so you need an action that can occur. Laws also come with consequences that are actions too.

I'd see something like a class to represent actions. Actions should be able to composite other actions (compound actions).

Now how should these actions work as well. Isn't it reasonable to suggest that if an action is known to be illegal, sometimes the action would hault before doing so anyhow? Or maybe the action would be judged for a cost-benefit. It's illegal to run a red light, but we're on our way to the hospital... it's more costly to stop.

Re: Abstract article (as in law) class? [OOP design]

Posted 15 November 2012 - 12:29 PM

Oh and speaking of DA and legislator and the sort.

Laws aren't clear cut either. It's evidence based. And you get to have trials by jury and the sort.

So how are we representing all of this stuff as well? It's not a matter of "did they break the law", it's a matter of "is there enough evidence in the actions to warrant a trial to see if a judge and/or jury should rule on if a crime was actually committed".