软件建模三元素

偶然的灵感, 能否以后编程就和写作文一样呢? 这也应该是面向对象的终极目标吧.下面这个是经常出现在教科书上的例子.

Person tom = new Person() – > tom is a Person

Dog trigger = new Dog() -> trigger is a Dog

List<Person> friends = new ArrayList<Person> – > Person have Person friends

Person implements Emotianal,HumanBehave -> Person behave Emotional and surely behave as a human.

interface Emotional{ sadly(); happily();} ->Emotional including sadly and happily doing things.

interface HumanBehave {cry();laugh();call(Person);} -> HumanBehave including cry and laugh and call somebody.

tom.cry().sadly() -> tom is crying sadly

tom.call(ann) -> tom is calling ann

如果以后将软件建模分为过程建模(process modeling)和对象建模(OO modeling),那么就更和谐了.让流程引擎来管理对象的生命周期以及提供上下文环境,对象只是一些功能性的个体.可能是因为最近了解了一些jBPM的东西.其实还应该有规则建模(也就是AOP主要解决的问题).过程,规则,对象这三者是否可以成为”三元素”而统一所有的软件建模领域呢?

有点不明白,为什么java不直接把void这种返回值省略掉,也就是如果没有东西返回就返回this.虽然只是一个很小地方,但真不觉得void有什么用.

例文:

A story about tom and ann (tom,ann,cruger=new Person…)

It’s friday.Raining. (context, initialize , environment)

Tom goes to the cinema, buys a ticket and sit. (tom.goToCinima().buyTicket().sit())

Movie started.(environment changed)

Tom notices a pretty girl beside him.(tom.notice(ann))

Tom fell in love.(tom.fallInLove(ann))

Tom kissed the girl whose name is ann. (tom.kiss(ann))

Tom get kicked ass by cruger who is Ann ‘ boy friend’. (cruger.kickAss(tom))

The end. (process end)

哈哈

Comments are closed.