I have a data structure that represents C# code like this:
class Namespace:
string Name;
List<Class> Classes;
class Class:
string Name;
List<Property> Properties;
List<Method> Methods;
List<Method> Constructors;
List<Field> Fields;
List<Class> InnerClasses;
Class Parent;
List<Interface> Implement...
I often read about dependency injection and I did research on google and I understand in theory what it can do and how it works, but I'd like to see an actual code base using it (Java/guice would be preferred).
Can anyone point me to an open source project, where I can see, how it's really used? I think browsing the code and seeing the...
I'm currently building a prototype AIR application for work. It allows our clients to download and work with their data and then synchronise with the server at some later time. Pretty standard stuff.
I'm an experienced web developer and so I have been fairly successful at getting this app into a reasonable state for demonstration, but...
Ideas on how to develop software that is capable of adapting to meet changing business requirements? Any patterns, architectures, etc. Possibly some anecdotal examples would be great. This is more of a survey than a concrete questions. Thanks
...
I recently discovered metaclasses in python.
Basically a metaclass in python is a class that creates a class. There are many useful reasons why you would want to do this - any kind of class initialisation for example. Registering classes on factories, complex validation of attributes, altering how inheritance works, etc. All of this be...
Is there a difference between the DAO pattern and the Data Mapper pattern? Is DAO just one of doing Data Mapper?
...
Today I got my book "Head First Design Patterns" in the mail. Pretty interesting stuff so far, however I do have a question about it's contents.
I have no Java/C# background nor do I wish to jump into those languages right now (I'm trying to focus on C++ first). In the book is said that java does not have an implementation for interface...
I want to know whether the below is an acceptable use of the visitor pattern. I feel a little uncomfortable returning from an Accept() or Visit() call - is this an appropriate usage of this pattern and if not, why not?
Note: Apologies for the long code sample, seems necessary to get across what I'm doing as visitor always seems to be a ...
The WindowsBase DLL defines the IWeakEventListener event with summary:
Provides event listening support for classes that expect to receive events through the WeakEvent pattern and a System.Windows.WeakEventManager.
This vague description doesn't describe what the 'WeakEvent pattern' actually is.
So, what is this pattern, why is it...
I am currently trying to refactor my codebase for an app I am making, I have an existing setup but it is not even close to being flexible and everything is dependent on everything else (aggregated to each class for example).
So, after reading PHP Design Patterns and countless articles on patterns and how they relate to scalable applicat...
I'm writing a Swing application, and further to my previous question, have settled on using the Model-View-Presenter pattern to separate the user interface from the business logic.
When my application starts up, it executes the following code:
Model model = new BasicModel();
Presenter presenter = new Presenter(model);
View view = new S...
I'm looking into educating our team on concurrency. What are the most common pitfalls developers fall into surrounding concurrency. For instance, in .Net the keyword static opens the door to a lot of concurrency issues.
Are there other design patterns that are not thread safe?
Update
There are so many great answers here it is difficul...
I've been looking at strategy pattern implementation examples and it seems to me like they are very similar to c# delegates. The only difference I see is that strategy pattern implementations don't need to explicitly declare a delegate.
But other than that, they both seem to point to functions that need a specific signature and they ca...
I'm using the following pattern in C#:
IList<foo> x = y.Select(a => new foo
{
b = Calc1(),
c = Calc2()
}).ToList();
foreach(foo f in x)
{
f.d = b / c;
}
What I would like to do though is:
IList<foo> x = y.Select(a => new foo
{
b = Calc1(),
c = Calc2()
d = b / c;
}).ToList();
So the question is: How can you ...
How can I do this in PHP
$myDBClass->users()->limit(5);//output you limited users to 5
$myDBClass->comments()->limit(3);//output you limited comments to 3
what I meant is nested methods or nested class (I don't know!)
so when I call the limit method as a child of users it will know that I am calling it from "users" method -or class- ...
Most of the examples quoted for usage of Dependency Injection, we can solve using the factory pattern as well. Looks like when it comes to usage/design the difference between dependency injection and factory is blurred or thin.
Once someone told me that its how you use it that makes a difference!
I once used StructureMap a DI containe...
Given a class that is semantically supposed to be an object of a certain type, but also has multiple operations for operating on objects of its own type, what is the best way(pattern?) of organizing the class in this type of scenario? I find this to be a common occurrence when a developer creates objects but is thinking with a procedural...
I'm planning to start the development of human motion recognition software which will monitor accelerations and recognize motion patterns (run, walk, jump...).
I have started collecting books about biomechanics and it would be good to get some good book about patterncomparison and detection.
Where can I get started with some reading ma...
In Python, I've seen the recommendation to use holding or wrapping to extend the functionality of an object or class, rather than inheritance. In particular, I think that Alex Martelli spoke about this in his Python Design Patterns talk. I've seen this pattern used in libraries for dependency injection, like pycontainer.
One problem t...
Is the provider pattern an implementation of IOC? If not, why not?
(reading through martin fowlers article on ioc)
...