其实有很多概念都是误导性的# Java - 爪哇娇娃
z*3
1 楼
举个例子
比如oo,oo讲究你要把现实中的所有的实体全部包装成对象
这个是没错
但是j2ee并不是完全的oo
或者这么说,它的oo,是建立在某些并不是你想的那种情况基础之上的
比如你这么理解oo,现实中的每一个人
你要写程序建立一个object去映射它
然后这个人应该要有自己的思想吧?
要有行为吧?这没错
那既然如此,那这个对象的行为是不是它的方法啊?
对啊,是啊
但是你这么做j2ee你就等死吧
没有人这么做
因为当你把对象行为封装到对象本身中去的时候
你就在创造一个controller
而controller是要集中管理的
如果打散到各个实体中去的话
是错误的
所以要想理解j2ee,要先理解mvc
j2ee三个层面分别代表着mvc的三个部分
web就是viewer
db就是model
中间就是controller
但是mvc也有自己的问题
最典型的就是当你要建立ai的时候
理论上应该是单独跑一个线程吧?
比如游戏中一个角色,你要封装它,那应该至少单独给它跑一个ai的thread吧?
然后这个thread跟其他的m也就是游戏的model做通信
对吧?
但是这个是错误的,错误的主要原因是并发的操作的问题
各种狗血,所以swing是单线程的,尼玛
实际上大多数时候,controller都是假的面向对象
controller是面向上帝
什么意思呢?也就是假设这个世界的一切都是上帝在背后操纵
而具体的每一个生命是没有自己思想的
所以每一个实体只需要对上帝负责就是了
然后由上帝来集中控制所有的行为
用这种方式来设计代码
可以解释几乎所有的程序
所以软件工程的程序里面每一个实体是没有思想的
可以认为不是真正意义上的面向对象
如果你用这种方式去思考j2ee,那么就很容易理解aspectj和spring的aop了
也就是面向切面的编程
这是一个很好的对于jar的补充
尤其是当你手头上需要用到同一个jar的不同版本的时候
比如oo,oo讲究你要把现实中的所有的实体全部包装成对象
这个是没错
但是j2ee并不是完全的oo
或者这么说,它的oo,是建立在某些并不是你想的那种情况基础之上的
比如你这么理解oo,现实中的每一个人
你要写程序建立一个object去映射它
然后这个人应该要有自己的思想吧?
要有行为吧?这没错
那既然如此,那这个对象的行为是不是它的方法啊?
对啊,是啊
但是你这么做j2ee你就等死吧
没有人这么做
因为当你把对象行为封装到对象本身中去的时候
你就在创造一个controller
而controller是要集中管理的
如果打散到各个实体中去的话
是错误的
所以要想理解j2ee,要先理解mvc
j2ee三个层面分别代表着mvc的三个部分
web就是viewer
db就是model
中间就是controller
但是mvc也有自己的问题
最典型的就是当你要建立ai的时候
理论上应该是单独跑一个线程吧?
比如游戏中一个角色,你要封装它,那应该至少单独给它跑一个ai的thread吧?
然后这个thread跟其他的m也就是游戏的model做通信
对吧?
但是这个是错误的,错误的主要原因是并发的操作的问题
各种狗血,所以swing是单线程的,尼玛
实际上大多数时候,controller都是假的面向对象
controller是面向上帝
什么意思呢?也就是假设这个世界的一切都是上帝在背后操纵
而具体的每一个生命是没有自己思想的
所以每一个实体只需要对上帝负责就是了
然后由上帝来集中控制所有的行为
用这种方式来设计代码
可以解释几乎所有的程序
所以软件工程的程序里面每一个实体是没有思想的
可以认为不是真正意义上的面向对象
如果你用这种方式去思考j2ee,那么就很容易理解aspectj和spring的aop了
也就是面向切面的编程
这是一个很好的对于jar的补充
尤其是当你手头上需要用到同一个jar的不同版本的时候