I have a set of data objects, which correspond to rows in RDMS table, as in ClassA -> Rows of TableA ClassB -> Rows of TableB . . . ClassZ -> Rows of TableZ I am fetching these records using JDBC and creating objects from the result set(Please no
Very often I run into code that logic that should be within business object is repeated everywhere as such: if ( !string.IsNullOrEmpty( Employee.Name ) ) Display( Employee.Name ); where as it should be like this : if ( Employee.IsNameSpecified ) Disp
I've put together a simple C++ event pattern, that allows the following: struct Emitter { Event<float> ev; void triggerEvent() { ev.fire(42.0); } }; struct Listener { void gotEvent(float x) { ... } }; int main() { // event source and listener unawar
I read the difference between factory pattern and factory method pattern. Factory method pattern defers instantiation of an object to subclasses. Also it is a Factory Method because the children of "Creator" are responsible for implementing the
Especially in unittests we use this "design pattern" I call "get class from class level" framworktest.py: class FrameWorkHttpClient(object): .... class FrameWorkTestCase(unittest.TestCase): # Subclass can control the class which gets u
I am working on a class which needs couple of helper methods. This methods are going to be used only by this class. So I am wondering which will be best practice i.e. whether declaring these helper methods as private methods or group them and put ins
I't trying to follow MVC pattern. In internet as I see the most famous example is calculator, for example here. I began to use this implementation of MVC pattern. But now I have some doubts about action listeners in controller as they tend to move to
We Love Play!! Have used for small projects and pleased with the performance and productivity. Need few suggestions or comments for the architecture for our new venture which is going to be on play-framework. Our new venture is to use REST Service st
I have created a single class but I'm having a little trouble accesing the public methods from the private ones. My example is this: var mySingleton = (function () { function init() { function privateMethod(){ publicMethod(); //this.publicMethod() al
I'm working on a project where I had to add a data layer to my application. I've always thought that the data layer is purely responsible for CRUD functions ie. shouldn't really contain any logic but should simply retrieve data for the business layer
I have been doing web app for medical data collection for a long time. Clients always have this kind of request : adding a new field in the form, for example they want add "gender" in demographic form. Every time they request, I have to 1. Add a
The Interfaces: package sandBox.ps.generics.compositePattern; import java.util.Collection; interface AnimalInterface { String getID(); /* * getAnimals can be: * 1. AnimalInterface * 2. Anything that implements/extends AnimalInterface (i.e. AnimalInte
I am trying to 'decorate' UICollectionViewCells using the Decorator pattern. For example, if I have a BaseCell : UICollectionViewCell I would like to be able to do something like this: BaseCell *cell = [[BaseCell alloc] initWithFrame] cell = [[Glowin
I am actually writing a library class which could be used by multiple classes. I am simplying the example so as to make a point. Lets say I have three classes: A, B and C: public class B { public static string B_Method() { string bstr = String.Empty;
I have a set of data that is basically a table of contents First Section First Subsection First Subsection Content A First Subsection Content B Second Subsection Second Subsection Content A Second Subsection Content B Second Section First Subsection
Suppose I have a repository (ContactsRepository) with method like getAllContacts(userId). The (ContactsRepository) fetch all data from server. After first call getAllContacts(userId) method I want to cache this data. My question is where I should rea
I have only one page with distinct sections managed with AJAX. In one section (1) I add and edit company names. In the following section (2) I display these company names. (Please see attachment) When I have edited a company name in section 1 (alread
I mean a user ID can't be auth in two different machines at the same time. How can I control this? I'm using the Java EE platform.Every time a user logs in you give him some token (Session ID, for example). Later, when user performs some operations y
To explain my question: Class : Toy Trait1: Speak like Male Trait2: Speak like Female Can I change the behavior (traits) of Toy during runtime so sometimes the same object speaks like male and sometimes the same object speaks like female? I want to c
Strategy is a pattern aimed at allowing you to add new (in your case sort) algorithms to your software without breaking the clients of the algorithms. It's an investment in design complexity that will pay off if you need to add new algorithms without
In my design, at the first time, I was designing a factory pattern. But one person recommend use better the bridge pattern. This is my scenario: How to improve my abstract factory pattern? I just want to know which pattern is the best for this scenar
I'm trying to improve a Java project which uses a lot of large case statements. In cases where the case statement is used, it is used to handle an event which has an attribute associated to it. For example: public void jumpOverWall(int wallID) { swit
I have been mauling over this for while now, and wonder if anyone could point me in the right direction. I have the following object definition: var foo=function(){}; foo.prototype={ foo1:function(){}, baz:{ baz1:function(){} }, bar:function(){ funct
I have a function that need to analyze packet after packet and decide what to do. For each packet the code must: Read a packet, on timeout return an error code. Check for corruption, if positive log it and and go to 1. Check for an abort packet, if p
Is there any way to easily implement a proxy class pattern in C++? Not using AspectC++ or other heavy tools, just built-in macro or templates. Explaining what I want: class base_class { public: virtual void method_one() { ... } virtual void method_tw
Given: internal void Configure(ButtonEventArgs args, IBroker broker, FunctionEntry entry) { int phase = broker.TradingPhase; if (args.Button == ItemType.SendAutoButton) { if (phase == 1) { entry.SetParameter("ANDealerPrice", -1); entry.SetParame
I can see how Swing uses Decorator and Observer pattern. Observer: Every component(eg. JButton) is a subject which can add observers(ActionListeners). When someone pushes a button it notifies all its ActionListeners by calling their actionPerformed(A
I have a three tier system, SQL Server backend, hand written data access layer, and using stored procedures. I have a table called EventTable. Each row is an 'Event'. An Event has a primary key, and a start date. CREATE TABLE EventTable ( ID INT IDEN
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 pattern
Why not use partial class to build the ViewModel? Since the definition of viewmodel classes have some definition of the data classes of datamodel, why not try to reduce some work, extending or making partial classes of the datamodel, completing them