There are claims that OOP design patterns are irrelevant in functional languages. Are there code demos how each pattern can be implemented in Haskell? In particular, complete demo would also have to show how to represent objects, OO polymorphism etc.
121896
Since I started learning  and  last year, I've read a huge number of articles which insist that design patterns (especially in Java) are workarounds for the missing features in imperative languages. One article I found :     Most people I've met have read     by the Gang of   Four (GoF). Any self respecting programmer   will tell you that the book is   language agnostic and the patterns   apply to software engineering in   general, regardless of which language   you use. This is a noble claim.   Unfortunately it is far removed from   the truth.      Functional languages are extremely   expressive. In a functional language   one does not need design patterns   because the language is likely so high   level, you end up programming in   concepts that eliminate design   patterns all together.   The main features of functional programming (FP) include functions as first-class values, currying, immutable values, etc. It doesn't seem obvious to me that OO design patterns are approximating any of those features.  Additionally, in functional languages which support OOP (such as F# and OCaml), it seems obvious to me that programmers using these languages would use the same design patterns found available to every other OOP language. In fact, right now I use F# and OCaml every day, and there are no striking differences between the patterns I use in these languages vs. the patterns I use when I write in Java.  Is there any truth to the claim that functional programming eliminates the need for OOP design patterns? If so, could you post or link to an example of a typical OOP design pattern and its functional equivalent?
79837
How does one draw the "snake" arrow for the connecting homomorphism when using the ?  I'd also be interested in drawing similar arrows act as "carriage returns" when considering a long exact sequence of cohomology.  I'm sorry if this is a little vague. I'm hoping that someone who's already done this might be willing to share a template. I'd prefer things in xy-pic, but would also be interested to see other ways it can be done.
67360
Edit:    From another question I provided an answer that has links to a lot of questions/answers about singletons:   So I have read the thread  And the argument still rages.  I see Singletons as a Design Pattern (good and bad). The problem with Singleton is not the Pattern but rather the users (sorry everybody). Everybody and their father thinks they can implement one correctly (and from the many interviews I have done, most people can't). Also because everybody thinks they can implement a correct Singleton they abuse the Pattern and use it in situations that are not appropriate (replacing global variables with Singletons!).  So the main questions that need to be answered are:   When should you use a Singleton How do you implement a Singleton correctly   My hope for this article is that we can collect together in a single place (rather than having to google and search multiple sites) an authoritative source of when (and then how) to use a Singleton correctly. Also appropriate would be a list of Anti-Usages and common bad implementations explaining why they fail to work and for good implementations their weaknesses.  So get the ball rolling: I will hold my hand up and say this is what I use but probably has problems. I like "Scott Myers" handling of the subject in his books "Effective C++"     Good Situations to use Singletons (not many):         Logging frameworks   Thread recycling pools      /*  * C++ Singleton  * Limitation: Single Threaded Design  * See: http://www.aristeia.com/Papers/DDJ_Jul_Aug_2004_revised.pdf  *      For problems associated with locking in multi threaded applications  *  * Limitation:  * If you use this Singleton (A) within a destructor of another Singleton (B)  * This Singleton (A) must be fully constructed before the constructor of (B)  * is called.  */ class MySingleton {     private:         // Private Constructor         MySingleton();         // Stop the compiler generating methods of copy the object         MySingleton(MySingleton const&amp; copy);            // Not Implemented         MySingleton&amp; operator=(MySingleton const&amp; copy); // Not Implemented      public:         static MySingleton&amp; getInstance()         {             // The only instance             // Guaranteed to be lazy initialized             // Guaranteed that it will be destroyed correctly             static MySingleton instance;             return instance;         } };   OK. Lets get some criticism and other implementations together. :-)
2289
Does anyone know of any resources that talk about best practices or design patterns for shell scripts (sh, bash etc.)?
33911
I have been reading through the  and was curious about the  declaration. I personally have never used it, however I am interested in exploring the language.   What is a good example of using friend?    Reading the FAQ a bit longer I like the idea of the &lt;&lt; &gt;&gt; operator overloading and adding as a friend of those classes. However I am not sure how this doesn't break encapsulation. When can these exceptions stay within the strictness that is OOP?
3035
I have a solid understanding of most OOP theory but the one thing that confuses me a lot is virtual destructors. I thought that the destructor always gets called no matter what and for every object in the chain. When are you meant to make them virtual and why?
89366
Lately I've gotten a friend of mine interested in mathematics. He has no college-level education to speak of, but is well employed as a software engineer. So I feel he's competent to learn this stuff on his own.  He asked me recently if there was a 'mathematical' version of .  The point being, if there was an "introduction to proofs" book which took a more hand-holding approach. He's also expressed fondness for the .  However, metamath's proofs are obviously a bit too low level to learn anything serious.  At one point in our conversation, I mentioned the dependently typed programming language , but I felt it's not quite as helpful until he at least gets some experience with  (for which the target audience of Agda is Haskell programmers, hence the similarity in syntax).  Anyone have any good suggestions on a book?
48644
What Delphi coding standards document(s) do you follow?  Our company is looking at putting some better coding standards in place, to improve our code’s readability, reviewability, and maintainability.  We’ve come across CodeGear’s “Object Pascal Style Guide”, but it hasn’t been touched in quite a while and I imagine a number of people have made some local improvements or additions.  I’ve come across some published variations and other documents, which I will list, below.  NB: I do not want to start a style war.  I just want to know what standards you follow, and why.  Thanks.   UPDATE:  Well, the "JCL Delphi Language Style Guide" seems to be the clear winner!  Thanks!
5812
Why does the  exist in modern languages such as C# and Java? Is it purely a self documenting code feature, or does it serve any actual purpose?  For instance the following example:  Class1 obj = new Class1();  Class1 foo() {     return new Class1(); }   Is as easy to read as the more Pythonesque way of writing it:  Class1 obj = Class1();  Class1 foo() {     return Class1(); }   EDIT:  hit the nail on the head with the clarification of the question: Why did they choose this syntax?
121228
My question if it possible for us to have, for example, a monoid(any algebraic structure really) with a class as the collection of the elements, instead of a set.  An example would be the class of sets and set union as addition. Clearly, it is closed under the operation, is associative and it has an identity element, so it is a monoid. Is it possible to say so?
43
I am working on an application and one design approach involves extremely heavy use of the instanceof operator. While I know that OO design generally tries to avoid using instanceof, that is a different story and this question is purely related to performance. I was wondering if there is any performance impact? Is is just as fast as ==?  For example, I have a base class with 10 subclasses. In a single function that takes the base class, I do checks for if the class is an instance of the subclass and carry out some routine.   One of the other ways I thought of solving it was to use a "type id" integer primitive instead, and use a bitmask to represent categories of the subclasses, and then just do a bit mask comparison of the subclasses "type id" to a constant mask representing the category.  Is instanceof somehow optimized by the JVM to be faster than that? I want to stick to Java but the performance of the app is critical. It would be cool if someone that has been down this road before could offer some advice. Am I nitpicking too much or focusing on the wrong thing to optimize?
78567
Can someone please explain to me how to deal with equivalence relations on classes instead of sets? Is there some sort of generalisation of relations?  Thank you
10971
Since multiple inheritance is bad (it makes the source more complicated) C# does not provide such a pattern directly. But sometimes it would be helpful to have this ability. For instance I'm able to implement the missing multiple inheritance pattern using interfaces and three classes like that: public interface IFirst { void FirstMethod(); } public interface ISecond { void SecondMethod(); }  public class First:IFirst  {      public void FirstMethod() { Console.WriteLine(&quot;First&quot;); }  }  public class Second:ISecond  {      public void SecondMethod() { Console.WriteLine(&quot;Second&quot;); }  }  public class FirstAndSecond: IFirst, ISecond {     First first = new First();     Second second = new Second();     public void FirstMethod() { first.FirstMethod(); }     public void SecondMethod() { second.SecondMethod(); } }  Every time I add a method to one of the interfaces I need to change the class FirstAndSecond as well. Is there a way to inject multiple existing classes into one new class like it is possible in C++? Maybe there is a solution using some kind of code generation? Or it may look like this (imaginary c# syntax): public class FirstAndSecond: IFirst from First, ISecond from Second { }  So that there won't be a need to update the class FirstAndSecond when I modify one of the interfaces.  EDIT Maybe it would be better to consider a practical example: You have an existing class (e.g. a text based TCP client based on ITextTcpClient) which you do already use at different locations inside your project.  Now you feel the need to create a component of your class to be easy accessible for windows forms developers. As far as I know you currently have two ways to do this:  Write a new class that is inherited from components and implements the interface of the TextTcpClient class using an instance of the class itself as shown with FirstAndSecond.  Write a new class that inherits from TextTcpClient and somehow implements IComponent (haven't actually tried this yet).   In both cases you need to do work per method and not per class. Since you know that we will need all the methods of TextTcpClient and Component it would be the easiest solution to just combine those two into one class. To avoid conflicts this may be done by code generation where the result could be altered afterwards but typing this by hand is a pure pain in the ass.
13839
I keep hearing a lot about functors in C++. Can someone give me an overview as to what they are and in what cases they would be useful?
102822
I know about , but in my case I need something that implements List, and not Set. So is there an implementation out there, in the API or elsewhere?  It shouldn't be hard to implement myself, but I figured why not ask people here first?
70733
What are the advantages and limitations of dynamic type languages compared to static type languages?  See also:  (a far more argumentative thread...)
42083
What are the C++ coding and file organization guidelines you suggest for people who have to deal with lots of interdependent classes spread over several source and header files?  I have this situation in my project and solving class definition related errors crossing over several header files has become quite a headache.