design-patterns

Write a java class to have only five instance of it created

I want to write a java class that can be instantiated only 5 times just like you have singleton class which have only one instance. Apart from this the instances should be picked in round robin basis. Suppose I have a class A. I should be only able to create 5 instances of this class. Say I have InstanceA_1, InstanceA_2, InstanceA_3, I...

Why do DAOs have separate create and update methods?

I'm looking at a couple of designs for DAO interfaces. One has a single update() method, while the other has separate create() and update() methods. Assuming that it's possible to do something along the lines of 'insert otherwise update', what's the benefit of a separate create() method? Is there something to do with concurrency lurking...

Can someone please critique my Factory Pattern??

Hello, I have recently been learning more about design patterns and thought I'd take a crack at it. I'm not sure if this is the correct way to use the factory pattern and was wondering if someone could provide me with feedback? I basically have a set of calendar items that are similar. Meals, workouts and measurements. They all have a d...

Architecture/patterns for pushing live data in client server application

I have got a server that controls a complicated industrial system. We need to write a remote client that can connect to the server and "observe" its internal state. I need to work out: How to establish the current state when the client connects How to keep the client up to date with changes on the server Do we replicate all of the obj...

How to create UI and Model based on some business logic

I had following business logic. In this Op1 and Op2 represents some operation. And param1,param2,... represents parameters required for executing these operations Op1=param1, param2 Op2=param1, param2, param3 Now in UI I had a drop down list containing "Op1" and "Op2". Following should happen based on my business logic 1) If I select o...

Is this still an adapter pattern?

Hi, I stumbled upon this class and was wondering if XYZAdapter might be the correct name. I know how the adapter pattern works, but this solution is a bit different: Instead of implementing the DataTable interface and mapping the appropriate method calls, im creating a new DataTable object by copying the values and expose this object. T...

Is Repository pattern an overkill

I have been using Repository pattern (DDD and POEAA) for some time. However some of our team members have argued that it is just an extra layer of abstraction and unnecessary. I can seen some benefit in their arguments. Modern ORM solutions (NHibernate or EF) have almost everything you need. I searched and found some article like this an...

How to structure a utility/companion project in a multi-project solution

Let's say I have a Visual Studio solution with a Web project, a BLL project, and a DAL project. I'm trying to follow the repository pattern keeping my SQL code in the DAL with an interface that is referenced by the BLL. I have a handful of common solutions for things such as error handling, usage logging, and other things that can be c...

GUI Design Pattern , MVP, Tab Control

Hi, I have an application that has a window similar to the one bellow . The requirement here is that when the user clicks the Save button everything has to get saved. The "Save" and "Reset" buttons are "common" to all tabs. Hence, when the "Personal Information" tab is selected and "Save" is clicked the program should also save chang...

Synchronizing client-server databases

I'm looking for some general strategies for synchronizing data on a central server with client applications that are not always online. In my particular case, I have an android phone application with an sqlite database and a PHP web application with a MySQL database. Users will be able to add and edit information on the phone applicat...

Design pattern to refactor switch statement

I have something like the following in the header class MsgBase { public: unsigned int getMsgType() const { return type_; } ... private: enum Types { MSG_DERIVED_1, MSG_DERIVED_2, ... MSG_DERIVED_N }; unsigned int type_; ... }; class MsgDerived1 : public MsgBase { ... }; class MsgDerived2 : public MsgBase { ... ...

If Entity Framework is meant to work with POCOs, then why the dependency on IObjectSet?

I keep hearing about EF 4.0, POCO, IObjectSet, UnitOfWork (by the way, UoW is atleast more than 17 years old when I first heard it) etc. So some folks talk about Repository "pattern". etc. There are numerous bloggers showcasing their concoction of a "wrapper" or repository or something similar. But they all require IObjectSets (or in so...

How do I break an iPad view up into more manageable chunks?

Hi all, I know I'm probably going to be berated for not properly reading the HIG or some documentation, but after going through several training videos and building a number of small projects on the iPhone, I'm now trying to put stuff together on the iPad and, well, my brain hurts. I understood the idea on the iPhone that one view = on...

JavaScript Namespace

I want to create a global namespace for my application and in that namespace I want other namespaces: E.g. Dashboard.Ajax.Post() Dashboard.RetrieveContent.RefreshSalespersonPerformanceContent(); I also want to place them in seperate files: Ajax.js RetrieveContent.js However I have tried using this method, however it won't work b...

Game engine development

I am going to be re-creating a game engine I created awhile back. This time I want to do it right, so I did some research into design patterns and tried to put pieces together to accomplish my goal. The idea of the game engine is simplicity, but at the same time I don't want to sacrifice usability. Here is a blueprint of what I am think...

Is there some literature on this type of programming?

In college I took on a class on modern physics, in which we learned about special relativity. I was completely blown away by how different frames of reference could actually observe physical properties of an object to be different and neither be incorrect. Over time, this concept has slowly been changing the way I program, to the point...

Please review my design - Need Input

I'm basically just posting tonight to get some feedback from some of you more experienced architects out there. I'm just starting to get into more use of Interfaces...already seasoned and know Abstract Classes which I've used in some pretty slick designs of my own. Anyway, I created a hack UML here: uml.pdf A few things about the diag...

Software pattern for auto-discovery mechanism

I am currently developing a system for translating between data files of different types. Some of these files are just a single stream of data, some have multiple columns of data, and some have multiple channels of data (i.e. can contain multiple streams and types of data embedded). The user would be allowed to select any file type as ...

How does TransactionScope work?

When Method1() instantiates a TransactionScope and calls Method2() that also instantiates a TransactionScope, how does .Net know both are in the same scope? I believe it doesn't use static methods internally otherwise it wouldn't work well on multithreaded applications like asp.net. Is it possible to create my own TransactionScope-like ...

Transferring data from one grails action to another

For our grails application, I've written a method that lets you upload a CSV file full of contacts, and it will parse the file and create contacts out of the data. I've used a test file of my own (hard-coding which fields mean what) and it works great. But of course I can't leave the field references hard-coded like that, so my next ste...