design-patterns

Interface hierarchy design pattern?

I'm in the early stages of developing a C++ multi platform (mobile) application which has a graphical user interface. I'm trying to find a good way of abstracting the actual UI/windowing implementation. Here is basically what I have tried so far: I created an interface hierarchy Screen +Canvas +Form +Dialog Control +EditBox +Che...

ASIHTTPRequest code design

I'm using ASIHTTPRequest to communicate with the server asynchronously. It works great, but I'm doing requests in different controllers and now duplicated methods are in all those controllers. What is the best way to abstract that code (requests) in a single class, so I can easily re-use the code, so I can keep the controllers more simpl...

Circular dependencies of declarations

Hi, I am trying to implement example of visitor pattern, but I have trouble with circular dependecies of declarations of classes. When I do forward declaration of class Visitor, classes Russia and England doesn't know that Visitor has method visit, but when I extend forward declaration of Visitor for method accept, I need to use classes ...

Virtual tables are undefined

Hi, I wrote some code but I am unable to compile it: #include <cstdio> #include <vector> using namespace std; class Visitor; class Land { public: virtual void accept(const Visitor *v); }; class England : public Land { public: void accept(const Visitor *v); }; class Russia : public Land { public: void accept(const...

When should we create a new method?

I'm trying to find out if there is a consensus on when we should create a new method in our code. For example should we only create a new method/function if we are going to be using the code again (therefore we obviously cut down on the lines used) or is it common to do it just to avoid code clutter as well. I've been programming for a l...

Stop and continue while evaluation an expression tree

At the office, we've applied simple Domain Specific Languages (DSLs) to several problem domains we encountered. Basically, we parse (lex/yacc) the custom script into an expression tree. Every node in the expression tree has an .evaluate() method that gets called recursively, until the program is done. Nice, and simple as pie. Which is ...

way to the intermediate level

Hi guys, I've got a question related to the practical learning of programming skill. I'm acquainted with basic programming stuff, know syntax and some concepts of several languages (Pascal, PHP, Python, now want to learn C#) and I debug quite a lot, so I can write (and have written) programs not bigger than 1000 lines of code for my ow...

How to design a command pattern with different listener?

I have a window which works like the Visual Studio designer. Each document has two views: Source View, Designer View. I have a toolbar that can issue different commands. The toolbar button has a CommandId string property that store the Id of the command, such as: Cut, Copy, Paste; Insert Grid, Auto Format ... I am having trouble...

Navigator pattern

The scenario is that we are writing a application to let people to fill online form to get insurance.The form is so large so that I have divided into many sections.My manager ask me to use navigator pattern to control the flow of the navigation.(section 1 to section 5 or you get the idea).I have not heard of Navigator pattern.Does my man...

What design pattern should I use for import/export?

I have a calendar event object. I have plans to make it compatible with CalDAV/iCal/vCal protocols/file formats, which require the event be serialized and de-serialized to and from different formats. I could write an ImportICal, ExportICal, ImportVCal, ExportVCal, etc. set of methods, but that doesn't seem like a very good approach, bec...

C++ Wrapper Native Interop Enterprise Scale

I want to know what is the best approach to wrapping a massive library written in C++ to make it accessible in C#. I have done work with interop before, and I love IJW. But I am not sure of how to implement this approach with a huge library. I am wondering if there is any pattern to use, otherwise I just have to write a wrapper around...

Pattern for batching and bulk processing

I've data queried from the db that looks a lot like the following Job Site File List ------------------------------- 1 SiteA file2.txt 2 2 SiteB file2.txt 2 3 SiteA file23.txt 23 4 SiteC file2.txt 2 5 SiteB file12.txt 12 6 SiteA file29.txt 29 7 SiteB file28.txt 28 I am supposed to initiate instances for each site (sites ...

Architecture of very complex php applications ?

I want to know which php architecture strategies developers use in complex php applications . So far , i know the mvc structure which consists of models, views and controller (and controller plugins which handle with common tasks such as user access controller ). I know some good php frameworks which makes some common stuffs easier .But...

Persistable and Repeatable Commands

Imagine that we have stuff we want done in the system and sometimes exceptions are raised while doing it. We want to give the end users a report of those errors so they have an opportunity to fix the root of the problem and then re-invoke the thing that caused the error. This obviously means we need to capture the "thing" in a way that ...

Observer Pattern Overload

I'm stuck with the following scenario. It has a code smell, that I'm not happy with, but resolutions to it seems to be as complex, but just in different ways. I have a scene graph representing business objects. I've designed it so that the business objects themselves are as simple as could be. They're practically POJOs. Now, 1 entity m...

Challenges and Best Practices for Failing Over Services

Hi everyone, Does anyone know of any established best practices for running Windows services (in my case, developed in .NET) such that they will (automatically) fail over correctly to another server, for high availability purposes? The main ways I can see this being done are either starting up the secondary server when required (in whi...

What C++ idioms should C++ programmers use?

Question What C++ idioms should C++ programmers know? By C++ idioms, I mean design patterns or way of doing certain things that are only applicable for C++ or more applicable for C++ than most other languages. Edit: Please explain why one should use the idioms and what the idioms do. ...

Representing game states in Tic Tac Toe

The goal of the assignment that I'm currently working on for my Data Structures class is to create a of Quantum Tic Tac Toe with an AI that plays to win. Currently, I'm having a bit of trouble finding the most efficient way to represent states. Overview of current Structure: AbstractGame Has and manages AbstractPlayers (game.nextP...

Building core shop framework in Rails. Suitable or not?

I work at an in-house IT department for company running 10 or so only shops of varying complexity. The shops code has been written over the last 8 years, each shop a new branch growing father and father away from the stem (I guess that makes it a bush?) The need for more and more complex discounts, campaigns and user monitoring are grow...

Master-Slave Pattern for Distributed Environment

Hi, Currently we have a batch driven process at work which runs every 15 mins and everytime it runs it repeats this cycle several times: Calls a sproc and get some data back from the DB Process the data Saves the result back to the DB It can't load all the data in one go because the data are segregated by a number of fields and each...