重构代码:什么时候做什么? [英] Refactoring Code: When to do what?

查看:160
本文介绍了重构代码:什么时候做什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

自从我开始使用.NET以来,我刚刚创建了Helper类或Partial类,以保存代码定位并包含在自己的小容器中。

Ever since I started using .NET, I've just been creating Helper classes or Partial classes to keep code located and contained in their own little containers, etc.

显然,干净的代码是主观的,但我想知道的是, m谈论什么时候使用东西(不是如何使用它们)如多态,继承,接口,类和如何更适当地设计类(使它们更有用,而不仅仅是说'DatabaseHelper',因为有些人认为这个坏习惯在代码气味wiki )。

Obviously clean code is subjective, but I'm talking about when to use things (not how to use them) such as polymorphism, inheritance, interfaces, classes and how to design classes more appropriately (to make them more useful, not just say 'DatabaseHelper', as some considered this bad practice in the code smells wiki).

有没有可能有助于这种决策的资源?

Are there any resources out there that could possibly help with this kind of decision making?

请记住,我还没有开始一个CS或软件工程课程,并且教学资源在现实生活中相当有限。

Bare in mind that I haven't even started a CS or software engineering course, and that a teaching resource is fairly limited in real-life.

推荐答案

对我来说真正的开明者是重构:改进现有代码的设计

A real eye-opener to me was Refactoring: Improving the Design of Existing Code:


b设计师可以采取一个坏的设计和
返工到设计良好,健壮的
代码。在这本书中,Martin Fowler
向您展示了通常可以找到
重构的机会,
以及如何将糟糕的
设计改造成一个好的机会。

With proper training a skilled system designer can take a bad design and rework it into well-designed, robust code. In this book, Martin Fowler shows you where opportunities for refactoring typically can be found, and how to go about reworking a bad design into a good one.

它帮助我有效地和系统地重构代码。它也帮助我很多与其他开发人员讨论,当他们的圣代码必须更改...

It helped me to efficiently and systematically refactor code. Also it helped me a lot in discussions with other developers, when their holy code has to be changed ...

这篇关于重构代码:什么时候做什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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