主题:[讨论]请问面向对象应该是怎样一种思想
mudwzq
[专家分:80] 发布于 2007-10-25 10:51:00
以前学的是面向过程的C,现在改学面向对象的JAVA,一时在思想上有些难以转变过来,主要就是遇到问题时从哪个方面去考虑呢,我知道C遇到问题主要考虑用什么方法去解决,教材上说JAVA遇到问题首先去构建一个对象,但怎样构建呢?是把问题构建成对象还是问题中涉及的数据构建成对象啊?
我遇到问题还是习惯先找出解决的方法,定义类的时候也还是习惯写成类似于C中的函数,怎么样才能从思想上转变过来啊,请教下过来人的经验!
回复列表 (共4个回复)
沙发
justforfun626 [专家分:18460] 发布于 2007-10-25 11:12:00
Haha, been there, done that.
Think in the real physical world, full of Objects.
Each Object has its own properties, behaviors.
Objects interact with each other, communicate with each other.
Object, like you, has something don't want others to know or to touch (private), allow something only give to your son/daughter(protected)
You buy a TV, you don't need to know the electric circuit to watch CCTV (encapsulation)....
Here is some possible help:
[url]http://bobcat.webappcabaret.net/javachina/faq/03.htm#oo_[/url]
板凳
justforfun626 [专家分:18460] 发布于 2007-10-25 11:17:00
OO is easy to be accepted by beginner, but it is hard for C-programmer.
I know somebody worked on Java several years still not thinking in OO.
Java is easy, but change thinking is hard.
You need to be aware of that.
3 楼
mudwzq [专家分:80] 发布于 2007-10-25 11:30:00
谢谢,如果转变真的很难的话,我会试着忘掉面向过程的思想,就好像要武侠中要学一门上层武功必须把原来的武功废了一样,我努力培养这方面的意识的.
4 楼
justforfun626 [专家分:18460] 发布于 2007-10-25 18:53:00
Way to go, at least for a while.
Actually, you will never really forget.
I forgot how to swim for a while, and when I went to the water, swimming skills came back! [em2][em2]
我来回复