Wednesday, December 2, 2009

What Can Logikit::Framework Do For You?

Note: I know it's a bit long. Anytime you feel bored and want to see the answer for yourself instead, please get Logikit::Framework from http://framework.logikit.net

During an online discussion at LinkedIn, one of the members, Didier Peereboom Voller, in his comment used an anology I like a lot:
"You don't sell a car by pointing out that its brakes work. You MIGHT sell a car if you point out that its brakes work better then anyone else's. "
Everybody drives a car but few of them try to design a brand new one. However, most of people have a "dream car" in mind, and in most cases some of people's dreams are also common. Some of us look for a much more confortable car, while some others give the first priority to the security and some people don't care anything else but the speed of the car. Of course, you can find a faster, a more secure, cheaper, less fuel-consuming or a more confortable car, but when you look for all of them in one place, that's where the dreams begin.

Then, can't anyone find out there, an affordable car that fits his/her needs, at least by 80-90%? Yes. Actually, that's the common situation. Most of people drive a car -a good or bad one, but a working one at least- and most of them again tend to "upgrade" his/her car from the very first opportunity. That's human nature. If it wasn't this way, we would still be riding horses. And given the opportunity, most of us would want to have "something better".

As far as I can tell, there are four items you have to possess to create something both new and usable:
1- Idea: You have to know exactly in advance, what you'll be doing.
2- Reason: You have to know why you are doing it. Without a reason acceptable for the public, the novelty you have made will remain in your hobby room.
3- Time: Everything takes time. Much or less. But you have to have it enough to put your plans in life.
4- Knowledge: Even if you already know what exactly you will produce, you also must know how to do it. Also, you have to know how to afford the development costs for your project.

If you are a team, a company, a faculty -name it- possessing those four items above in the mean time, you can do virtually anything.
But for a single person, it's hard to have all four in the mean time. If you are a student, probably you have time and ideas -and perhaps also the reason- but not the knowledge for sure (otherwise, you wouldn't remain a student, right?) If for you, school days are long gone, then probably you have an idea, a reason and the knowledge, but no time. In the latter case, you could put your time and create your dream car... and would you give it away?

Fortunately, in software business, combining the four items, you may have your dream software, can use it, improve it everyday, change the parts you don't like, add new things, and can also give it away so that other people can also benefit.

So, let's come back to Logikit::Framework (LF) and see how its breaks work better than anyone else's and answer the question "can it fly?".

"Economics is the science of satisfying unlimited demands with limited resources". - Peter Schiff

Dreaming is good, however when it will come to plan to put the dream into life, one of the first things to be figured out is the need to favor some features against some others. When designing a car, if you want a faster one, this will probably mean to weaken the security, or to consume more fuel or both. One needs to be very meticulous using his choices, from the "paper and pencil" phase to the test drives. Below is how I will "sell" my dream:

- Not a superiority over other frameworks, but this needs to be mentioned first: LF is published completely free of charge, under MIT license, the most libertarian one I came across. What I'm telling here is "I realized my dream. If your dream is different than mine and if you want, you can take and do whatever you want out of it. It can't fly yet, but if you ever come up with a 'wings' library, who knows?"

- In my opinion, to have a good project architecture is one of the key reasons to use a framework. LF is very well structured and offers everything a programmer may need to keep the project clean and maintainable, but still flexible and in most cases, does not force people to follow the way that is originally advised.
Thanks to LF structure, in a case you will need to add a field to a form, for example, in a project you deployed a year ago, it will be a matter of seconds to do it, cause you will know exactly where the form file is. Adding the field and setting the validation rules will be a real small job, to add another element to the form array.
Like most of modern frameworks, LF uses a MVC (Model-View-Controller) pattern, in most cases associated with a form and a validator. So the pattern might be called MVC+FV.
Every controller may have it's own model and it's own view, form and validator folders and every action (function in the controller class) may have it's own form and validator, and must have it's own view. The particular views are included in a higher structure called a "template" (a single html/php file in fact) during the software lifecycle.
The forms are defined as an array, however the array elements can be used free-style within a view and each of them can be placed anywhere needed in the layout design.
The validators can "talk" directly to the forms, uniforming and easing the validation handling.

