Ayende @ Rahien

My name is Oren Eini
Founder of Hibernating Rhinos LTD and RavenDB.
You can reach me by phone or email:


+972 52-548-6969

, @ Q c

Posts: 6,128 | Comments: 45,550

filter by tags archive

Macto, or How To Build a Prison

time to read 3 min | 506 words


The sample application that I am going to build is going to be a prison management application. I am going to take this post as a chance to talk about it a bit, discuss the domain and then I’ll talk about the overall architecture in more details.

The domain of a prison is actually fairly simple, you have an inmate, and the sole requirement is that you would keep him (it tend to be overwhelmingly him, rather than her) in lawful custody.

The term lawful custody has a lot of implications, which are, in more or less their order of importance:

  • The inmate is in custody, that is, he didn’t manage to run away.
  • Custody is lawful, that is, you have legal authorization to keep him in jail. Usually that means an order by a judge, or for the first 24 hours, by a police officer.
  • Lawful custody itself means that you:
    • keep the inmate fed
    • in reasonable conditions (sleeping quarters, sanitation, space)
    • access to medical facilities. Indeed, in most prisons the inmates get better health care, especially for emergencies, than the people living in most big cities.
    • ability to communicate with lawyers and family

The devil, however, is in the details. I am pretty sure that I could sit down and write about 250 pages of high level spec for things that are absolutely required for a system that run a prison and still not get everything right.

In practice, at least in the prisons I served at, we did stuff using paper, some VB6 apps & Access, and in one memorable occasion, an entire set of small prisons where running on what amounted to a full blown application written using Excel macros.

Anyway, what I think that I’ll do is start with a few modules in the system, not try to build a full blown system.

The modules that I‘ll start with would be:

  • Staff – Managing the prison’s staff. This is mostly for authentication & authorization for now.
  • Roster – Managing the roster of the prisoners, recording Countings, etc.
  • Legal – Managing the legal side of the prisoners, ensuring that there are authorizations for all the inmates, court dates, notifications, etc.
  • Escort – Responsible for actually taking the inmates out for court, medical evacs, releasing inmates, etc.

That is enough for now, for that matter, it is a huge workload already, but that is about the only way in which I can actually have a chance to show a big enough system and the interactions between all the parts.


Kyle Szklenski

I hope you meant a Roster class, not Rooster. :) That would be one hell of a rooster, managing all that!


A large feeling of anticipation, and a nagging one of guilt. A week or two after writing about needing to take breaks to avoid burn out you are making a complex application for no other purpose than community example. Thanks.

Bobby D

Really looking forward to seeing the app come together.. thanks for listening to the readers!

Kornelije Sajler

Sounds very interesting. I can't wait to see progress of MactoPMS and great developer at work. I also hope that you will not stop and rework all app like Rob Conery did!

Mikael Henriksson

Without doubt the most interesting sample application I have come across so far. Will be very nice to follow how you go about it.


In your post "Feature by feature" that you had multiple folders in the same project / assembly for Model, Infrastructure etc.

You also mentioned that you think really hard before creating new assemblies. While I agree excessive layering is bad, what is the difference between this approach and creating seperate assemblies for model & infrastructure.

It is more separation of concerns than needless complexity

Ayende Rahien


More projects == slower VS

Jake Scott

This should be good cant wait!

Kyle Szklenski

Also, venu, who says you can't have separation of concerns with a single assembly? I think having a decent folder structure that all developers involved understand and more importantly use can be just as effective. Just have to make sure no one crosses the line, and since there's only one developer on this right now. . .


Looking forward to this series.

Frank Quednau

Excel Macros...Hm, thank God I've never been sentenced to 77.1*850 years in prison, it would take even longer than expected!

Comment preview

Comments have been closed on this topic.


  1. The worker pattern - about one day from now

There are posts all the way to May 30, 2016


  1. The design of RavenDB 4.0 (14):
    26 May 2016 - The client side
  2. RavenDB 3.5 whirl wind tour (14):
    25 May 2016 - Got anything to declare, ya smuggler?
  3. Tasks for the new comer (2):
    15 Apr 2016 - Quartz.NET with RavenDB
  4. Code through the looking glass (5):
    18 Mar 2016 - And a linear search to rule them
  5. Find the bug (8):
    29 Feb 2016 - When you can't rely on your own identity
View all series


Main feed Feed Stats
Comments feed   Comments Feed Stats