Use Batch Methods to Group Related Method Calls
I once had lunch with a group of programmers who were visiting my company from Germany. They were from a company that was partnering with the company I was working for. We were supposed to use CORBA to handle the method calls from their system to ours. But there was a problem.
“CORBA,” they confided to me, “doesn’t work. It’s much too expensive. It doesn’t scale very well at all.” I was a little surprised by this. I’d been using CORBA for a couple of years at that point, and I’d never run into scalability problems (at least, not at the scale we were talking about).
It turned out that their idea of “building a
distributed application” was to
“build a single-process application using standard
object-oriented techniques and then stick the network
in.” Their testing had revealed that if an instance
of
Person
is on one machine, and the user interface displaying information
about the person is on another machine, a sequence of fine-grained
calls such as
getFirstName( ),
getLastName( ), and getSSN( )
to get the values to display on the screen has performance problems.
Once I figured out what they were complaining about, I had a solution: “Don’t do that.” The object decompositions that make sense in a single-process application often don’t make as much sense in a distributed application. Instead, you need to carefully look at the intent behind sequences of calls and see if you can encapsulate a sequence of calls in one bigger method ...