Sunday, October 12, 2008

Andromeda: Give it a chance

I have been working with Andromeda for well over a year now and I can honestly say that I love this framework! I have tried many other frameworks including the following:
  • Mach II (ColdFusion)
  • FuseBox (ColdFusion & PHP)
  • Joolma (Not necessarily a framework)
  • MyCMS (PHP) developed by jeff@madtasty.com
And I have always found a reason that I could not use the framework in the fashion it was intended. I guess this is because alot of framework take the MVC approach and try to separate the business logic from the display logic. The MVC approach can cause a very large headache when you are picking up somebody elses' project and they are no longer around to answer questions. It also can cause a little bit of a headache because in my option it tries to be too organized. So I have never really used a framework for any given project because once I have started on these projects I have found the need to modify the framework in such a way that now what I have made exists outside the framework.

Now going back to the MVC approach, its definetly a good idea on paper however in the site/application is still just file based. So in the end instead of looking in say one object file you are looking in about 2,3,4 or even more places just to add a field to the page.

In my opinion Andromeda takes an MVC type approach and separates the business logic from the code completely, and puts it in the database. All your business rules go into the database and now the database does the validation, so you can never have invalid data.

Andromeda uses YAML to define the database and the rules. An example of this would be:

table contacts:
module: addressbook
column name:
primary_key:"Y"
description: Name
tooltip: Persons Name
uisearch: "Y"
column add1:
primary_key: "Y"
column add2:
column city:
column state:
column zip9:

The above creates a table called contacts with 6 column: name, add1, add2, city, state, zip.
Andromeda has predefined columns. I have used only predefined columns in the table above, but sya you wanted to create another field to store the contacts favorite food, you could achieve this in the following way:

column favorite_food:
type_id: vchar
description: Favorite Food
table contacts:
module: addressbook
column name:
primary_key:"Y"
description: Name
tooltip: Persons Name
uisearch: "Y"
column add1:
primary_key: "Y"
column add2:
column city:
column state:
column zip9:
column favorite_food:



You now have defined a column "favorite_food" that can be used in any other table in your application. Now once we build our application this table will exist in our application and can be edited right away with 0 code. One of the things I love the most about Andromeda is that it created the CRUD (CReate, Update, Delete) screens for you, with 0 code so any time you might have spent creating these screens is no longer needed and if you go back and look at my table definition you'll see there is a property called "module". This allows us to assign permissions groups for each of these modules. This is done in the following way:



group editors:
description: Address Book Editors
module addressbook:
permsel: "Y"
permdel: "Y"
permins: "Y"
permupd: "Y"


This defines a group called "editors" and gives it SELECT(permsel), DELETE(permdel),INSERT(permins), and UPDATE(permupd) permissions to any table in the module address booke. OK I am sure by now you are asking "but how does this put the business logic in the database?" OK lets say we now want to be able to assign phone number to these contacts we can now add a couple more tables to allow for this.



group editors:
description: Address Book Editors
module addressbook:
permsel: "Y"
permdel: "Y"
permins: "Y"
permupd: "Y"
column favorite_food:
type_id: vchar
description: Favorite Food
table contacts:
module: addressbook
column name:
primary_key:"Y"
description: Name
tooltip: Persons Name
uisearch: "Y"
column add1:
primary_key: "Y"
column add2:
column city:
column state:
column zip9:
column favorite_food:

table phonetypes:
module: addressbook
column name:
primary_key: "Y"
uisearch: "Y"
description: Phone Type
tooltip: Phone type eg. Cell, Home, Work

table contactnumbers:
description: Contacts Phone Numbers
foreign_key contacts:
uisearch: "Y"
primary_key: "Y"
foreign_key phonetypes:
primary_key: "Y"
uisearch: "Y"
column phone:



We've now added two tables(phonetypes & contactnumbers). The phonetypes table is extremely simple and allows us to add phone types such as Cell, Work, Home, etc...

