重构代码:当该怎么办? [英] Refactoring Code: When to do what?

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

问题描述

自从我开始使用.NET,我刚刚创建助手类或部分类,以保持位于并包含在自己的小容器等。

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.

我正在寻找了解是使那些代码作为清洁和抛光,因为它可能是可能是最佳做法。

What I'm looking to know is the best practices for making ones code as clean and polished as it possibly could be.

显然,干净的代码是主观的,但我米聊什么时候要用的东西(而不是如何使用它们),如多态,继承,接口,类以及如何更恰当地设计班(使他们更加有用,而不是仅仅说'DatabaseHelper',因为一些人认为这是不好的做法在代码味道维基)。

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:

通过适当的训练熟练的系统
设计者可以采取一个坏设计和
返工成精心设计,稳健的
码。在这本书中,马丁·福勒
展示了在那里的
重构的机会通常可以发现,
和如何去返工坏
设计成一个很好的一个。

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天全站免登陆