From: Brian Candler Date: 2007-02-24T00:38:26+09:00 Subject: Re: Web frameworks - separating UI from logic On Fri, Feb 23, 2007 at 11:50:17PM +0900, khaines@enigo.com wrote: > >Would it also be true to say that in Rails, the de-facto model is just a > >bunch of database tables, with a separate ActiveRecord facade sitting in > >front of each table? For example, if a particular action requires four > >tables to be updated, would the controller typically get four > >ActiveRecords, > >modify them and write them all back? If so, this seems to bundle the 'user > >interface' and 'application logic' parts together more closely than I'd > >like. > > You'll find that for most simple web apps, this level of separation is the > common case. For that majority of applications, it is a sweet spot > between having enough separation to make code management easier and > cleaner, while not having so much separation as to introduce additional > complexities. This doesn't preclude having greater separation, though. OK. Perhaps what confused me about Rails is that there seem to be a lot of default controls - the CRUD stuff - which act on a single table at a time. If I could hide those sort of controls, and expose only higher-level controls to the user which perform business logic, that would be part of my problem solved. The other part is ensuring that my application isn't tied only to interactive HTTP use. But then I should be able to build (say) a SOAP facade which maps onto the same controls, yes? Then all I have to do is ensure that no database updates are possible except via these controllers - for example, by keeping the database write password secret. > Now, regarding your overall application design, I don't understand why > you'd need to implement an RPC server for the application logic, so my > first impression is that you would be best served by writing a class > library that encapsulates the application logic. Well, "RPC" was also assuming that by the time this was deployed, there would need to be multiple application servers for load-sharing and resilience. But equally, "RPC" could just be direct object invocation - i.e. LPC :-) Thanks, Brian.