- Although it's never obligatory to use it, LF comes with a code generator that can create the controller, the model, the views, the forms and the validators, starting from a database table. The resulting code will permit to do CRUD (create, read, update, delete) work along with pagination and sorting, and best of all, it's fully Ajaxified, and the design is still flexible, mainly CSS based, so the generated layout also can be altered to fit any design.
For me, this is also an important feature to let people choose for themselves and use the generator if they need it, when they need it. In some frameworks, to use a generator is almost obligatory to start a project, while some others totally reject to use it. Using LF, a programmer can use it anytime he/she will need it, not only at the beginning of a project, or can forget it for good.

- LF's model system is based on PDO, practically permitting the use of a lot of DMBS's (MySQL, PostgreSQL, Oracle, SQLite and so on) with the same code, providing a database abstraction layer. To use the model structure is encouraged and the only default way to interact with the database is the model. Of course, it's still not obligatory and one may create another object extending the model and use it within controller, but I think that will be against one of the major arguments of a MVC view. However to use such an object may be needed especially with the external libraries, and a solution for the purpose is also provided. The structure of the database class can be defined as a "lightweight version of active record pattern", leaving the decision to write raw queries or use predefined methods, to the programmer. Following existing LF standards, programmer will have very clean and usable models, and as always, the final choice is him or herselves.

- LF's library structure is exactly as it needs to be: Any external library could be just copied into the library folder, can be loaded and used within the controller in no time. If the library has dependencies, those dependencies also can be simply included or loaded within the library. An instance of the controller object is always available in hand so libraries have total access to controller capabilities.

- LF also offers built-in libraries. At this point, it's hard to say the libraries are enough to solve everything, however LF is not planned to be a simple MVC architecture, but it aims to be "self-sufficent" so that a programmer may be able to use only LF to solve 99% of the problems. With the first version (1.0.0), we had only a couple of libraries. As of version 1.0.1, image processing, ftp and email libraries have been introduced. Authentication, ACL (access control list), encryption, file compression, payment (paypal, 2CO and authorize.net), calendaring and PDF libraries are on the way. I can't promise for a date or a release order for them, as I also need to make my living. I'm also always open to any contributions also here, as I am for the other parts of the project. Until this time, I didn't use any 3rd party php code, but I'd appreciate it if some of you would like to participate and share his/her works, so we can speed up the things.

- Some helpers are "auto-auto-loaded" and are also used within the LF core. Say, if you need a "preformatted" print_r() function, it's already there. If you need a "flash message" on the actual page or the next page, it's also there. Thinking how those "small issues" let us lose some important time when it comes to the total time cost, the benefits of this could be better understood. As all independent functions are defined in a global scope, they are accessible from troughout your project.

- LF is packed with JQuery along with an ajax and messages helper using it, turning the ajax works and everyday's Javascript issues into a piece of cake.

- LF provides a URL-rewrite by default, based on Apache mod-rewrite, with an .htaccess file. It is also smart enough to understand if you are using a URI structure in a form "http://yoursite/yourLfInstallation/index.php/yourController/yourAction" or in a form "http://yoursite/yourLfInstallation/yourController/yourAction".

- Unlike most of other frameworks, LF can have an unlimited deepness with controllers.
While you may only have a maximum of two deepness with most of them (as in "http://yoursite/yourLfInstallation/index.php/yourSubfolder/yourController/yourAction"), LF can have something like "http://yoursite/yourLfInstallation/index.php/yourSubfolder1/yourSubfolder2/.../yourSubfolderN/yourController/yourAction/yourParams", and it will detect which part of the URI corresponds to your controller. I know, many projects won't need such a feature, but it's useful if you are a meticulous programmer who looks after a well-organized software structure, even with 20-30 controllers. And if you are dealing with a project with 1000 controllers, there it will become a required feature.

- This should not be considered a superiority, but: LF is well documented. Of course this is a must for every piece of software, however I must admit I have seen only two or three other framework docs comparable to LF docs.

- Besides all of the above, LF is designed to be remarkably, extremely fast. You may check the benchmark results mentioned in another post on this blog or better, can repeat them for yourself and compare with some other frameworks.

After having wrote that much, I can really understand how hard is car dealer's work, but if you were patient to read it to the bottom, I guess I managed to sell my car.