An open letter to object technology newcomers

This report is an html draft of HaT.TR.96.02, which may be submitted for external publication . This early version is being made available for professional peer communication. Since this file was auto-converted and touched up, some html marks may be bad. Please let me know if your browser objects.

Intro

It used to be the habit of authors to write an apology for adding another piece of writing to the face of the earth, and a justification. The need for apology still holds, the justification for this article is this: Over the last 6 years, I have spent numerous and pleasant long evenings in restaurants, bars, and hotel lobbies, discussing the nature of object orientation with other interested seekers of truth, light and wisdom. Over the years, we have been able to answer many of the questions we asked at the beginning. The other night I spent such an evening in a restaurant discussing those same questions asked by a new colleague. The next day, his office-mate wanted the same questions answered, and suggested I capture the discussion for his other colleagues to read. Considering the number of like-minded colleagues he has around the world, asking the same questions, it seems sensible to write it for them all to read.

The key questions were:

  • “Why is it that some OO experts get really upset when I do or say anything that is not strictly and purely object-oriented, but use cases are so popular, while not being object-oriented, and object modeling looks so much like data modeling?”
  • “Would the model produced by a data modeler look the same or different as the structural part of an object model, and would the model produced by a process modeler look different or the same as the behavioral part of an object model?”
  • “Why do we use use cases and scenarios, instead of just modeling the structure of the business?”

The questions are asked repeatedly by new arrivals to object orientation, and cannot be answered without having certain experiences. They come right to the heart of working with object orientation on a daily basis. So they are worth receiving consideration and serious response.

 


 

“Why is it that some OO people get really upset when I do or say anything that is not strictly and purely object-oriented, and yet use cases are so popular, while not being object-oriented, and object modeling looks so much like data modeling?”

My answer comes in 3 steps.

“When Bob <invented name for generic OO expert> and I get together to talk about OO, there is a shared understanding we have of each other, that we are experienced and convinced users of object technology. We understand and expect to use object identity, polymorphism, combined data and behavior, instance responsibilities, inheritance. So when I say, ‘Tomorrow we’ll do data modeling on the application form,’, Bob does not think that I have abandoned objects in favor of relational tables, but expects that we are discussing the structural aspects of the situation, which will show up in the object model. He forgives my use or misuse of the term because he has associated certain expectations with my speech.

When Bob visits your organization, just learning object technology, he sees a strict separation of data from behavior, and an absence or neglect of object identity and polymorphism. So when you say ‘data modeling’, he comes down on you like a ton of bricks. He wants to make sure that you get clear about the shifts you need to make. You will notice that over the last months, your model (and modeling) have slowly acquired object identity, polymorphism, and combined behavior with data. It is perhaps now less dangerous to use the word ‘data modeling’, but there is the chance that he will think you are sliding back into previous work styles. In other words, he does not have those safe expectations with respect to your speech, and so you are obliged to speak carefully.

In the end, even an object model has structural aspects and behavioral aspects. We use those words to signal that we are not making the mistake of doing ‘just’ data modeling or ‘just’ process modeling. In point of fact, modeling the structural aspects is just a particular form of data modeling, being a bit careful with the meaning of the term data modeling. It is not that we are modeling the tables on the disk, but modeling the structure of the information that will be captured. Data modelers refer to this as the ‘conceptual data model’, as opposed to the logical or physical data model. It is something they regularly produce.

On the other hand, if two OO people are talking, and one starts talking about, ‘process modeling’, the other does not have a safe interpretation to give. Does the person really mean process modeling with standard data-flow diagram? These have been shown over the years to give great difficulty when going to an OO implementation, and so the conversation is about to enter a difficult period. Does the person mean the behavioral aspects of the model? Does the person mean modeling a process as an object in itself? This is interesting because it is not done that often. So ‘process model’ is not safe to insert into the conversation because the intent is too ambiguous.

