anti-patterns

Good techniques for keeping COM classes that implement multiple interfaces manageable

廉价感情. 提交于 2021-02-07 04:24:15
问题 COM objects that implement many interfaces can end up suffering from the god object anti-pattern or end up full of tedious forwarding code: class MyCOMClass , public CUnknown , public IFoo , public IBar , public IPersistStream , public IYetAnotherInterface, , public IAndAnotherInterfaceToo // etc etc etc In the most obvious implementation, the class MyCOMClass ends up implementing all the interfaces internally, becomes very large and coupled to details of implementation of each interface.

Premature refactoring? [closed]

瘦欲@ 提交于 2021-02-06 08:42:07
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 2 years ago . Improve this question We have all heard of premature optimization, but what do you think about premature refactoring? Is there any such thing in your opinion? Here is what I am getting at. First off, reading Martin Fowler's seminal work "Refactoring" quite literally changed

Premature refactoring? [closed]

旧城冷巷雨未停 提交于 2021-02-06 08:41:52
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 2 years ago . Improve this question We have all heard of premature optimization, but what do you think about premature refactoring? Is there any such thing in your opinion? Here is what I am getting at. First off, reading Martin Fowler's seminal work "Refactoring" quite literally changed

What type should Struts ActionForm properties be?

不羁的心 提交于 2020-01-14 08:53:06
问题 I inherited this gigantic legacy Java web app using Struts 1.2.4. I have a specific question regarding ActionForms. Some of them have only String properties (even for numbers), some of them use the seemingly appropriate types (Integer, Date, String, etc). What's the best practice here? Also, it seems that if a property is of type Integer, and the value the user entered is not an integer value, Struts silently swallows this and just doesn't set the property. What's up with this? 回答1: For

Confused over using IOC container, service locator and factory

為{幸葍}努か 提交于 2020-01-02 06:45:30
问题 Suppose I have a BaseForm which depends on an ILogger or IResourceManager or something like that. Currently it resolves the correct implementation of the required service using the service locator which I know is an anti-pattern. Is using the constructor injection the right way to resolve this kind of dependency? Do I have to register my BaseForm (and its' derived types) in the container in order to create instances of them with resolved dependencies? Doesn't that complicate everything? Is it

Why is it “wrong to require rubygems”?

我只是一个虾纸丫 提交于 2020-01-02 01:19:09
问题 According to this post, requiring rubygems is an antipattern. require 'rubygems' The argument seems to boil down to this: When I use your library, deploy your app, or run your tests I may not want to use rubygems. When you require 'rubygems' in your code, you remove my ability to make that decision. I cannot unrequire rubygems, but you can not require it in the first place. But couldn't the same argument be made about any Ruby library that you 'require' when you create and share a library of

What is the worst abuse you've seen of LINQ syntax? [closed]

回眸只為那壹抹淺笑 提交于 2020-01-01 02:48:26
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed last year . On a recent Dot Net Rocks podcast, Jon Skeet mentioned possible abuses of LINQ syntax. What examples have people seen where crazy things are being done with LINQ? 回答1: It has to be a ray-tracer implemented in a single LINQ expression. Clever, beautiful, and scary all at the

Extending singletons in PHP

早过忘川 提交于 2019-12-31 08:06:10
问题 I'm working in a web app framework, and part of it consists of a number of services, all implemented as singletons. They all extend a Service class, where the singleton behaviour is implemented, looking something like this: class Service { protected static $instance; public function Service() { if (isset(self::$instance)) { throw new Exception('Please use Service::getInstance.'); } } public static function &getInstance() { if (empty(self::$instance)) { self::$instance = new self(); } return