我找到了一篇关于论坛:
If you have a type with "Manager" in the name, it s a candidate for refactoring.
一个答案:
我知道这被认为是一种代码“气味”
那么…为什么?这篇论文正确吗?
外面有很多经理。例如,Ogre3d经常使用它们,而这个引擎确实有一个干净的架构。
我找到了一篇关于论坛:
If you have a type with "Manager" in the name, it s a candidate for refactoring.
一个答案:
我知道这被认为是一种代码“气味”
那么…为什么?这篇论文正确吗?
外面有很多经理。例如,Ogre3d经常使用它们,而这个引擎确实有一个干净的架构。
Ogre3d经常使用它们,而且这个引擎确实有一个干净的架构。
它适用于除“经理”类之外的任何地方。查看DefaultSceneManager就是一个例子。这些都是非常庞大的、噩梦般的类。”
问题是,大多数名称中包含“Manager”的类通常会违反单一责任原则。这并不总是正确的,因为一个类可能有管理另一个方面的单一责任,但通常情况下,这些方面的名称会有所不同。当一个类被命名为“Manager”时,通常是因为它是监督一切的类,并且确实应该根据其个人责任划分为不同的部分。
经理在做很多事情时是一种气味。如果我们仔细调查经理在做什么,那么你可能会发现一项服务所做的很多事情。拆分、分离它们并提取到不同的服务中是有意义的。
您还可以发现一些SRP类的名称后缀为Manager,如ConnectionPoolManager。如果它说到做到,这是有道理的。
In C#, I know that I can overload the constructor for a class by specifying it in the body of the class: public class MyClass() { public MyClass(String s) { ... } } This overrides the default ...
I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?
While designing ORM, what is the best approach to represent the relationship, performance-wise? I mean, out of the following two, which approach is best considering performance? class Employee { ...
I am in the middle of solving a problem where I think it s best suited for a decorator and a state pattern. The high level setting is something like a sandwich maker and dispenser, where I have a set ...
Is there a standardized way to store classes in JSON, and then converting them back into classes again from a string? For example, I might have an array of objects of type Questions. I d like to ...
I m a little confused about what is going on in Perl constructors. I found these two examples perldoc perlbot. package Foo; #In Perl, the constructor is just a subroutine called new. sub new { #I ...
I was wondering what is the best practice re. passing (another class) amongst two instances of the same class (lets call this Primary ). So, essentially in the constructor for the first, i can ...
A Google search yields a number of results - but which ones are the best? The Perl site appears to contain two - perlboot and perltoot. I m reading these now, but what else is out there? Note: I ve ...