I can't seem to find a good and accessible explanation of "Leader/Follower" pattern. All explanations either simply refer to it in the context of some problem, or are completely meaningless.
Can anyone explain to the the mechanics of how this pattern works, and why and how it improves performance over more traditional asynchronous IO mo...
Hi all
Working my way through the Head First Design Patterns book.
I believe I understand the simple factory and the factory method, but I'm having trouble seeing what advantages factory method brings over simple factory.
If an object A uses a simple factory to create its B objects, then clients can create it like this:
A a = new A(n...
What are the best examples of Singleton Pattern in Java API? Is Runtime class a singleton?
...
Hello!
Currently I'm reading some documentation written by another and I'm confused. A lot of it is about the multi-threading synchronization that has been implemented in the project for which this documentation is written.
In this project this programmer implemented a few classes that control the critical sections that are being used...
There are dozens of network protocols and file formats (WAV, TCP, BMP, etc. etc.)
Is there a solution available to create an abstraction layer between the implementation of a protocol and the code that uses the resulting data?
Take a WAV file. A software component could contain logic to identify chucks and parse them into classes. The ...
In an application I'm creating, I've got two components that I want the user to be able to pause/resume. I'm wondering what standard patterns might exist to support pausing and resuming, if any? Both components do a lot of network I/O. It seems like, at a high level, I have to persist the current queue of work that each component has ...
I was kind of curious as to how replay might be implemented in a game.
Initially, I thought that there would be just a command list of every player/ai action that was taken in the game, and it then 're-plays' the game and lets the engine render as usual. However, I have looked at replays in FPS/RTS games, and upon careful inspection ev...
I have a factory class that serves out a bunch of properties.
Now, the properties might come either from a database or from a properties file.
This is what I've come up with.
public class Factory {
private static final INSTANCE = new Factory(source);
private Factory(DbSource source) {
// read from db, save properties...
Hi,
I am wondering what should be the step by step analyzing approach to a well defined problem for figuring out the possible Design Patterns that can fit in the solution.
Any guidance you can recommend?
thanks
...
I am working on an ASP.Net web application in which several WCF services are being used. At client level, I am creating channel factory mechanism to invoke service operations. Right now, I have created an assembly having classes used for channel factory creation code for every service. As per my assumption this is some sort of
facade pat...
interface IFoo
{
int MyReadOnlyVar { get; }
}
class Foo : IFoo
{
int MyReadOnlyVar { get; set; }
}
public IFoo GetFoo()
{
return new Foo { MyReadOnlyVar = 1 };
}
Is the above an acceptable way of implementing a readonly/immutable object? The immutability of IFoo can be broken with a temporary cast to Foo.
In general (...
C# project, but it could be applied to any OO languages.
3 interfaces interacting:
public interface IPublicData {}
public /* internal */ interface IInternalDataProducer { string GetData(); }
public interface IPublicWorker {
IPublicData DoWork();
IInternalDataProducer GetInternalProducer();
}
public class Engine {
Engine(I...
I was asked this question recently during my job interview, and I couldn't answer it. So, what is the most used pattern in java.io and how is it used? What are other patterns used in common java libraries?
...
Hi.
I am writing a project on Google App Engine, within it I have a number of abstract classes that I hope I will be able to use in my future projects, and a number of concrete classes inheriting from them.
Among other abstract classes I have an abstract servlet that does user management, and I hava an abstract user. The AbstractUser h...
Hi,
I am developing an application which manage various business objects.
These business objects (BO) are displayed in a web page (a sort of Objects Explorer).
Some actions could be executed on these BO, depending of the BO "type":
Some could be copied
Some could be deleted
Some could be executed
...
The final goal will be to disp...
Hi all,
This question is a bit rhetorical. At some point i got a feeling that ASP.NET MVC is not that authentic implementation of MVC pattern. Or i didn't understood it.
Consider following domain: electric bulb, switch and motion detector. They are connected together and when you enter the room motion detector switches on the bulb. If ...
Hi there,
I code Java/Swing based UI. My dialogs are quite complex and there are many rules for screen dynamics: when to enable/disable buttons, when to allow to edit some fields, etc.
In general there are widgets and there are some rules to set them in some state.
I am wondering if there are any nice patterns, ideas how to resolve suc...
Hi all,
I am currently in the process of designing/implementing a repository pattern in a .NET application. After many days of research I feel I am getting close but there really is so many ideas and opinions out there I was hoping to get some peoples thoughts on any design considerations they may have had if you've implemented one your...
What is the difference between NVI ( Non-Virtual Interface ) and the Template Method patterns?
They seem very similar and I've read both that they're basically the same and that they're subtly different with Template being somehow more general.
...
I am implementing a Rails application that needs to aggregate search results from N independent heterogeneous databases. An example use case would be:
User queries "xpto"
The query is submitted to all the databases registered on the system
The results are transformed and combined in a predefined format
User gets the results
The appli...