回想起来问题是显而易见的 - 写作OO就是一个例子 [英] problems are obvious in retrospect - writing OO being an example

查看:76
本文介绍了回想起来问题是显而易见的 - 写作OO就是一个例子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在5月问了很多关于如何组织OO代码的问题。我在这里没有得到很好的答案,但是有人在这里建议我看看Eclipse库中的b $ b,这是一个很好的提示。看看它的小,

只是对象对我来说是一种教育。


当我将程序代码重写为OO时,我想知道什么? />
是如何避免最终被其他所有人调用的?我写了大量的物品,每个物体都需要其他物品。

这是一团糟。


最后,我意识到我写的东西太大了。

再一次,看着Eclipse库给我带来了这个家。我学到的东西可以提炼到这个:


写鹅卵石,而不是巨石。小物件,而不是大物体。


最终我觉得我终于得到了OOPs编程:那些不需要其他对象的对象
然后成为其他类构建的基础

类。例如,

的部分我的表格类不需要任何其他类成为我的基本表格

class。但是后来我需要$ sql数据库类来获取信息

填写一些表格,我创建了一个子类表格,而孩子

结合了数据库类有基础形式的课程。


回想起来这一切都很明显,但是在五月份它对我来说是不透明的。


我写下这个作为其他人在为同样的问题苦苦挣扎的教训。

挣扎着。

I asked a lot of questions in May about how to organize OO code. I
didn''t get great answers here, but someone here suggested that I look
the Eclipse library, which was a good tip. Looking at its small,
simply objects was an education for me.

What I was wondering, when I rewrote my cms from procedural code to OO
was how to avoid end up have every class called by ever other? I was
writing massive objects where every object needed every other object.
It was a mess.

In the end, I realized that the objects I was writing were too big.
Again, looking at the Eclipse library brought this home to me. What I
learned can be distilled to this:

Write pebbles, not boulders. Small objects, not big objects.

Eventually I feel like I finally "got" OOPs programming: that portion
of my objects that did not need some other object then became the base
class that other classes were built on. For instance, the portion of
my forms class that didn''t need any other class became my base forms
class. But then where I needed the $sql database class to get info to
fill out some forms, I created a child class of forms, and the child
combined the database class with the base forms class.

It''s all obvious in retrospect, but it was opaque to me back in May.

I write this as a lesson for others struggling with the same issue I
struggled with.

推荐答案

sql数据库类获取info to

填写一些表格,我创建了一个子类表格,孩子

将数据库类与基本表单类相结合。


回想起来这一切都很明显,但是我在5月份对我来说是不透明的。


我把这作为其他人在为同样的问题苦苦挣扎的一课我很挣钱。
sql database class to get info to
fill out some forms, I created a child class of forms, and the child
combined the database class with the base forms class.

It''s all obvious in retrospect, but it was opaque to me back in May.

I write this as a lesson for others struggling with the same issue I
struggled with.


lk ** ****@geocities.com (劳伦斯)在
最终我觉得我终于得到了 OOP编程:我的对象的那部分不需要其他对象,然后成为其他类构建的基础类。例如,我的表格类中不需要任何其他类的部分成为我的基本表格类。但是后来我需要
Eventually I feel like I finally "got" OOPs programming: that portion
of my objects that did not need some other object then became the base
class that other classes were built on. For instance, the portion of
my forms class that didn''t need any other class became my base forms
class. But then where I needed the


sql数据库类来获取信息来填写一些表格,我创建了一个子类表格,而孩子
结合了带有基本表单类的数据库类。
sql database class to get info to
fill out some forms, I created a child class of forms, and the child
combined the database class with the base forms class.



你是什么意思组合?


类数据库扩展表单?


What do you mean "combined"?

class database extends forms?


这篇关于回想起来问题是显而易见的 - 写作OO就是一个例子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