The contactnumbers table has foreign_keys to the two previous tables contacts & phonetypes and that will tell the system that the primary_key fields from those tables need to be included in this table and to also make the primary_keys for this table. Our CRUD screens we will also have a drop down list for the foreign_key entries and this is done again with 0 code. What these primary_keys do is restrict each contact to having one phone type for each contact. If you try to insert more than one phone number for each phone type for a given contact, whether it be through the CRUD screens or even the SQL command line you will get an error telling you that the record already exists. So you don't have to make sure the record exists before you try inserting it, its done for you...yes of course you can still do this just so that your application wont have a DB error thrown back but the benefit of this is you can never get more than one phone type for a given contact into the system.

Now say for instance you wanted to have the number of phone number for each contact included in the contact record, you can have this done in the database for free with what Andromeda calls AUTOMATIONS. Here is how this is achieved:



column num_phones:
type_id: int
description: Number of Phone Numbers
table contacts:
module: addressbook
column name:
primary_key:"Y"
description: Name
tooltip: Persons Name
uisearch: "Y"
column add1:
primary_key: "Y"
column add2:
column city:
column state:
column zip9:
column favorite_food:
column num_phones:
automation_id: COUNT
auto_formula: contactnumbers.phone



Once again we've added another column definition(num_phones) and now you'll notice the automation_id property of COUNT and the auto_formula of contactnumbers.phone this tells Andromeda to do a count of records in the contactnumbers table that reference this table as a parent table(foreign_key). This is only a tip of the iceberg when it comes to Andromeda. There are many other useful automations and features such as ranged primary keys and dominant records.


This entire article is my opinion and probably not that well organized but I highly suggest taking a look at this "Database Development System/Framework". My basic examples above do not even compare to what is possible with Andromeda. It does sometimes take changing the way you approach certain things but in the end you will have drank the coolaid realized why you will never use another framework again.

I would highly suggest joining the mailing list and sending an email if you think something cannot be approached in the way you like. I have found more than once that the way that I like isn't the best way.

**Comments are welcomed and appreciated, even if you don't agree**

Monday, June 30, 2008

ExtJS

I've been working with ExtJS lately, and I must say I am highly impressed. For those of you not familiar with ExtJS (Ext), Ext is a crossbrowser javascript framework that allows for the creation of RIA (Rich Internet Applications).

Ext uses the latest and greatest web 2.0 methods, such as ajax, which has built in parsers for JSON, XML, text and possibly some other formats. Ext allows for the creation of desktop looking interfaces with just som simple notation(Ext is probably not the first project to do this)...this in my opinion is one of the greatest things Ext has to offer. The simple notation way of creating these interfaces allows for rapid deployment of interfaces, and takes the GUI creation out of the hands of the developer, and allows the developer to focus on getting the data to the front end.

Alot of chatter has been generated in the past couple of months on the decision to change the licensing model. The most current version of Ext uses the GPL 3.0 model in my opinion it may have not been the greatest of choices for a license however it still allows you to create open source applications. And if you want to build an application that you will be selling for $ you can purchase a license which will ultimately help support the project and only make it better.

There is one negative aspect to Ext, the documentation....yes all the information you need is there and they even give some basic code in the documentation however in my opinion the examples of interfaces/widgets are all given in the notation format of creating objects however the examples in the docs all give examples of referencing things or adding eventlisteners via old sytle javascript. This i think determs alot of people, they do have a community support forums but that can also at times be discouraging, as it may take a couple of bumps to get a question answered.

In my opinion the Ext documentation could take a lesson from the PHP documentation and add common examples in this notation style format, for the various things you may want to do with an object/widget/datastore.

In the end Ext is a great product with a bright future and just needs to polish its documentation as well as it has its interface objects.

Wednesday, April 30, 2008

jQuery

Well I've been using jQuery from quite some time now, and I must say they have a great product. It is a extremely easy to use as well as makes things such as alternating row colors in a table so easy, with two lines of code you can have alternating row colors on a table. The plugin support is great and pretty much anything you can think of you can find a plugin for.

Andromeda is rocking along and from what I here from Ken there may be some news coming in the next couple of weeks or so.

Thursday, February 21, 2008

Andromeda SVN

Well now that Andromeda has had SVN support built in for about two weeks I must say it makes pushing updates from dev to staging ALOT easier also has allowed for cooperative development of Andromeda even more possible.

