Where does the business logic go?

This is a debate I have both listened to and been a part of for years. When you are building an app of any respectable size, where does the business logic go? Specifically, for the sake of this discussion… In ColdFusion or Oracle?

To be honest about my opinion I think it is only fair to share where I “fit” into things. I would consider myself extremely proficient in data design, database programming, and query writing. Especially in the world of Oracle. I consider myself proficient, if not a bit rusty, in ColdFusion. The way our team is set up, I am the “backend” guy and therefore I live in the database. UI? Hacker. I follow what is going on, and can make modifications easily, but I am not the guy you want coding your front end.

I have been fortunate to be with my current company for quite a few years which means I have seen the full range of philosophies on this subject.

When I was a one man team, or working with a single other developer… if it could go in Oracle, it went in Oracle. Data updates all went through Packages and data retrieval, most of the time, did so as well. This worked well for us. I would be out front with the customers gathering requirements and designing the architecture for the app. Once I reached around an 80% completion range, the CF and UI guy (same guy) was brought in to bring it all together and get the app to the customer.

In the case above, the Oracle packages ended up serving similar needs as CF components. If you wanted a “project” object, you ended up with output parameters representing the “project” as well as recordsets representing things like invoices, checks, people/roles, etc. CF said “give me a project and everything about it”, Oracle did the heavy lifting. I liked it.

Several years back, I began working with a larger team that was comprised of quite a few more proficient CF and UI folks. Given the high number of applications to produce/maintain, our development strategy changed. All of the business logic got pulled out of Oracle and into CFCs. My role was still data architect, but business logic was rarely my realm and I also got labeld “the query guy”. We have a lot of apps and a lot of data to manage, so since I am the main Oracle guy, this works well for our team. We have more CF people so in this case, it makes sense to have the business logic where it is accessible to the most people to understand and maintain.

So my question is this… with all things being equal, where “should” it go? Or is it always a function of the skills/staff available on the project?

Advertisements

2 responses to “Where does the business logic go?

  1. Brad Wood November 5, 2013 at 9:36 pm

    I have always favored the application server since it scales better. Most applications have one database, but can (fairly) easily roll out multiple web servers. If my application has dependencies (i.e. send an E-mail every time an order is saved) it feels more correct to tie that into the service level. If order creation is entirely handled by a large stored procedure, now your database has to deal with sending E-mails too. I’d rather it just save the data.

    Now, that being said I’ve been a SQL Server DBA and I can recognize there are some operations– typically ones that involve large data sets which will always perform faster when handled by an RDBMS. For this reason I avoid “always/never” statements and like to use common sense when architecting.

    • hagoodc November 6, 2013 at 3:54 am

      I see what you are saying; especially when you talk about scaling. Most of what I deal with are corporate (inside the firewall) applications which means scaling rarely is part of the discussion. I also think how “transactional” the application will be plays a role in the decision making. Again… not what I typically deal with. I guess I would fall into the larger data sets side of the argument. In this case, with our setup, heavy data lifting lends to Oracle providing better performance.

      One other big hurdle I haven’t solved is passing complex data structures into Oracle in a way that doesn’t result in way more PL/SQL code than it is worth. Dealing with objects in CF (in a world where you use CF and the DB) seems to make more sense as well.

      I will have to look into this “common sense” idea you describe for data architecture. It intrigues me.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: