anti-patterns

If the constant interface anti-pattern is such a crime, why does Swing do it?

眉间皱痕 提交于 2019-12-05 04:24:55
I was making a swing application, and realized I had a handful of classes that needed access to the same set of constants. I couldnt bring myself to declare one the primary holder of them and place them all in there and have the others reference it; I thought, hey, I'll just have them all inherit from some common place, but Java doesnt do multiple inheritence, BUT I can put infinity interfaces on things. So the idea came to me to dump them all into an interface (it's true, it just naturally occurred to me without doing any research). I later learned that this is heresy. "In fact, it's such a

TFS — Sustainability of Cascading Branches

烈酒焚心 提交于 2019-12-05 02:19:15
问题 Branching guidance usually describes an immortal "Main" branch, with features branched from Main, and merged back to Main, and Releases branched from Main, with further branches of a Release as necessary for Service Packs, RTMs, etc. The guidance regarding Main is often simplified to "no trash in Main." I'm working with a group that releases regularly (as often as monthly) and serially. To them it seems unnecessary to ever return work to the Main branch. They use TFS 2010--diagramatically

Is replacing a list element an anti-pattern?

南楼画角 提交于 2019-12-05 01:51:46
I have a module that works on paths represented as lists. Most of the functions do typical recursive list processing, but now I need one that sometimes mutates a path. So, I wrote this replace function: module List = let replace f sub xs = let rec finish acc = function | [] -> acc | x::xs -> finish (x::acc) xs let rec search acc = function | [] -> None | x::xs -> if f x then Some(finish ((sub x)::xs) acc) else search (x::acc) xs search [] xs which works like this: let xs = List.init 10 id let res = List.replace ((=) 5) (fun _ -> -1) xs //Some [0; 1; 2; 3; 4; -1; 6; 7; 8; 9] Usually, when I

Why is a generic repository considered an anti-pattern? [closed]

我的未来我决定 提交于 2019-12-05 01:32:12
it seems to me that a lot of specialised repository classes share similar characteristics, and it would make sense to have these classes implement an interface that outlines these characteristics, creating a generic repository to illustrate my point, say we have this code public class IEntity { public int Id; } public interface IRepository<T> where T: IEntity { IEnumerable<T> List { get; } void Add(T entity); void Delete(T entity); void Update(T entity); T FindById(int Id); } [Table("Author")] public partial class Author : IEntity { public int Id { get; set; } [Required] public string

What are some specific legitimate uses for singletons? [duplicate]

喜你入骨 提交于 2019-12-04 18:42:08
问题 This question already has answers here : Closed 9 years ago . Possible Duplicate: On Design Patterns: When to use the Singleton? This question is not about whether or not singletons are "considered harmful" in general. I just want to know, from your experience, what are some SPECIFIC SITUATIONS in which singletons seem to work well. EDIT: Please, if you want to discuss the appropriateness and/or evilness of singletons in general , there are aleady exising questions: 137975, 11831 Oops! I've

What are common antipatterns of using Git? [closed]

倾然丶 夕夏残阳落幕 提交于 2019-12-04 07:51:37
问题 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 . As a Git newbie, I realized that I have been using it as if it were Subversion. e.g. always working on master, not committing locally before pulling changes etc. This often results in avoidable manual merge situations. What are other common antipatterns of using Git? 回答1: Big

Creating custom events - Object Sender or Typed Sender?

风格不统一 提交于 2019-12-04 03:53:52
I searched through the archives and I found lots of questions about what sender is and why you should use the pattern but I didn't see anything about a custom event and the type if sender. Say I am creating a custom class called Subscription and it implements ISubscription and I have some event args called SubscriptionEventArgs. If Subscription had an event called Changed what is wrong about the event signature Changed(ISubscription sender, SubscriptionEventArgs e)? A little code to help drive the question: public class SubscriptionEventArgs : EventArgs { // guts of event args go here } public

`return $this;` design pattern or anti-pattern?

蓝咒 提交于 2019-12-04 02:52:47
问题 I've seen many times Zend Framework using return $this; pattern style - and from my point of view: Pro: seems its quite not bad pattern style for chaining many actions on the same object and making your code shorter. Con: code looks a bit weird when you see that object returns itself in the method, which does something else (e.g. setter for some property) Is it really good pattern practice or maybe an anti- pattern practice? EDIT: well it was a little too much from my side to call it "pattern

TFS — Sustainability of Cascading Branches

℡╲_俬逩灬. 提交于 2019-12-03 20:34:09
Branching guidance usually describes an immortal "Main" branch, with features branched from Main, and merged back to Main, and Releases branched from Main, with further branches of a Release as necessary for Service Packs, RTMs, etc. The guidance regarding Main is often simplified to "no trash in Main." I'm working with a group that releases regularly (as often as monthly) and serially. To them it seems unnecessary to ever return work to the Main branch. They use TFS 2010--diagramatically their branching structure looks like this: Daily builds on a branch are made; eventually the branch goes

Why the Service Locator is a Anti-Pattern in the following example?

▼魔方 西西 提交于 2019-12-03 16:35:39
I have a MVC application with a Domain Model well defined, with entities, repositories and a service layer. To avoid having to instantiate my service classes inside my controllers, and thus, mess my controllers with logic that does not suit they, I created a helper that acts as a sort of Service Locator , but after reading a bit, I realized that many devs: http://blog.tfnico.com/2011/04/dreaded-service-locator-pattern.html http://blog.ploeh.dk/2010/02/03/ServiceLocatorIsAnAntiPattern.aspx http://underground.infovark.com/2010/06/18/the-service-locator-pattern-is-the-new-global-variable/ http:/