zoukankan      html  css  js  c++  java
  • (zt)OO vs. SOA

    Removing the intimacy to create services

    Ram is back from vacation has been blogging on the subject of SOA and OO.

     

    While I agree with option C in Ram’s post, some of his comments took me back to the PDC talk where Don was explaining the difference between a service and an object.  One of his observations that resonated with me was that ‘services help remove the intimacy’ from distributed computing.  For those who didn’t see the talk, here’s my extended and modified analogy from this:

     

    Imagine two entities, A and B.  A wants to borrow $5 from B in good faith.  A plans to return the money to B by the end of the day.

     

    If these two entities were objects, the interaction may look like this: 

     

    A walks up to B, goes into B’s pocket, promptly removes his wallet and the $5.  After he has the money, A leaves.  B is left wondering ‘Hey, what happened?  I was robbed!’  B doesn’t know if and when he’ll see his money again.

     

    In this case, the interaction between A and B in the object world is very intimate.  B can of course use security to prevent A taking the money, but in general there is little to do to remove the intimacy of the interaction.  

     

    To think like a service, you have to remove this intimacy.  One of the easiest ways to do this is to think about how a similar interaction would take place in the real world.  Going up to another person and trying to forcibly remove cash from their wallet in this way is likely to end you up in some trouble.  Instead, the interaction in the real world (and the model that we can adopt for a more service based approach) looks like this:

     

    Again, A wants to borrow $5 from B in good faith. 

     

    A walks up to B and asks ‘Hey, can I borrow $5?  I forgot my ATM card and need to buy lunch’.

     

    B wants some reassurance about A.  B takes a quick look at A.  Assuming no breakthroughs in human cloning, B decides he can trust A as he has had previous interactions, and A still looks and sounds the same.   Despite this, B wants some validation that his money is going to be returned.

     

    ‘When will I get my money back?’ B enquires.

     

    ‘I’ll have it back to you by the end of the day, plus an extra $1 for your trouble’.                                        

     

    B accepts the proposal, opens his wallet and gives A the $5.  The interaction is concluded and A walks away happy.

     

    Although a simple analogy, I’ve found that removing the intimacy and thinking about how the interaction could occur in the real world can really help when defining services – and more importantly the types of interfaces that services expose.  Even if the technology promotes a service orientated approach, it’s this type of shift in thinking that helps define true services as opposed to merely exposing objects.

     

     

    Published Thursday, January 29, 2004 11:48 PM by smguest
    Done is better than perfect.
  • 相关阅读:
    JS基础_自增和自减
    计算机组成原理
    SyntaxHighlighter
    10个经典的C语言面试基础算法及代码
    知名互联网公司面试题
    计算机网络基础知识(笔试题)
    面试准备之常见上机题目搜罗
    小米2013年校园招聘笔试题-简单并查集
    2014华为上机试题
    C++学习笔记
  • 原文地址:https://www.cnblogs.com/zhaorui/p/931607.html
Copyright © 2011-2022 走看看