design-patterns

c# class design - what can I use instead of "static abstract"?

I want to do the following public abstract class MyAbstractClass { public static abstract int MagicId { get; } public static void DoSomeMagic() { // Need to get the MagicId value defined in the concrete implementation } } public class MyConcreteClass : MyAbstractClass { public static overrid...

How to understand other people's CSS architectures?

I am reasonably good with CSS. However, when working with someone else's CSS, it's difficult for me to see the "bigger picture" in their architecture (but i have no problem when working with a CSS sheet I wrote myself). For example, I have no problems using Firebug to isolate and fix cross browser compatibility issues, or fixing a floa...

What is the best way to implement Singleton Design Pattern in C# with performance constraint?

Hi, Please let me know what the best way to implement Singleton Design Pattern in C# with performance constraint? ...

Name the pattern - Create, Set, Execute, Destroy?

I somewhere heard that the .NET Framework was built around specific pattern, which they tried to uphold as much as possible. var rsa = new RSACryptoServiceProvider(); // Create rsa.ImportParameters(GetParameters()); // Set byte[] encrypted = rsa.Encrypt(data, true); // Execute // Destroyed by garbage-collector Are there any variants o...

pattern to transfer search model to dao

We have a dao as a project (jar file). Clients use its interfaces and factories to operate with database. Alongside with standard CRUD operations, dao allows you to search an entity by some search criteria. What is the best way to represent this criteria? Is transfer object appropriate pattern in this situation? How should client cr...

What Design Pattern is this?

I know that everything we do in programming can be described as design pattern(even abstract method has design pattern called template method) public class Guicer extends AbstractModule { private static Injector injector = Guice.createInjector(new Guicer()); public static void setInjector(Injector injector) { Guicer.in...

Lackadaisical One-to-One between Char and Byte Streams

I expected to have a one-to-one correspondence between the character streams and byte streams in terms of how the classes are organized in their hierarchy. FilterReader and FilterWriter (character streams) correspond back to FilterInputStream and FilterOutputStream (byte stream) classes. However I noticed few changes as - BufferedIn...

Confused about this factory, as it doesn't look like an Abstract Factory nor Factory Method

I'm looking into Guice and I've been reading its documentation recently. Reading the motivation section I don't understand the factories part, why they name it that way. To me that factory is just a wrapper for the implementing class they want it to return after calling getInstance(). public class CreditCardProcessorFactory { privat...

Design pattern suggestion

Following is the problem statement. There are n numbers of match strings, If event A occurs and then in certain period of time event B occurs then I do not raise alarm. but if B do not occurs then i have to raise alarm. There can be multiple chain of events which defines whether to raise alarm or not. ...

Producer/consumer in Grails?

Hi all, I'm trying to implement a Consumer/Producer app in Grails, after several unsuccessful attempts at implementing concurrent threads. Basically I want to store all the events coming from a clients (through separate AJAX calls) in a single queue and then process such a queue in a linear way as soon as new events are added. This look...

How does java implement flyweight pattern for string under the hood?

If you have two instances of a String, and they are equal, in Java they will share the same memory. How is this implemented under the hood? EDIT: My application uses a large number of String objects, many of which are identical. What is the best way to make use of Java String constant pool, as to avoid creating custom flyweight implemen...

Pattern for creating a database schema using JDBC

I have a Java-application that loads data from a legacy file format into an SQLite-Database using JDBC. If the database file specified does not exist, it is supposed to create a new one. Currently the schema for the database is hardcoded in the application. I would much rather have it in a separate file as an SQL-Script, but apparently t...

javascript: execute a bunch of asynchronous method with one callback

I need to execute a bunch of asynchronous methods (client SQLite database), and call only one final callback. Of course, the ugly way is: execAll : function(callBack) { asynch1(function() { asynch2(function() { ... asynchN(function() { callBack(); }...

.Net web architecture literature

Hi, Can somebody please advise a very advanced book on the architecture of the web application development, preferably in .Net I'm interested in patterns and designs, code security and re-usability I have studied a variety of books, but they all seem to be for beginner/intermediate levels. ...

Pattern for managing object state/settings?

I'm having something of a dilemma and would appreciate some input. I have this class, let's call it "Car" where each instance has some individual settings (through properties), like "Color", "HasGearShift" or whatnot (I'm making this up for a simple example). These should be user customizable but there should also be default values. So...

What is it in MVVM that makes it particularly appealing for managed WPF and Silverlight but not native C++?

What is it in WPF and Silverlight that makes MVVM suit them so well? What is it in C++, or what does C++ lack, that makes MVVM and C++ never be mentioned together? ...

Objective-c design advice for use of different data sources, swapping between test and live

I'm in the process of designing an application that is part of a larger piece of work, depending on other people to build an API that the app can make use of to retrieve data. While I was thinking about how to setup this project and design the architecture around it, something occurred to me, and I'm sure many people have been in simila...

Suggestions for opening the Rails toolbox to design a challenge game?

How would you suggest designing a challenge system as part of a food-eating game so that it's automated as possible? All RoR tools, design patterns and logic are at your disposal (e.g., admin consoles, crontab, arch, etc.). Prize goes to whoever can suggest the simplest and most-automated design! Here are the requirements: User has ma...

How to separate model and view with Core Data?

I have a subclass of UIView which draws itself based on data held in a corresponding model class, which is a subclass of NSManagedObject. The problem is, some fields in the data model (e.g. the position of the view) are already held in the view (i.e. the frame property in this case). I then have a data duplication/synchronization probl...

What is the difference between MVC model 1 and model 2?

I've recently discovered that MVC is supposed to have two different flavors, model one and model two. I'm supposed to give a presentation on MVC1 and I was instructed that "it's not the web based version, that is refered to as MVC2". As the presentations are about design patterns in general, I doubt that this separation is related to Jav...