strategy

Strategies for writing expanding ordered files to disk

I an a graduate student of nuclear physics currently working on a data analysis program. The data consists of billions of multidimensional points. Anyways I am using space filling curves to map the multiple dimensions to a single dimension and I am using a B+ tree to index the pages of data. Each page will have some constant maximum num...

difference between strategy pattern and delegation pattern

What is the difference between strategy pattern and delegation pattern (not delegates)? ...

How to generate a random number with Java from given list of numbers.

Hi, Assume I have an array/vector of numbers like 1,3,7,9 then I need to guess a number from this list randomly. Using Random class in Java it seems like not possible to do this. Could anyone kindly help me to tell a way to do this kind of thing. I have to change the list of numbers used to generate random number. I am trying to impleme...

Log4J: Strategies for creating Logger instances

I decided to use Log4J logging framework for a new Java project. I am wondering what strategy should I use for creating/managing Logger instances and why? one instance of Logger per class e.g. class Foo { private static final Logger log = Logger.getLogger( Foo.class ); } one instance of Logger per thread one instance of Logger pe...

Are there any open-source military/war strategy simulating engines/frameworks?

Are there any open-source military/war strategy simulating engines or frameworks? Combat rules engines or weapon selection guides? I'm looking for something similar to a military strategy "unit testing" in a simulated field. What I'm trying to build is a combat advisor for troops deployed in the field. Intel' comes in with enemy's moves...

Real-time synchronization of database data across all the clients

What's the best strategy to keep all the clients of a database server synchronized? The scenario involves a database server and a dynamic number of clients that connect to it, viewing and modifying the data. I need real-time synchronization of the data across all the clients - if data is added, deleted, or updated, I want all the clien...

use strategy pattern for billing models that use different data for the calculation?

we have an invoice model that bills clients in a few different ways. for brevity sake, i'm going to focus on two: cost per impression and cost per phone inquiry. my thought was to implement these (and the rest) as strategies and then dynamically mix them in to the invoice class. this seems appropriate because there are different source...

TDD as a defect-reduction strategy

Can TDD be successful as a defect-reduction strategy without incorporating guidance on test case construction and evaluation? ...

Most elegant/safe/easy solution to store and edit (GUI) a directory-like tree structure?

Hello, I've got a slightly tricky problem to solve; imagine this: One of my applications needs to make heavy use of scripting, so my idea was to provide the user a way to write script snippets and organize them in a directory-like tree structure. This is much like a source code directories with subdirectories and source files. Data Cl...

How to win this game?

Support we have an n * m table, and two players play this game. They rule out cells in turn. A player can choose a cell (i, j) and rule out all the cells from (i,j) to (n, m), and who rules out the last cell loses the game. For example, on a 3*5 board, player 1 rules out cell (3,3) to (3,5), and player 2 rules out (2,5) to (3,5), curre...

AS3: strategy for adding sprites that animate sequentially

Hi all, I am developing a component that can list files that users select from their filesystem. I'm using a (extended) FileReferenceList and (my own) FileReferenceDisplayList. The latter listens for events from the former. If the FileReferenceDisplayList receives a FileReferenceListEvent.ADDED event, it should display the new item in t...

Recommendations on handling object status fields in rails apps: store versus calculate?

I have a rails app that tracks membership cardholders, and needs to report on a cardholder's status. The status is defined - by business rule - as being either "in good standing," "in arrears," or "canceled," depending on whether the cardholder's most recent invoice has been paid. Invoices are sent 30 days in advance, so a customer who...

who should instantiate and assign runtime strategy implementations?

When implementing the strategy pattern, how do you determine which class is responsible for: Selecting the specific concrete strategy implementation to pass to the Context class (assuming that the selection is based on some complex business logic and not a static flag) Instantiating the aforementioned concrete implementation and actual...

Deployments: MSI packages vs Scripts

I have been tasked with looking into our deployments, and seeing where they can be streamlined. Right now we have 4 different configurations (Debug/Dev, Test, Staging, Release) and 4 *.config files. We have a task that will overwrite app/web.config with the appropriate *.config pre-build time based on the active configuration. An MSI is ...

Which strategy about connection management should we use when developing an application?

Which one is better while developing win-based application which uses a Database as its data store ? What about web-based applications? 1) when user loads he first form of an application, the global connection opens and by closing the last form of the application, the connection closes and disposes. 2) for every form within the applica...

strategy implementation question

I have a MessageProcessor class which processes xml messages of different types. A switch statement (C#) based on the message type calls the appropriate method to parse the xml and extract the data required for the type of message. I would rather have a number of parser classes, one of which will be injected into the MessageProcessor w...

Strategy for external javascript framework debugging

Working with Extjs, GeoExt and OpenLayers, I more and more tend to run into problems which do not result in direct javascript errors (in either IE, FF or similar). It could be features not working, unexpected behaviour and so on. My usual strategy is to strip down code to a minimum hoping to discover where the problem arises - Firebug a...

Difference between Template Method (separation) and Strategy pattern?

Hi all. My teacher is a really good one and I tend to understand his points, but this one just goes over my head. He explains Template Method in two variants; - Unification: the standard variant, that is composed of an abstract class with some abstract methods defining the variant parts of the otherwise fixed algorithm. - Separation: his...

Strategy: Unlock document when user leaves a page.

Hi, The current app I'm building is a collaboration app that holds several users in a "team" or company that can access a set of projects. Each project has it's own documents. I want to protect team users from running in to each other and so I have built a system where documents are locked by the first user to access them. The document...

Which object will be garbage collected ?

I wish to confirm which scenario will cause a Garbage Collection on the object myObj: Scenario 1 ArrayList arList = new ArrayList(); while(someCondition) { myObj = new MyObect(); // a custom object arList.add(myObj); } Scenario 2 ArrayList arList = new ArrayList(); while(someCondition) { myObj = new MyObect(); // a custom obj...