pattern

Need help with asynchronous operation

I'm relatively new to asynchronous and service-oriented programming and want to do the following: Fire off a stored procedure in a database that could run for minutes or even hours. Return a code to the caller of a job id that the client can use to track the progress of the job. This seems like a simple task, but being new to asynch...

Java Plugin Pattern

I am a Java beginner and I would appreciate it if someone here can explain how to implement Martin Fowler's plugin pattern in Java. Thanks in advance. ...

Best way to skin flash player

Is there a good pattern to creating a flash player that is easily skinned, providing different dimensions, buttons, background color, etc? I've considered 2 approaches: 1 The player skin is flat. The logos and buttons are on one large background image. The actual trigger areas are transparent sprites, positions and dimensions defined by...

How can I get multiple memories from a Perl regex match?

The purpose of the regex search is to determine all template class instances from C++ header files. The class instances can be formarted such as: CMyClass<int> myClassInstance; CMyClass2< int, int > myClass2Instacen; The search is performed by loading the entire file into a string: open(FILE, $file); $string = join('',<FILE>); close...

Factory method pattern in java using generics, how to?

I have code that looks like follows: public interface BaseDAO{ // marker interface } public interface CustomerDAO extends BaseDAO{ public void createCustomer(); public void deleteCustomer(); public Customer getCustomer(int id); // etc } public abstract class DAOFactory { public BaseDAO getCustomerDAO(); public static DAOFactory getIn...

Patterns and technologies for a system capable of processing 40,000 messages per second

We need to build a system capable of processing 40,000 messages per second. No messages can be lost in case of any software or hardware failures. Each message size is about 2-4Kb. Processing of a message consists of validating the message, doing some simple arithmetical calculations, saving result to database and (sometimes) sending no...

Haskell: Creating Type Classes for Zippers

So I've been reading a bit about the Zipper pattern in Haskell (and other functional languages, I suppose) to traverse and modify a data structure, and I thought that this would be a good chance for me to hone my skills at creating type classes in Haskell, since the class could present a common traversal interface for me to write code to...

Java enums in MIDP 2 mobile application

I've just got back to MIDP development after some 4 years of .NET 2 and Java 5 and 6. During that time I got to like using enums quite a lot. Enum is a language feature that allows a developer to have more confidence in some parts of his code, specially for being able to avoid or detect errors earlier (during compilation). Some other ad...

Service Layer vs. Helper Objects?

Hello, I'd like to have your opinion on a specific case, please. This is about Service Layer vs. Helper Objects - and I'm not looking for idealistic patterns, but merely a good understanding of what my dear programming colleagues think about this: In my current application I have a full domain model (Linq to Sql, extremely lightweight r...

C# Change Desktop Pattern

Im making a simple wallpaper changer. It works when changing the wallpaper but i cant change the pattern of the wallpaper. I tried something like this but it doesnt work :S SystemParametersInfo(SPI_SETDESKPATTERN, 0, "Center", SPIF_UPDATEINIFILE | SPIF_SENDWININICHANGE); Can some1 please show me the proper way of setting the wallpaper...

Cost decorators

Hello, For each product there are associated cost calculators like: discount, discount by merchant, bonus by merchant, monthly discount etc. In future, more cost calculators would be added. We have a concrete product class and many decorators for each cost calculation. All products should use all of the calculators, because the calcula...

how to design extensible and secure data structure in my scenario?

Hello everyone, I am developing a web site and I need to build a data structure to store user profile information. Just like what we filled about our gender/age/education/etc. information for Facebook, etc. The current issue I met with is how to design an extensible and secure data structure, in more details, Currently I may not consi...

Any good reason for xml pattern "the order of elements is significant" rule?

I don't see why order of elements is significant but not the case for attributes. Can any one provide a sound reason? element addressBook { element card { attribute name { text }, attribute email { text } }* } In XML, the order of attributes is traditionally not significant. RELAX NG follows this tradition. The above patt...

What is an Anti-Pattern?

Hi, I am Studying about Patterns and Anti-patterns . I have a clear idea about Patterns. but I am not getting Anti-Patterns. Web Definitions and Wikipedia is confusing me a lot. can anybody explain me in simple words that what is anti-pattern ? what is the purpose . what they do ? .. is it a bad thing or good thing ? ...

Inheritance in a composite structure

Hello everybody, i have a problem related to the design of a composite structure. I have an Expression abstract class that describes a generic mathematical expression. The idea is that an expression can be an atomic expression (like "x" or "3") or some kind of aggregation of atomic expressions (like summatories, productories, exponentia...

Javascript regex pattern

Hi, I have a combo box and input box. If I enter any letter in input box then all the words or sentence that match with that letter should display in the combo box assuming that a list of words or sentence contain in the list. ex1:) input box: a combo box : America Australia joy is in Austr...

How can I create an object whose derived class is specified implicitly by the creation properties?

I'm looking for a pattern for the following. (I'm working in Perl, but I don't think the language matters particularly). With a parent class Foo, and children Bar, Baz, Bazza. One of the methods for constructing a Foo is by parsing a string, and part of that string will implicitly specify which class is to be created. So for example i...

Is there a way to derive from a class with an internal constructor?

I'm working with a 3rd party c# class that has lots of great methods and properties - but as time has gone by I need to extend that class with methods and properties of my own. If it was my code I would just use that class as my base class and add my own properties and method on top - but this class has an internal constructor. (In my ...

How to get several regex groups from Matcher in Java?

I have a Java program that does some String matching. I'm looking for anything that matches \d+x\d+ in a String. This works, using the Pattern and Matcher classes. However, to parse the String parts I have found, I have to manually parse the String I get from the Matcher.find() and Matcher.group(). How can I tell the Pattern I'm looking ...

ORM and DAO in PHP

I am a PHP developer and I am familiar with ORM (Doctrine and Propel), but I seldom heard about DAO. What are the differences and relationship between ORM and DAO from PHP development perspective? If I use Symfony to develop very large and complex projects, will that be better if I use DAO? (ORM is somehow heavy I think, but I know lit...