使FAT类成为部分&的优点和缺点是什么?将其分为部分类? [英] What are the pros and cons of making a FAT class a partial one & splitting it into partial classes?

查看:70
本文介绍了使FAT类成为部分&的优点和缺点是什么?将其分为部分类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近,我正在考虑一个类,因为其中的方法太多,它似乎变得很胖.

Recently I was considering a class that seems to become fat because of too many methods in it.

旧版代码...

具有许多在各种实体"上执行所有类型CRUD的业务逻辑方法.

That has many business logic-wise methods doing all types of CRUD on various 'Etntities'.

我在想

  1. 使此类不完整
  2. 然后将所有方法按其工作的目标实体分组
  3. 并将它们拆分为单独的物理文件,这些文件将成为部分类的一部分

问题:您能否列出这种重构的优缺点,那就是将一个具体的胖类作为子类并将其划分为更苗条的子类?

Question: Can you list pros and cons of such a refactoring, that is making a fat concrete class a partial class and splitting it into slimmer partial classes?

推荐答案

我想到的一个专家是减少源代码控件中的冲突/合并.您将减少并行检出的次数,并减少开发人员检入工作时不可避免地出现的合并难题.我认为,如果您有很多开发人员经常在同一个班级上工作,那么我就是一个伟大的专业人士.

One pro I can think of is the reduction of conflicts/merges in your source control. You'll reduce the number of parallel check-outs and the merging headaches that invariably come when the devs check-in their work. A big pro, I think, if you have a number of devs working on the same class quite often.

这篇关于使FAT类成为部分&的优点和缺点是什么?将其分为部分类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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