Getting finally to use cases and scenarios, they are primarily requirements-gathering techniques, and are neutral to the implementation technology. They contribute a value in guiding the conversation during design, giving it context and scope. The fact that they are not ‘object-oriented’ is neither good nor bad. The fact that they resemble functional decomposition scares some people, but is also neither good nor bad. The important consideration is that they contribute value to the design process. When they are used to describe internal designs, they present a picture of the behavior of the system. Procedural code, flow charts, interaction diagrams, Petri nets, data-flow diagrams, use cases, all show aspects of behavior, and have different uses, advantages and disadvantages. As long as you know that objects have behavior as well as data, you can work open the discussion about how best to capture or describe the behavior within and across objects.”

 


 

“Would the model produced by a data modeler look the same or different as the structural part of an object model – would the model produced by a process modeler look the same or different as the behavioral part of an object model?”

“In my experience, there are two groups of data modelers – those who model the data on the disk, and those who model the information in the system or in the organization. There is a world of difference between the models they produce and the discussions one can have with them.

Those who model the data on the disk talk and think in concrete terms, often in terms of tables. Their models are often quite different from OO models, and they are unwilling to see the similarities that exist across the technologies. In the data modeling community, it is legitimate to say that these people produce logical or physical data models, without being insulting.

Those who model the information in the system produce the conceptual data model. My experience is that the models they produce are very similar to the models produced by experienced OO modelers. These people typically work a lot closer to the business people than do the logical data modelers, which perhaps explains the difference in their results.

Also, there seems to be a body of knowledge, lore, training, or examples that let these people come to their results faster than OO people do. I have time and time again seen OO people go through three or four design iterations, ending up with the same model that the (conceptual) data modelers produced on the first round. So I have a lot of respect for the data modeling community. In fact, when I get stuck in the object design, I sometimes run and snatch a copy of what the data modelers produced, to look at where we are likely to end up.(因为logical data modeler有成熟且完善的数据库建模理论可以借鉴,而conceptual data modeler则通常是具有全面的坚实的理论和经验的行家里手;殊途同归,也充分说明数据库系统理论建立出的数据模型对对象的结构模型有参考意义;也的确如此,有时从领域建模角度很难理清的对象关联,从数据库建模角度却能快速地得到合理的数据关系)

I had the experience of facilitating a session between warring data and object modelers. We decided to do ‘CRC sessions for an audience’. The four experienced OO designers sat around one end of a long table and were the only active participants. The business experts sat next along the table. They were there to answer questions and correct misstatements about the business. After them were the data modelers. At the far end of the table were other interested people. All told, there were over a dozen people in the room, but only four active people, talking mainly among themselves.

After about an hour of work, a section of the object design had emerged. We asked the data modelers what they had produced in their previous work, whether it was essentially the same or quite different. They said, ‘Essentially the same.’ We repeated this for two more segments of the design and got response from the data modelers each time that we had produced essentially the same design as they had, apart from certain obvious differences in notational technology. They had note used inheritance, but had the same placeholders in the same places. After that we were able to split into groups containing one business expert, one data modeling expert and one OO expert, and they quickly reconciled the rest of the design, identifying where there was a simple difference in technology, and sorting out minor differences. Where there was a difference, it sometimes happened that the data modelers had a better rationale, and sometimes the OO models had a better rationale, and the groups were able to resynchronize their designs.(data modeler会不会骂conceptual data modeler SB? 这么点事,讨论了那么久)

So there have been at least a few experiences showing the similarity between results of conceptual data modeling and OO modeling with CRC cards.

There were also experiences showing the difference between logical (information-on-disk) based relational modeling and OO modeling. For the most part, the differences were due simply to technology, free use of inheritance and many-to-many relations in the OO model. The difficulties came with the inability of the participants to communicate across those technological differences.

So much for the data modeling part of the question.

The same cannot be said at this time for process modeling. Numerous methodologies, plans, conversions and projects were tried in the early 1990’s to adapt data-flow diagram models to objects. A few projects may have laid claim to success, but in the end there seems to have been quiet consensus that they are difficult to map to object models. Most data-flow-diagrammers-become-OO-designers have dropped them (the Martin-Odell and Ptech groups being notable exceptions). My answer at this time is that process modelers do not produce a model comparable to what OO modelers produce.

