OK, even though I'm pretty new to OOP, I've been doing great things and coming to levels of comprehension with it at a pretty amazing rate. My backend is CF10 (dev), MS-SQL 2012.
How I used to get data : Before, I would create a CFC with a method like "executeSQL" and then I'd pass it some parameters, one of which was the name of a .SQL file that was subsequently loaded, executed and then the method would return the results to the caller. I could pass it structures full of dynamic values in the event I wanted to pass "parameters" into the script so that it was dynamic.
How I should get data: This is where I'm stuck. I am familiar with Beans, Gateways and Services, but not to the extend or interacting with Data. In my research, I hear people refer to Beans as singular records of data and Gateways as handlers of recordsets of data. So let's use a blog post for example.
So, I call: PostService.getRecentPosts(). For sake of simplicity, I know a function like this could be passed parameters like 'numberOfPosts' to make it dynamic, but I'm just trying to wrap my head around the role of each object before I optimize them.
OK, so PostService performs logic, and calls PostGateway.getPosts() function. This is my first point of misunderstanding. The GW should only be responsible for performing mass CRUD operations right? So somehow the Service invoked the GW and the GW does what? Does it simply run <cfquery> and supply hard-coded SQL in it?
SELECT TOP 10
p.post_id AS postID,
p.post_title AS postTitle
FROM posts AS p
ORDER BY p.post_date DESC
Before I make this thread too massive. Let's just stop here and get my thinking straight. If someone is familiar with the proper process of getting to this point, I'd love to pick your brain.