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

  • (3 Pages)
  • +
  • 1
  • 2
  • 3

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

#1 lucky3  Icon User is offline

  • Friend lucky3 As IHelpable
  • member icon

Reputation: 231
  • View blog
  • Posts: 765
  • Joined: 19-October 11

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

Posted 15 November 2012 - 09:47 AM

Hello there.

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?

Is This A Good Question/Topic? 0
  • +

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

#2 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 9387
  • View blog
  • Posts: 35,242
  • Joined: 12-June 08

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

Posted 15 November 2012 - 09:54 AM

Yeah I would have an abstract class that objects would inherit from.
Was This Post Helpful? 0
  • +
  • -

#3 jon.kiparsky  Icon User is online

  • Pancakes!
  • member icon


Reputation: 7875
  • View blog
  • Posts: 13,365
  • Joined: 19-March 11

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.
Was This Post Helpful? 1
  • +
  • -

#4 lucky3  Icon User is offline

  • Friend lucky3 As IHelpable
  • member icon

Reputation: 231
  • View blog
  • Posts: 765
  • Joined: 19-October 11

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.

Edit:
California Vehicle Code example of act to be simulated (posted after baavgai's answer below)

This post has been edited by lucky3: 15 November 2012 - 10:19 AM

Was This Post Helpful? 0
  • +
  • -

#5 baavgai  Icon User is offline

  • Dreaming Coder
  • member icon

Reputation: 5882
  • View blog
  • Posts: 12,760
  • Joined: 16-October 07

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

Posted 15 November 2012 - 10:13 AM

Data ain't programming. And the OO hammer isn't always the best tool.

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. :P )
Was This Post Helpful? 1
  • +
  • -

#6 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 9387
  • View blog
  • Posts: 35,242
  • Joined: 12-June 08

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.
Was This Post Helpful? 1
  • +
  • -

#7 jon.kiparsky  Icon User is online

  • Pancakes!
  • member icon


Reputation: 7875
  • View blog
  • Posts: 13,365
  • Joined: 19-March 11

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

Posted 15 November 2012 - 10:20 AM

View Postlucky3, 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.


So, skynet is what you're looking for?
Was This Post Helpful? 0
  • +
  • -

#8 jon.kiparsky  Icon User is online

  • Pancakes!
  • member icon


Reputation: 7875
  • View blog
  • Posts: 13,365
  • Joined: 19-March 11

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

Posted 15 November 2012 - 10:28 AM

View Postmodi123_1, on 15 November 2012 - 12:18 PM, said:

Jon's right - there's a tree structure to be followed.



And baavgai's right: XML is a good tool for doing this. There's really no reason why the data should be in the code, and a markup language is a good way to represent this data on disk.
Was This Post Helpful? 0
  • +
  • -

#9 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 9387
  • View blog
  • Posts: 35,242
  • Joined: 12-June 08

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

Posted 15 November 2012 - 10:34 AM

Man.. if I had a structure to abstract who is right this post would be easier. ;)
Was This Post Helpful? 0
  • +
  • -

#10 lucky3  Icon User is offline

  • Friend lucky3 As IHelpable
  • member icon

Reputation: 231
  • View blog
  • Posts: 765
  • Joined: 19-October 11

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.
Was This Post Helpful? 0
  • +
  • -

#11 jon.kiparsky  Icon User is online

  • Pancakes!
  • member icon


Reputation: 7875
  • View blog
  • Posts: 13,365
  • Joined: 19-March 11

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?
Was This Post Helpful? 0
  • +
  • -

#12 lucky3  Icon User is offline

  • Friend lucky3 As IHelpable
  • member icon

Reputation: 231
  • View blog
  • Posts: 765
  • Joined: 19-October 11

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.
Was This Post Helpful? 0
  • +
  • -

#13 lordofduct  Icon User is offline

  • I'm a cheeseburger
  • member icon


Reputation: 2538
  • View blog
  • Posts: 4,639
  • Joined: 24-September 10

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

Posted 15 November 2012 - 10:51 AM

How are you representing actions at all?

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.
Was This Post Helpful? 1
  • +
  • -

#14 jon.kiparsky  Icon User is online

  • Pancakes!
  • member icon


Reputation: 7875
  • View blog
  • Posts: 13,365
  • Joined: 19-March 11

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

Posted 15 November 2012 - 11:00 AM

And this fits in with the article/section/subsection stuff how?

I mean, there's a difference between a cop and a DA and a legislator.
Was This Post Helpful? 0
  • +
  • -

#15 lordofduct  Icon User is offline

  • I'm a cheeseburger
  • member icon


Reputation: 2538
  • View blog
  • Posts: 4,639
  • Joined: 24-September 10

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".
Was This Post Helpful? 0
  • +
  • -

  • (3 Pages)
  • +
  • 1
  • 2
  • 3