This question is motivated by something I've lately started to see a bit too often, the if..else if..else structure. While it's simple and has its uses, something about it keeps telling me again and again that it could be substituted with something that's more fine-grained, elegant and just generally easier to keep up-to-date.
To be as ...
What real (i.e. practical) difference exist between a static class and a singleton pattern?
Both can be invoked without instantiation, both provide only with one "instance" and neither of them is threadsafe. Is there any other difference?
...
In Apple's documentation for their example of a Singleton, and I do understand there's more than one way to skin a cat -- but why do they bother ensuring the instance is registered as static?
Take from: http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaFundamentals/CocoaObjects/chapter_3_section_10.html
I'm referring to:
...
Based on the code I've found, it seems that the Visitor is required to known the structure of the visited objects and call on the needed children. This seems a bit clunky in some cases where the visitor would want to continue to work even if the visited classes are modified.
I guess the real question is: Is their a pattern where the enu...
I have a database table with a list of products (clothing). The products belong to categories and are from different stores.
Sample categories: tops, bottoms, shoes
Sample stores: gap.com, macys.com, target.com
My customers can request to filter products in the following ways:
all products (no filter)
by category
by store
by categor...
My role at my company is the sole developer, and my experience is limited (I got the job mostly because I'm probably the only person who will do it for the money they're willing to pay - but I digress) compared to the averge developer but more extensive than the average recent grad.
As such I'm looking for some good books to fill in the...
Is there any good way to design a web page for massive data entry? Datagrids seem to be the best way to handle this type of data entry and I think a client application like Access or SQLite+Frontend would be better suited for this than the web.
Links to sites with a page for data entry would be greatly appreciated.
...
In his definition of OOP, Alan Kay points out he supports "the extreme late-binding of all things". Does his interest in late-binding share the same motivation as people's interest in IoC?
In particular, would it be correct to say that both are motivated by the concept "specify as little as possible, and leave implementation details to ...
I have a Subject which offers Subscribe(Observer*) and Unsubscribe(Observer*) to clients. Subject runs in its own thread (from which it calls Notify() on subscribed Observers) and a mutex protects its internal list of Observers.
I would like client code - which I don't control - to be able to safely delete an Observer after it is unsub...
I am attempting to conceptualize the Singleton design pattern (qua Java) in OCaml and have seen ever instance allude to functors or modules, neither of which I am using in a proof of concept of GoF's work. Basically, I would like to recreate the following functionality using OCaml:
public class Singleton
{
private static Singleton Uniq...
I need to access a Web-svc, run a bunch of queries and save the data to a store as part of an analysis. On top of this, there is a web-site that will query the datastore and show this data.
We have features like this getiing added every month. How can I reduce the amount of boilerplate code that get's written.
Add web svc ref
Wrap met...
I'm in the process of writing a BSD licensed mini-ORM targeted at embedded databases (with support for ese, sqlite and sqlce out of the box)
After working lots with Rails in the last year I have been thinking of implementing an Active Record pattern in C#.
I have come up with some demo code and was wondering if the interface design i...
I have an ABC with several derived classes. To create these derived classes I use the factory pattern:
.h file:
class derivedFactory
{
public:
base* createInstance();
};
.cpp file:
base* derivedFactory::createInstance()
{
new derived();
}
Is there any advantage to this over just having a free function:
.h file:
base* de...
I currently design all of my websites with a file for each page, then include common elements like the header, footer and so on. However, I've noticed that many frameworks and CMSs use the Front Controller pattern.
What are the advantages and disadvantages of using a Front Controller? Is the pattern simply used in frameworks and CMSs be...
Hi,
We are developing applications for use within AutoCAD.
Basically we create a Class Library Project, and load the .dll in autoCAD with a command (NETLOAD).
As so, we can use commands, "palettes", user controls, forms etc...
AutoDesk provides an API through some dll's, running in their program directory.
When referencing these dll'...
This is my first question so please be patient :)
Background:
I'm implementing an observer pattern and I have about 20 classes where I would eventually implement it. In order to use the subject and observer I need to:
1: initialize observer classes
2: create delegates
3: add delegates to the events
This is probably very simple, but I d...
Let's imagine I have a collection of nodes that I use for my Renderer class later on. Then I have a Visitor class that can visit node or whole collection. It's simple because my collection of nodes it's simply a wrapper to the std::list with few extra methods.
The problem is I'd like to have a tree like structure for nodes(instead of si...
Working with Java and Java frameworks I have started shuddering when I encounter Abstract Factory patterns. In my opinion this is the most abused design pattern. Not all frameworks abuse it but there are many. It doesn't fit all models and when almost 100% of the time you are going to be doing the same thing why abstract it?
Which desi...
Say for example you have a base abstract class
public abstract Foo
{
IFlyable _fly;
ISwimmable _swim;
void performSwim()
{
_swim.swim();
}
void performFly()
{
_fly.fly();
}
}
And have behaviors/algorithm that you will have in your system
interface IFlyable { void fly(); }
interface ISwimmable { void swim(); }
in...
Are mixins considered a design pattern? Structural?
...