(Copied in part from my blog at http://www.dotnetified.com)
NOTE: Let me preface this by saying that "I want to believe." I really do want to learn the so-called "right way" to do things, but I do reserve the right to point out the emperor has no clothes if I feel it hampers my productivity... It seems to me that it's a battle between the RAD guys and the server-side guys. One group wants to get a project up and running with the minimum amount of code required to actually communicate with the backend, while one group wants to build a robust, maintainable architecture. I'm afraid I'm currently in the RAD camp right now. Although I futzed around a bit with objects in C++, I never really "got" the concept of object-oriented development until COM arrived (OK, OK, for you purists out there, I refer to it as "component-oriented." Satisfied?) One of the truly nifty things about COM/OLE2 was type libraries: you could redistribute your library, and as long as you included the type library as a resource, some other developer could use your components in their app. This led to domain-specific libraries that exposed heirarchies of objects that were commonly called "Object Models." These object models typically intermingled state and function (e.g.: ADO), but that was OK because, after all, everything was running on the same box. Enter distributed applications and DCOM/COM+. Since it was expensive to remote an object and have it getting/setting properties and invoking methods over the network, we ended up writing libraries chock-full of objects that only had methods, and other libraries that had objects that only contained state. The server-side libraries took and returned instances of the state objects, marshaling them over the wire. The best part was that the developers of the client apps just had to reference your datatypes library and reference the server-side library's type library, and they were able to ferry data back and forth. Life was good, except for the pesky issues surrounding code maintenance. If you updated the library containing the datatypes (to add a property, for instance), you typically had to update the server-side library and the client apps, to boot. This led to many all-night upgrades and much wailing and gnashing of teeth. Enter XML Web Services. Instead of using shared datatypes libraries, we just agree on a contract and pass XML back and forth. Now we have this wonderful loosely coupled mechanism so that old apps continue working without a recompile! Oh, but now every client app developer has to write an internal object model unless they are willing to dispense with strong typing and don't mind littering their app with XPath statements. Yes, you can try to use DataSets, but, frankly, I don't consider DataSets to be good enough to replace a true object model1. So, since each developer ends up writing code that maps XML to objects and vice-versa, the number of bugs WILL increase. And to be honest, I sure do like that Intellisense. So what to do? I want my easy development (reference a couple of assemblies and you're ready to code the UI with the minimum amount of client-side code required), but I want my ease of maintenance (I want to be able to add more information to the message that is passed to/from the Web Service without requiring a recompile on the client side). I already have a couple of projects under my belt using shared assemblies that contain data-only objects and WebServices as a glorified RPC mechanism, and all things considered I must say that it's worked out quite well. The problem with this approach is that you have to hack the proxies generated by the framework tools to make them use the shared types rather than automatically generated types, and I find doing such an end-run around the platform's tools distasteful (but worthwhile). I have also written a couple of SOA-style projects that just pass XML messages back and forth, mapping the XML to ad-hoc client-side objects when it made data binding easier. I have to say, it's actually pretty cool. Modify the server to your heart's content, and as long as the service contract is backwards-compatible, (i.e.: no new and required elements) everything's fine and dandy. But I did end up copying & pasting quite a few classes from the server-side code. All of the above being said, I am currently gravitating towards the shared assembly and RPC model. Why? Because I work with a group of developers, all of whom are writing the client side apps while I toil away on the server-side. I could simply ask them to consume XML and not worry my pretty head over how they manipulate the data, but it's MUCH easier for them to reference my shared types assembly, add a Web Reference, then run my "Munging Macro" to fix up the types used by the proxies. Happy colleagues means happy Andy, because I then don't get angry/confused phone calls. Yes, the SOA idea is a good one, but I believe it only works well if A) you are only trying to provide a service (i.e.: clients ain't your job) and B) only one client for the service is being written by the developer. -Andy Hopper ---------------------------------------- 1 - For instance, you lose the collection-as-a-property syntax COM developers are used to - the ability to write an expression like Movies["12 Monkeys"].Actors["Brad Pitt"].Salary or, better yet, Movies["Blade Runner"].Actors.Add(myNewActorObject). =================================== This list is hosted by DevelopMentor� http://www.develop.com Some .NET courses you may be interested in: NEW! Guerrilla ASP.NET, 26 Jan 2004, in Los Angeles http://www.develop.com/courses/gaspdotnetls View archives and manage your subscription(s) at http://discuss.develop.com