The answer is not closed, though. OO people are beginning to model process per se. It is not clear how this will evolve. Will the processes start looking like steps in a procedure (procedural programming reincarnated), will they look like data-flow diagrams, or will they look like encapsulated objects?

 


 

“Why do we use use cases and scenarios, instead of just modeling the structure of the business?”

“Use case and scenarios …

... guide the conversation, giving it scope and context,

... indicate what to include, exclude, how wide, how deep to go, and when to stop,

... provide variations to stress-test the design.

I have watched a number of groups do a random exploration of the domain when they model without working from scenarios. How does the leader know what questions to ask next? From intuition guided from some previous experience. How does the group know if they are capturing the information they will eventually need? They often don’t, and don’t know it, or do know it and use intuition and guesswork.

Several really expert OO designers have confessed in the late of the night that they do not have a straightforward formula for getting to the beautiful objects. One said, “We have really wild discussions at times”, another agreed to the notion that, “Sometimes we just beat our heads against the walls until eventually some decent objects show up.”

Using scenarios does not prevent wild discussions and beating heads against walls until decent objects show up. Using scenarios provides a context and boundaries for those discussions so that they stay within the area of interest. Without the scenarios, I watch groups go mad as they wander through an arbitrarily large modeling space for days or longer. So the first reason to use scenarios and use cases is to channel the effort.

The second use of scenarios is to determine when you are done.

Consider that you have been given the job of modeling a trucking company. What do you model? Would you include the new purchase value of the trucks… the actual purchase value… the resale value… the make… the color of the interior… the number of speeding tickets issued against it… the number and destinations of its trips? If you try to include everything, you will never finish. Where do you start, when do you stop, what do you include, exclude, and how much detail do you want?

An answer is provided by the scenarios. You need to have sufficient information to deliver all the questions posed by the scenarios. On the structural or full object model, every box (line, phrase) addresses some need of a scenario. If you color the items on the model red as you walk through a scenario, the red items will all be connected in some way (there will be no islands). If you do this for all scenarios, all items will be colored at the end. There are no boxes (lines, phrases) extra, there are no boxes (lines, phrases) missing. Then you are done. During the modeling work, the conversation may go wild from time to time, but there is a way to tell if you have strayed out of the bounds of the current need, or wandered too deep.

Finally, scenarios provide variations to stress test the design and establish its quality.

How do you distinguish the better between two models? Saying, ‘It matches the business’ is necessary, but not sufficient. There are many possible models that ‘match the business.’ What is the measure of quality?

Software has a very high cost function associated with making changes. For a change request, the cost grows rapidly with the area of damage (the ‘trajectory of change’). The goal for software, then, is to change exactly one module. This will not always be possible, but as Kent Beck says, ‘There is a noticeable difference in the quality of the software when you can change just one class.’ For a business model, it is less clear what the cost function attaches to, but minimizing area of damage is a reasonable place to start.

To test the trajectory of change, you need variations. The scenarios provide the variations. ‘What happens when the user wants to <something-or-the-other>?’ How many items on the model do you have to touch? Some techniques, such as the CRC (‘class-responsibility-collaborator’) technique encourage you to invent _impromptu_scenarios rapidly, to uncover likely, but unstated future changes. At the end, you review the likely changes, and see how many items you have to alter to make those changes. For two models that match the business, that one is better which has fewer (Kent says, ‘One’) touched points for each scenario.

You will also find variations in other places, such as the structure of related products. Can you change products touching just one place? Both sources of variations should be used.

There are other uses of scenarios, such as checking requirements with users, and providing functional test cases for the system. These are the three reasons to use scenarios during the modeling activity itself.”

Discussion

Thank you for writing this down. Over the years I have had very similar conversations with OO newcomers.

You mentioned that OO types, “use object identity, polymorphism, combined data and behavior, instance responsibilities, inheritance.” I would like to add "state" to that list. When encapsulation, object identity, data, and behavior are bundled together objects can control their own life / the states they go through.

