I am working on a project that is developing a website application for 3 clients. All clients are happy with the base product that we are producing. 2 of them have some slightly different requirements - about the visibility of certain controls, different data binding to dropdowns, etc.
My question is - knowing that each of the 3 clients...
Hi,
I've implemented an abstract factory like this
public abstract class AbstractFactory {
private static final Map FACTORIES = new HashMap();
AbstractFactory(FactoryType type) {
FACTORIES.put(type, this);
}
public abstract A getA();
public abstract B getB();
public static AbstractCatalogFact...
I have a class called DataStructures where I have a set of public static data structures that store objects. To add an object to a data structures is an involved process requiring a number of checks to be carried out, processes to be remembered and data to be rearranged. In another class called Foo, I need to add objects to the data stru...
Hi,
I am creating a software project in which most business objects are stored in files (in a legacy format). The objects will only be instantiated from an inputstream.
I do this today with making the constructor private and instantiating in a static function as follows:
public class BusinessObject {
private BusinessObject() {}
...
In my application I have many classes. Most of these classes store quite some data, and it is important that other modules in my application are also 'updated' if the content of one of the data classes changes.
The typical way to do this is like this:
void MyDataClass::setMember(double d)
{
m_member = d;
notifyAllObservers();
}
This...
Can someone point out the main differences between the two?
It seems that, at least conceptually, the two are very closely related. If I were to hazard a guess, I would say that the publish/subscribe method is a subset of the mediator pattern (since the mediator need not necessarily be used in the publish/subscribe manner, but the latt...
Firstly, can anyone explain how a state object can be shared when the state object has no instance variables ?
This text is taken from GOF, page 308, item 3 (consequences section):
The state object can be shared.
If state objects have no instance variabkes - that is, the state they
represent is encoded entirely in their
type...
I'm having a very hard time wrapping my head around this problem (it might be the heat from the summer finally arriving).
Problem:
I want the user to press a button client side which performs javascript data preparing and at last send a JSON structure to (currently a asmx webservice on) the server. The JSON structure is several levels d...
I have a class whose sole purpose is to decide, based on a setting, whether to call A) a business layer using a WCF service first or B) the business layer directly.
What is the naming convention for a class the is just a redirector. I was thinking either using "Wrapper" or "Controller" in the class name.
...
I'm starting a new project that will require use an external REST API that basically returns JSON and XML files. It's similar to the StackExchange API and I see every wrapper that has be done for that API has a different approach; for instance, stackoverflow-java-sdk uses the Adapter Pattern.
So, in order to make sure every new API feat...
Hi all,
This is a question for general discussion. Are there any good, comprehensive resources for useful JavaScript design patterns. I am trying to avoid references that attempt to coerce JavaScript into, say, Java by imposing patterns more suited to another language. Let's let JS be JS and shape our patterns around the strengths.
Ple...
I'm building a form class in python for producing and validating HTML forms. Each field has an associated widget which defines how the field is rendered.
When the widget is created, it is passed in a (default) value so that it knows what to display the first time it is rendered. After the form is submitted, the widget is asked for a val...
Now that I learned to use Observers two questions came to my attention:
1 - Is it common to use Observer Pattern to notify just one object about changes?
2 - When just one object need to be updated it's better to use an observer or an event? Or there are cases when just one notification is needed that Observers are more recommended?
...
I have to create a COM API which basically will read some data from XML , do some processing on it and return some data as a string.
This API will be in COM DLL which will be in memory most of times.
I have created a struct to hold the data in memory which can be used as cache so as to avoid reading file every time whenever API is call...
I've been reading various programming styles like XP (writing the test first), and came across a Java book that just has design patterns, what seems to be like pseudocodes.
What are these design patterns used for ? what does design apttern in the context of programming refer to and what are it's applications ? Is it like blue prints for...
Just for discussion, to me it seems that 2 different terminologies actually are saying the same thing. Is there any tangible differences between this 2 design approaches?
...
I'm new to designing OO systems. I have a simple Flash Cards app where I'm having trouble figuring out the proper way to architect the system. The application has a simple GUI with a question, answer, and couple buttons. The questions and answers dataset are stored in a Derby embedded database.
Quick Setup:
Database Class - Handles the ...
Hi all,
I've been looking into various ORM frameworks lately (mostly .net) and see that the Active Record design pattern is commonly used to persist data.
I just wondered what everyone's take on the active record pattern is? Personally I think it puts too much responsibility on the data object, be it just a data container or an entity...
This may sound like a stupid question, but can DI be used everywhere where a Singleton is needed? Or are there use cases where a Singleton makes more sense? A professor of mine said that there a few but valid cases where a Singleton is "good enough" but I'm somehow not happy with that :-/.
...
I think I finally figured out they need to use this DeclarativeFieldsMetaclass (to turn the class fields into instance variables and maintain their order with an ordered/sorted dict). However, I'm still not quite sure why they opted to use a BaseForm rather than implementing everything directly within the Form class?
They left a comment...