I would say keep your eye on the Andromeda site in the coming weeks for more exciting news.

And for those of you who have yet to try it...just do it already!! It will change your world.

Sunday, February 10, 2008

Busy Week

Well this past week has been extremely busy both @ work and after work with Andromeda. Which is funny because both are connected. The e-commerce project I have been working on for the past ~5 months now uses Andromeda, so a lot of the bugs, most in my custom code not so much Andromeda lately, that I find keep Ken a little busy.

But besides that Ken has been busy this week getting SVN(subversion) working for upgrades of Andromeda, and also deploying Andromeda applications. We will hopefully be announcing the AndroPage feature this week, it is currently available in the most recent releases of this week we just haven't announced it. I am working on getting the LIPHP site wrapped up so we can get that out there.

I have a couple of extra that I am going to work on this coming week for Andromeda which include report back features this way we can start to see how people are using Andromeda as well as where in the world people are using it.

I can actually say that I finally have used a framework that I would use for anything. And it does try to separate the code into all sort of sections and folders, my worst experience with something like that was fusebox(Coldfusion) or Mach-II also coldfusion. Drupal and Joomla both have way too much stuff to sort through to find anything, and then when you have found it, you havent it's something that just has the title that you were looking for.

Andromeda makes creating an application with logic easy, and even just a website is easy to throw together with Andromeda and is even easier since the introduction of AndroPages. I am going to also start working out my idea of creating a google chart plugin for AndroPage which will bring reports to the next level.

Well that also for now, happy programming everyone.

Wednesday, January 30, 2008

Upcoming Andromeda Feature

About three weeks ago I was working on a project for work, that is using Andromeda and for some reason got to thinking about reports. And I thought to myself why couldn't we use YAML to define reports. So I sent an email to Ken Downs and suggested that we should get together and hash this idea out. So we got together about two weekends ago, and I presented this idea to him, and then showed him Smarty and showed him a couple of things that could be done with it.

Basically the whole "concept" comes down to the following
  • We already have our tables defined in the application YAML file
  • A report is just how to display the data
  • Smarty Gives us a way to have some logic (Looping, Alternating Row Color)
  • WE just need a filter for the data to display (WHERE CLAUSE)
So over the course of the rest of the weekend Ken coded up the concept of an AndroPage, which literally passes off the data to a another class that handles either turning the data into a Report(PDF) or a page(Smarty). After he was done with that I put into place the code that loops through the sections, and assigned the row(s) to the appropriate Smarty Variables named after the section they are in.

The definition of page looks like this:
options:
title: Reviews

section review:
onerow: "Y"
table reviews:
column name_book:
compare: = @book
column review:
column ts_ins:
column ts_upd:
column uid_ins:
column uid_upd:

uifilter book:
description: Book Title
type_id: vchar
colprec: 50

template: p_review.tpl

options: Allows us to set things such as page title.

section: Allows us to litterally pull as much data as we want and place it in different sections around the page, such as maybe client information in one area and then ads pertaining to this clients industry in another area.

onerow: Specified that we only expect one row back for this page(This is done so that we do not need a foreach loop in the smarty template)

table: Refer to tables that are specified in the application YAML file. Multiple tables can be specified and Andromeda will attempt to join the tables based on primary_keys

column: The columns to be used for display from the tables.

uifilter: Tells Andromeda that we need to filter on something, and if its not specified display a page so the user can enter it.

template: Tells Andromeda that this is a Smarty Page and to use the specified template.

Each section get assigned to a Smarty variable with the same name, then you just have to create the Smarty template.

An example of a Smarty template is this:

{* Smarty *}
<table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td><h3>{$review.name_book}</h3></td>
</tr>
<tr>
<td>Review:</td>
</tr>
<tr>
<td>{$review.review}</td>
</tr>
<tr>
<td>Reviewed by: {$review.uid_ins} on {$review.ts_ins}</td>
</tr>
</tbody>
</table>
There as still a couple of minor bugs which should be fixed shortly and then there will be a release.

Thursday, January 24, 2008

Blog Change

I have decided to go with Blogger instead of Drupal as there were too many options in Druapl and changing something took some digging. So now I am using blogger.