design-patterns

How to adapt domain objects to GUI in Java

Hi, I'm new to the architecture of UIs and in the past I've programmed very simple UIs. Now I'm confronted with a very large domain model. Because I've used different OR-Mappers to store domain objects in a flat data structure I thought about mapping the domain objects to the view-side in a similar way. Are there any patterns or framew...

What pattern/patterns work best for developing rule/decision engine

I am working on a decision engine / rule evaluation engine. For example: Input: Customer and all the offences done by the customer Output: Consequences of the offences A sample case would be: Input: Customer(Jhonny Chimpo, 999-00-1111), Offences ( Broke window, slapped boss, kicked team lead in his groin) Output: Gets pink slip So ...

Design question: Dynamically changing GUI -> sending implementation classes as soap attachments.

Here's a scenario: I have a java front end (RCP/SWT) app which currently has no authentication support. I have to however, add security to this application so that it gets deployed in different enterprise envinronments. I have a few approaches which I thought I would share with you all here and take your inputs. Please note that there a...

Why are they called the "gang of four"?

The writers of the Dragon book are called gof. Why is that? Are they some kind of clique that always hangs out together? ...

Pattern to build a large hierarchy of objects

I have a problem that involves a relatively large object hierarchy as follows: game has one community manager community manager has one network network has many players network has many friendships player has one strategy manager player has one memory player has one neighbourhood neighbourhood has many players strategy manager has many...

Passing platform-specific data in a platform independent design?

I have a game engine design written in C++ where a platform-independent game object is contained within a platform-specific Application object. The problem I'm trying to solve is the case where I need to pass OS-specific data from the Application to the game. In this case, I'd need to pass the main HWND from Windows for DirectX or an O...

C++ Design pattern for Search and Replace

Hi I have big paragraph with some special characters as %1 , %2, %3 I need to know if there is any design pattern to replace those with proper values and create final paragraph. For Example: Following is my static paragraph. %1 is beautiful country , %2 is the capital of %1, %1 national language is %3. I get values of %1,%2, %3 by so...

PHP/MySQL database design for various/variable content - modular system

Hello, I'm trying to build (right now just thinking/planning/drawing relations :] ) little modular system to build basic websites (mostly to simplify common tasks we as webdesigners do routinely). I got little stuck with database design / whole idea of storing content. 1., What is mostly painful on most of websites (from my experience...

How to Create a Custom tabBarController to simulate uiTabBarController

How to create an custom tabbar controller which has custom background image, custom icons, and custom labels and positioning but serves exactly the same purpose as UITabBarController. I badly seeking for an optimal solution for this. When i learn the solution this will really help me to write a generic wrapper and save more time. I hav...

Need help with Java design of Http Requester

Hi everyone, I am running into a design problem. I have the following (pertinent) classes: class LoginScreen { public login() { httpRequest = factory.createHttpRequest(url, method, this); httpRequest.start(); } public authorize() { httpRequest = factory.createHttpRequest(url, method, this); httpRequest...

Is this how the Factory Pattern works?

The Singleton and the Registry patterns were very simple and easy for me to understand right away but the Factory pattern has been something I haven't been able to get my brain to interpret 100% yet. I think I might understand it now, I have wrote a sample code below, please review and tell me if this is the proper use of the Factory pa...

When using auto-generated TableAdapters, what is the suggested way to deal with repeated instantiation?

I am using the .xsd dataset thingies (which I hate) to auto-generate TableAdapter classes for some backend code. I have not really used these before, tending to favour manual commands and stored procs whenever possible (for various speed-induced reasons: those xsds play hell with dynamic tables and really large amounts of columns), and a...

How to explain failure of an action with complex restrictions

I'm implementing a system where a customer can use vouchers to gain discounts for a purchase. If a voucher can be used for a certain purchase depends on several circumstances. For example: Proper voucher code - is the code correct? Validity Range - is the voucher still valid? Can the voucher be used with the type of purchase? Comb...

ASP.NET Model-View-Presenter and List versus Details

In Model-View-Presenter what is the correct pattern to do a page that: a) contains a grid for browsing a list of items b) an alternate mode for editing single items maybe you are toggling between two asp:panels. Do you just make the presenter smart enough to do two types of presentations? Make 2 presenters? I'm new to this pattern ...

Android - poster child project

In my past programming experience I found that learning by example is the shortest way to improve my skills. I'm now looking for a "poster child" opensource Android project which would follow best practices such as having good unit-test coverage, following clear design patterns, have well written, well documented sources and (hopefully) ...

C++ specific patterns due to language design.

It took me a long time to realize how important and subtle having variables that: 1) exist on the stack 2) have their destructors called when they fall out of scope are. These two things allow things like: A) RAII B) refcounted GC Interesting enough, (1) & (2) are not available in "lower" languages like C/Assembly; nor in "higher"...

Can't figure out this in Holub's pattern book

Hi, I started reading Holub's pattern book and not sure if this is a mistake (pg 59-61). He has in listing 2-3 public interface Employee { void youAreFired(); } public static class EmployeeFactory { private Factory() {} public static Employee create() { return new Peon(); } } /* package*/ class Peon implements Employee { p...

Single Responsibility Principle(SRP) and class structure of my rpg looks "weird"

I'm making a role playing game just for fun and to learn more about the SOLID principles. One of the first things I'm focusing on is SRP. I have a "Character" class that represents a character in the game. It has things like Name, Health, Mana, AbilityScores, etc. Now, normally I would also put methods in my Character class so it would ...

To use or not to use the State Pattern?

I'm designing a pinball game for a Uni project in which there are supposed to be 2 modes: running mode and builder mode, whereby one can design/redesign the layout of the machine. My initial thought was the State pattern - however, I'm concerned that the common interface between the states may contract them into implementing methods whi...

Generating pass-through code when "preferring composition over inheritance"

Problem Let's say I'm trying to model a cell phone as a combination of a regular phone and a PDA. It's sort of a multiple inheritance scenario (a cell phone is a phone, and it is a PDA). Since C# doesn't support multiple inheritance, this pretty much calls for some kind composition. Plus, let's say that I have other reasons to favor com...