应该使用助手开发新的代码吗? [英] Should Class Helpers be used in developing new code?

查看:172
本文介绍了应该使用助手开发新的代码吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Delphi 8引入了类助手,用于将VCL / RTL映射到.NET对象层次结构。它们允许将注入方法注入到现有类中,而不会覆盖该类或修改原始类。后来的Delphi版本发现了类帮助器的改进,并且被移植到了Win32中。



在帮助中,它说他们不应该被视为一个设计工具,用于开发新代码。



类助手违反传统的OOP,但我不认为这使他们成为坏事。这个警告是否有保证?



应该在开发新代码时使用类助手吗?



开发新代码时是否使用它们?



为什么或为什么不这样?



Per Malcolm的意见:新代码意味着日常应用程序开发,您有一些第三方库,一些现有的代码,然后你正在写的代码。

解决方案

取决于新代码的含义。



他们与您刚刚开发的课程并不真正相关,所以在这种情况下,不,他们可能不应该被使用。但是即使在一个全新的项目中,您仍然可能需要修改一个不能以其他方式更改的现有类(vcl类,第三方类,等等)。在这种情况下,我肯定会说。



他们本身并不邪恶。像大多数其他事情一样,您只需要了解它们如何工作,并在适当的上下文中使用它们。


Delphi 8 introduced Class Helpers for the purposes of mapping the VCL/RTL to the .NET object hierarchy. They allow injecting methods into an existing class without overriding the the class or modifying the original. Later versions of Delphi found class helpers improved and they were ported to Win32.

In the help it says "they should not be viewed as a design tool to be used when developing new code."

Class Helpers violate traditional OOP, but I don't think that makes them a bad thing. Is this warning warranted?

Should class helpers be used when developing new code?

Do you use them when developing new code?

Why or why not?

Per Malcolm's comments: New code means daily application development, where you have some 3rd party libraries, some existing code, and then code you are writing.

解决方案

Depends what you mean by "new code".

They aren't really relevant for classes you are newly developing, so in that case, no, they probably shouldn't be used.

But even in a brand new project, you may still need to modify an existing class that you can't change in other ways (vcl class, third-party class, etc). In this case, sure, I'd say go ahead.

They're not evil in and of themselves. Like most other things, you just need to understand how they work and use them in an appropriate context.

这篇关于应该使用助手开发新的代码吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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