OO newcomers are told that objects combine data and behavior. Coming from a functional world they think this simply means co-locating data structures and functions that use those structures. They miss the notion of state — that an object can perform its behavior depending on what state it is in — as it moves through its life cycle from initial allocation to final deallocation. A person in the state of baby, child, teenager, or adult all perform the eat behavior. But, it is performed in different ways depending on state.

Perhaps we could add this notion of statefull objects into the conversation with OO newcomers.

Cheers,
Jim Schardt

-by Jim on 3/5/2009 at 4:34 PM

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
提供的源码资源涵盖了安卓应用、小程序、Python应用和Java应用等多个领域,每个领域都包含了丰富的实例和项目。这些源码都是基于各自平台的最新技术和标准编写,确保了在对应环境下能够无缝运行。同时,源码中配备了详细的注释和文档,帮助用户快速理解代码结构和实现逻辑。 适用人群: 这些源码资源特别适合大学生群体。无论你是计算机相关专业的学生,还是对其他领域编程感兴趣的学生,这些资源都能为你提供宝贵的学习和实践机会。通过学习和运行这些源码,你可以掌握各平台开发的基础知识,提升编程能力和项目实战经验。 使用场景及目标: 在学习阶段,你可以利用这些源码资源进行课程实践、课外项目或毕业设计。通过分析和运行源码,你将深入了解各平台开发的技术细节和最佳实践,逐步培养起自己的项目开发和问题解决能力。此外,在求职或创业过程中,具备跨平台开发能力的大学生将更具竞争力。 其他说明: 为了确保源码资源的可运行性和易用性,特别注意了以下几点:首先,每份源码都提供了详细的运行环境和依赖说明,确保用户能够轻松搭建起开发环境;其次,源码中的注释和文档都非常完善,方便用户快速上手和理解代码;最后,我会定期更新这些源码资源,以适应各平台技术的最新发展和市场需求。
Shifts in China’s Rural and Urban Population: 2000-2020 The bar chart clearly reveals that from 2000 to 2020, while the total population in China increased moderately from 1.25 billion to 1.41 billion, population in urban and rural areas experienced dramatic shifts in different directions. Urban population rose from 450 million in 2000 to 670 million in 2010 and 900 million in 2020; contrastingly, rural population declined from 800 million in 2000 to 680 million in 2010 and 510 million in 2020. The population gap narrowed largely because of the joint effects of urbanization, unequal economic opportunities in rural and urban areas, and the expansion of higher education. In the first place, there was a large-scale urban sprawl during this period. Places which had been part of the vast countryside were incorporated into cities, causing hundreds of millions of rural dwellers to be passively transformed into urban residents. What’s more, while urban living standards improved greatly in these years, few economic opportunities fell on rural areas and most peasant families remained at the poverty line. Poverty prompted the call for change, leading a large quantity of healthy young peasants to leave their hometowns and flock to cities for a better living. Last but not least, China’s higher education grew at an unprecedented rate in these years. More high school graduates than ever before entered colleges and universities, most of whom preferred to stay in urban areas after graduation for personal development. The increase in urban population was a sure indication of economic and educational achievements in China. It benefited the country in many aspects, relieving the shortage of labor force in cities, lessening the burden of peasants to support their families, and affording young people from rural areas more opportunities to display their talents. However, the migration of rural residents into urban areas inevitably brought about disadvantages. Some of them, such as waste of arable land and left-behind children in the countryside, as well as traffic congestion and soaring housing prices in cities, have already called the attention of the government and corresponding measures have begun to take effect. But others, especially the inability of many peasants to integrate into urban life due to their lack of education and civilized habits, have long been neglected. In this sense, we cannot be satisfied with the superficially optimistic figures in the chart, but should endeavor to foster the integration of these newcomers by providing them with adequate assistance in educational and cultural aspects, so that they can find easier access to the prosperity and convenience of urban life and be more fully devoted to the development of cities.翻译成英文版两百单词左右的文章
02-21

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值