我怎么能摆脱一个神对象呢? [英] How can i git rid of a god-object?

查看:69
本文介绍了我怎么能摆脱一个神对象呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每一个人都坚持使用很久以前在c#中编写的旧代码,我的第一个任务就是放弃一个几乎10 000 lign的上帝对象,任何人都知道我该怎么办

谢谢你



我的尝试:



我试图分析代码,并发现其中的fonctonalities,在近50个其他类中使用,(注意所有的功能,每个类最多使用这个类的2到4个小说)

hi every one i'm stuck with an old code that was writen in c# a long time ago , my first task is to git rid of a god-object almost 10 000 lign , any one has an idea how should i proceed
thank u

What I have tried:

i've tried to analyse the code , and found out that the fonctonalities that are there , are used in almost 50 other classes , (note all the fonctions, each class uses at most 2 to 4 fontions of this class )

推荐答案

以与吃大象相同的方式解决问题...

一次咬一口。



分析问题并查看哪些功能可以移到较小的班级。

然后重复使用其他功能。

然后再重复一次

再次

又一次

直到你对自己拥有的东西感到满意为止。



注意:不要只是为了更改代码。您必须证明进行更改是合理的。

如果它当前有效,请不要更改它。
Solve the problem in the same fashion that you would eat an elephant...
One bite at a time.

Analyze the problem and see which functionality can be moved to a smaller class.
Then repeat with another functionality.
Then repeat again
And again
And again
Until you are satisfied with what you have.

Note: Don't do this just to change the code. You have to justify making the change.
If it currently works, don't change it.


这篇关于我怎么能摆脱一个神对象呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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