ATK Design Principles
From Achievo/ATK Wiki
ATK follows a number of design principles. Understanding these principles will help you understand how ATK works and will help you create applications more efficiently.
The Hollywood Principle
"Don't call us, we'll call you"
Most frameworks consist of components that have an API that allows you to invoke certain functionality. While of course ATK has these APIs as well, the most important parts of the framework follow what is called the so-called 'Hollywood Principle'.
The 'Hollywood Principle' gets its name from the process of recruiting actors for movies. At the end of a screening, the candidates would hear "Don't call us, we'll call you". For ATK, this means that the main application flow is not run by you as the developer of an application, but by ATK itself. To do its work, ATk will then call methods in your classes to get things done.
I.e. instead of you saying "hey present me a form" to ATK, ATK will turn things around. ATK knows when it needs to present a form, so instead it will say to you "I'm going to present a form; give me the fields you want to have in the form"
This makes ATK very powerful, but also slightly confusing to novice developers. They're not accustomed to this 'inversion of control', also, unfortunately, this makes documenting the framework more difficult.
Also see wikipedia.org the Wikipedia article.
Analogy: A good way to understand the Hollywood principle and the difference with other frameworks is to compare it to the preparation of food. Zend Framework and other frameworks are comparable to the ingredients you'd use to prepare a meal. The Zend Framework manual is a set of recipes to tell you how to use the ingredients and how to combine them into the meal. ATK is a higher level framework, which means that there are still ingredients, but they are abstracted away from you. ATK is where you get a menu and you'd simply say 'Steak please!' and the steak comes fully prepared and all you have to do is eat. How does the hollywood principle fit in? The hollywood principle is the waiter dropping by your table and asking 'how would you like your steak sir?'. You'd simply say 'medium' and the waiter dashes off and your stake will be medium.
Suggestions for further reading:
- Once you are developing in the ATK framework, you'll want to know what methods ATK will call. See the Hooks for a list of methods that are useful to implement to influence ATK's behavior.
Code Minimization
We are lazy developers. This means we don't like to write too much code. ATK is completely focused on getting as much done as possible, using as few lines of code as possible. So instead of giving you many objects that can do an enormous amount of things for you, we have a very minimal API that does things that you might expect from a CRUD application, because in the end, most applications work more or less the same. This means that we do not only abstract features, we abstract the whole concept of an application. This is why we can have the slogan 'an application in 10 lines of code'. You only code what makes your app different from other apps. (In other words, you can focus on your business logic). Security, form building, session handling, templating; all of that is 'been there, done that' for most developers anyway, so ATK takes care of all of this for you.
Assumption Driven Development
To be able to minimize code, ATK adheres to what we call 'assumption driven development'. We assume a lot. We assume that when you build a CRUD application, you want to have a list of records with edit and delete buttons. We assume that if you make a field unique that you'll want to let the user know if he violates this, we'll assume that you'll want a calendar when you edit a date field. Or even for small internal details. Like "I'm assuming that if you want to hide a field for the user, that we can leave it out in the query that retrieves your record".
ATK basically says "look, I'm going to assume you'll want to have things this way; tell me if you want things otherwise". This principle makes ATK very Rapid, because if you don't tell it to change its assumptions, it will assume things in such a way that it can build an app for you.
ATK provides an enormous amount of Hooks that you can implement to change its behaviour. The hooks follow the Hollywood Principle, so if they're not there it's fine, but if they're there, ATK will call your hooks and you'll be able to influence its behaviour.