The bottom-level tier in the Centeno Framework are Services. Services are low-level concerns that could be applied to any project. They contain no business logic. Tate and Gehtland talk about aspect-oriented programming as a way to program better, so I’m going to apply it to Centeno and see what happens.
I’ll assume we’re starting a project and we want to use Scrimshaw but there aren’t any downloadable services for it yet (sorry). Take the requirements and break them into aspects, or processes. So in a store, rather than going page by page, you’d have a shopping cart aspect and a product mainenance aspect (add/edit/delete) as well as others. This may not be the best example. Anyway, since every company is likely to have their own needs as far as data for their store, the product maintenance portion would fall into the Domain tier as specific logic for an application. But perhaps the shopping cart aspect and the shipping calculation aspect and the e-mail notification aspect and others could be done as a transparent service that all your work could use.
Rather than go page by page creating everything that page needs, you go aspect by aspect and complete a whole process at a time and then snap them together. It’s faster and you’ll be thinking more clearly about the whole process rather than the process on one page.
So in our e-mail notification service, we’ll create a new service file,
service.Email.class.php and place it in our classes directory which we’ve already placed in our
Create the basic skeleton for the class. Leave out the constructor, since whenever possible Centeno services should be static class methods. My rule of thumb is that if you’re going to house data in a class, you should need to instantiate it, but if all you’re doing is processing data, there shouldn’t need to be an instance of the class.
Next, take a minute to think about the service and the methods that would be useful to have. We’d at least want to be able to send multipart e-mail messages (with html and plain text). We’d probably want to be able to send attachments. Within that service we would need to check for valid addresses, etc., too (which we might want to later provide for in our Validation service when we make that). Let’s start with this and then add to it as we go.