anti-patterns

Are subversion externals an antipattern?

血红的双手。 提交于 2019-11-26 23:21:07
Subversion lets you embed working copies of other repositories using externals , allowing easy version control of third-party library software in your project. While these seem ideal for the reuse of libraries and version control of vendor software , they aren't without their critics : Please don't use Subversion externals (or similar in other tools), they are an anti-pattern and, therefore, unnecessary Are there hidden risks in using externals? Please explain why they would they be considered an antipattern. Rob Williams I am the author of the quote in the question, which came from a previous

How do you refactor a God class?

家住魔仙堡 提交于 2019-11-26 20:39:24
问题 Does anyone know the best way to refactor a God-object? Its not as simple as breaking it into a number of smaller classes, because there is a high method coupling. If I pull out one method, i usually end up pulling every other method out. 回答1: It's like Jenga. You will need patience and a steady hand, otherwise you have to recreate everything from scratch. Which is not bad, per se - sometimes one needs to throw away code. Other advice: Think before pulling out methods: on what data does this

How to prevent the arrowhead anti-pattern

烈酒焚心 提交于 2019-11-26 19:55:34
问题 I'm a bit confused about how to best refactor my code into something more readable. Consider this piece of code: var foo = getfoo(); if(foo!=null) { var bar = getbar(foo); if(bar!=null) { var moo = getmoo(bar); if(moo!=null) { var cow = getcow(moo); ... } } } return; As you can see, lots of nested if blocks, needed because each nested if is dependent on the previous values. Now I was wondering how to make my code a bit cleaner in this regard. Some options I have thought of myself would be to:

how to block users from closing a window in javascript?

拜拜、爱过 提交于 2019-11-26 18:40:43
Is it possible to block users from closing the window using the exit button [X]? I am actually providing a close button in the page for the users to close the window.Basically what im trying to do is to force the users to fill the form and submit it.I dont want them to close the window till they have submitted it. guys i really appreciate your comments,im not thinking of hosting on any commercial website.its an internal thing,we are actually getting all the staff to participate in this survey we have designed.... i know its not the right way but i was wondering if there was a solution to the

Why is double-checked locking broken in Java?

一个人想着一个人 提交于 2019-11-26 16:43:58
问题 This question relates to behaviour of old Java versions and old implementations of the double checked locking algorithm Newer implementations use volatile and rely on slightly changed volatile semantics, so they are not broken. It's stated that fields assignment is always atomic except for fields of long or double. But, when I read an explaination of why double-check locking is broken, it's said that the problem is in assignment operation: // Broken multithreaded version // "Double-Checked

Is global constants an anti-pattern?

China☆狼群 提交于 2019-11-26 16:17:56
问题 I've always thought having a class just for the sake of holding constants is a bad design. But recently, I've tried googling for it and found only that having an interface as a constants is bad an anti-pattern - no mention of using a class of constants. I'm of the opinion that since a class of constants is really not much different from global variables, that's why I'm against it and tend to refactor away such classes. It creates a class of data that has absolutely no context. Those constants

Avoiding parallel inheritance hierarchies

て烟熏妆下的殇ゞ 提交于 2019-11-26 15:50:12
问题 I have two parallel inheritance chains: Vehicle <- Car <- Truck <- etc. VehicleXMLFormatter <- CarXMLFormatter <- TruckXMLFormatter <- etc. My experience has been that parallel inheritance hierarchies can become a maintenance headache as they grow. i.e. NOT adding toXML(), toSoap(), toYAML() methods to my principal classes. How do I avoid a parallel inheritance hierarchy without breaking the concept of separation of concerns? 回答1: I am thinking of using the Visitor pattern. public class Car :

Design patterns to avoid [closed]

跟風遠走 提交于 2019-11-26 14:58:22
问题 A lot of people seem to agree, that the Singleton pattern has a number of drawbacks and some even suggest avoiding the pattern entirely. There's an excellent discussion here. Please direct any comments about the Singleton pattern to that question. My question : Are there other design patterns, that should be avoided or used with great care? 回答1: Patterns are complex All design patterns should be used with care. In my opinion you should refactor towards patterns when there is a valid reason to

What is the most EVIL code you have ever seen in a production enterprise environment? [closed]

孤人 提交于 2019-11-26 14:57:29
问题 What is the most evil or dangerous code fragment you have ever seen in a production environment at a company? I've never encountered production code that I would consider to be deliberately malicious and evil, so I'm quite curious to see what others have found. The most dangerous code I have ever seen was a stored procedure two linked-servers away from our core production database server. The stored procedure accepted any NVARCHAR(8000) parameter and executed the parameter on the target

Why are data transfer objects (DTOs) an anti-pattern?

廉价感情. 提交于 2019-11-26 14:06:01
I've recently overheard people saying that data transfer objects (DTOs) are an anti-pattern . Why? What are the alternatives? KLE Some projects have all data twice . Once as domain objects, and once as data transfer objects. This duplication has a huge cost , so the architecture needs to get a huge benefit from this separation to be worth it. Gabe Moothart DTOs are not an anti-pattern. When you're sending some data across the wire (say, to an web page in an Ajax call), you want to be sure that you conserve bandwidth by only sending data that the destination will use. Also, often it is