Contact Doug!
Learn About Doug!
View Doug Boude's online resume
updated 11/18/2009

View Doug Boude's profile on LinkedIn
Link to me!

Follow Doug Boude on Twitter
Follow me!

Be Doug's friend on Facebook
Befriend me!
(I promise not to follow you home)
OO Lexicon
Chat with Doug!
Recent Entries
You may also be interested in...
Florida web site design



Czech your Page Rank!
Check Page Rank of any web site pages instantly:
This free page rank checking tool is powered by Page Rank Checker service
Surf's Up!
Visit Egosurf.org and massage YOUR web ego!
My Score: 9,001
Doug's Books

Read (and recommend)

  • Men are from Mars, Women are from Venus
  • The Wisdom of Crowds: Why the Many Are Smarter Than the Few and How Collective Wisdom Shapes Business, Economies, Societies and Nations
  • Blink: The Power of Thinking Without Thinking
  • Head First Design Patterns
  • Transact-SQL Programming
  • What's So Amazing About Grace?
  • Just So Stories (Rudyard Kipling collection)

Reading

  • Prayer: Does it Make Any Difference?
  • Data Mining (Practical Machine Learning Tools and Techniques)
<< May, 2009 >>
SMTWTFS
12
3456789
10111213141516
17181920212223
24252627282930
31
Search Blog

Recent Comments
Categories
Archives
Photo Albums
Funnies (5)
Family (3)
RSS

Powered by
BlogCFM v1.11

21 February 2007
Just What IS a 'Service Layer', Anyway?

(Consider hiring Doug to instruct you and your team in the ways of OO!)

I've been hearing the term 'Service Layer' everywhere for at least the past year and a half, as I'm sure most of my peers have as well. Whether it's seen in blog posts, heard during casual conversation at conferences, found in articles, or woven throughout almost any discussion at all concerning OO and Coldfusion...the term is quite prevalent and common these days. But I had a problem: the term held absolutely ZERO connotation in my mind. No picture was ever conjured up when I came across it, no corresponding 'Doug Boude' translation was found in my internal lexicon; I felt quite out of the loop. Ah, but recently that has all changed, as the phrase itself has not only come to life for me, but found an absolute and permanent place in all that I do, technically speaking; an epiphany, if you will.  I just figured there were others out there who, like myself, may still be kinda grasping for a way to think about the term, so what follows is my personal definition/explanation of what a Service Layer really is. Please feel free to append, addend, flip, and twist it to your heart's content until it's as whole as it ever can be.

SERVICE LAYER

 

 

This is not NEARLY as gray and ambiguous a term as you might think. Picture if you will, a man sitting comfortably on his sofa. In one hand is the remote for his very large plasma TV; in the other hand is a remote for his home theater system. The two remotes and the man are all objects, and all three come pre-built with things they can do. In the kitchen is the man’s wife; let’s think of her as the calling application. She barks out the order to the husband object, “START THE MOVIE, YOU IMBECILE!”. The husband object just happens to have a startTheMovie method, and begins to execute it. First, he manipulates the objTVRemote object, calling its “tvOn” method. Then, he manipulates the objDVDRemote object, calling it’s “dvdOn” and “dvdPlay” methods. Now he manipulates the objTVRemote again, calling the “inputSRC” method and switching the tv to receive the dvd input. Tada! Movie is playing now!

Pretty clear scenario, eh? Well, in this illustration, the MAN is acting as the SERVICE LAYER. Although he has a “startTheMovie” method, all he’s really doing is coordinating efforts between other lower level objects that actually do the work. His wife doesn’t care about the remotes or how they work, and her life is then simplified because she need only make her one call to her SERVICE LAYER OBJECT and he handles the nitty gritty details. Service Layer…not such a deep, complicated mystery after all, is it?

Doug out.




Posted by dougboude at 6:15 AM | PRINT THIS POST! |Link | 7 comments
Subscription Options

You are not logged in, so your subscription status for this entry is unknown. You can login or register here.

Re: Just What IS a 'Service Layer', Anyway?
Yeah, I've always fantasized about a Service layer that the ColdFusion developers would call.
Them: "SELECT * FROM Cust".
Me: You may WANT a list of all customers, but this is the list that I'm going to GIVE you:
SELECT * FROM Cust
INNER JOIN Security
ON Security.CustID=Cust.CustID
WHERE UsrID=#You#
Posted by Phillip Senn on February 21, 2007 at 11:06 AM

Re: Just What IS a 'Service Layer', Anyway?
Great analogy!
Posted by Sal on February 28, 2007 at 11:06 AM

Re: Just What IS a 'Service Layer', Anyway?
Is this the same as an Object Factory?
Posted by Josen Ruiseco on March 2, 2007 at 3:40 PM

Re: Just What IS a 'Service Layer', Anyway?
Hi Josen!
Actually, no, a service layer is not an object factory at all...two different animals. An object factory is itself and object whose job it is to create instances of other objects for you. So, instead of writing 'createObject("component","model.user")', you'd instead ask your object factory for it with something like 'cfset myNewUserObj = objFactory(objToMake="user") . Make sense?

Why would you want to do this, you might ask? Well, you might want to do this in order to simplify your object creation process and lessen the amount of code needed throughout the rest of your app. There are a myriad of other possible reasons to do it, as well, but that's content for a blog post all its own.
Hope this helps some.
Posted by dougboude on March 2, 2007 at 3:59 PM

Re: Just What IS a 'Service Layer', Anyway?
I get it now...another debate that I have heard is where the business logic should reside...in the service layer or the domain objects. Can anyone expand on scenario?
Posted by arcot on March 17, 2007 at 10:57 AM

Re: Just What IS a 'Service Layer', Anyway?
Ah, you've used yet another commonly used term ("domain"), yet one which tends to conjure up very little by way of visual associations. As far as I'm concerned, and the team I work with, the "domain" of any of our applications is everything that lives inside and under our "MODEL" directory. Our rule of thumb is (and we've adopted and modified this to meet our needs) that, if we had to change frameworks tomorrow, everything that IS our app should live inside the Model directory, INCLUDING and ESPECIALLY the service layer objects! Here's a scenario that REALLY drives this point home:
We build an app that manages medical benefits. In order to perform a simple task such as "change my medical coverage", there are actually several underlying object calls needed, and thus a "benefitServiceLayer" object. Now our home office mentions during a status meeting that they'd like to be able to leverage that same business logic in an app they're building, and they'd like to do it via web services. The only object that needs exposing as a web service is our benefitServiceLayer object...all of the other objects live below that one and are not accessed directly from the home office. So, from this scenario, it's absolutely clear that our service layer objects are JUST as much a part of our 'domain' as any other object containing business logic, and thus the service layer objects must belong within our MODEL directory.
That's what it looks like from where I'm standing, anyway.
Posted by dougboude on March 17, 2007 at 11:11 AM

Re: Just What IS a 'Service Layer', Anyway?
Thanks for this excellent and humorous explanation of "service layer."
Posted by Keith DeWeese on July 4, 2008 at 9:07 AM

Name:   Required
Email:   Required your email address will not be publicly displayed.

Want to receive notifications when new comments are added? Login/Register for an account.

Time to take the Turing Test!!!

17 plus 9 equals
Type in the answer to the question you see above:

Your comment:

Sorry, no HTML allowed!