As a Java programmer I hear all the time that the most important thing in the universe is to separate your business and presentation logic. Mind you, this often comes from JSP developers who have just recently helped themselves to the custom tag library Kool Aid, who a year ago would have told me that it's fine to mix Java and HTML together because everybody pretty much knows both anyway (that's an exact quote from an earlier argument, by the way).
So today I was thinking about exactly what it means to separate your business logic. I mean, where do you stop? Separate it from what, exactly? Is it ok to just separate it from the JSP page, and therefore stick it in the Java? At my current job we've had a rule since day one that certain business operations needed to be possible without Java intervention (for example, the creation of new site map elements). That meant extracting certain logic even farther, such as into XML files that could be dynamically reloaded without the need for a code push or a server reboot. Is that what separation of the business logic *really* means, and it's just that the rest of the industry hasn't reached that point?
I had a discussion today on the following subject. I have a business object that contains some properties I need to expose in a JSP. One option is to create a custom tag for every property. Another is to create a [property name="x"] tag. In the days of just DTDs I would have opted for the former, for validation purposes, but now with XML schemas that's not so much of an issue. Here's the catch -- the business object is defined by an XML file, which may in turn change its definition during normal running of the site (i.e. fields may be added/deleted). Now what? If I use the first method and want to add a field, I need to add Java code for a custom tag (whether it is automatically generated or not), do a code push to production, and possibly a server bounce. But with the second, I push out the new XML file and schema, and have an ops person use the admin console to restart the appropriate service. Is one method superior to the other? Some would say that if you're going to push changes out to production than it doesnt matter how you do it because your exposure is the same (that is, you could crash the site no matter what you do). But I think that the separation issue comes into play, since the latter method doesnt invoke any development resources (no IT resources at all, if we can assume that the service in question will be reloaded on a fixed schedule such as nightly).
So maybe when we say separate the logic, what we really mean is *who* is responsible for it, and what can that person do? Our content management system uses JSP framework files that just drop HTML content "tiles" into place. Why? Because we have an army of web monkeys who only do HTML and were not trained as JSP programmers. So we made a separation (content has no custom tags) that many people would not even have considered, if they have a team of all JSP people. But is that right? Is there a universal right?
When we first started, the rules were easy because everything was pretty much being hand coded. HTML people did HTML, Java people did Java, and so on. We even had one content dude who insisted he wouldn't leave MS Word (we wrote him an automatic doc to html converter, and no we didn't use Word's because it sucks). We had certain separations because we had no choice. There was no hot deploy for our server, either, so pushing new Java meant bouncing (which was a no-no). But times change. XML is considered a good thing not because people will write XML, but because it's easy to write GUIs that populate XML and hide the syntax. So we let our "non-developers" generate and push out XML. Ok, well, why not use that XML as a feed to a Java code generator and build some classes on the fly? Debugging's not really an issue, because if you debug your generator, you'll know that all your classes are correct. Once upon a time the answer would have been that dreaded "code push == server bounce" gotcha, but hot deploy changes even that. So is it even valid anymore to make the separation where we've made it?
One of the reasons that this has come up is that my team has existed for five years, and developed a certain philosophy for how web architecture, roles & responsibilities should work. And we're all getting laid off. So naturally we're looking to see how leveragable our experience is in the job search. And I'm finding that often it seems like we did things *differently*. I'm wondering if that therefore means we did them wrong. I don't think so.
For the record, I have no point, I'm just rambling to try out my journal.