language-agnostic

Is the Prototype Design Pattern Really Just Clone?

I am doing an in depth study on design patterns, and I came across prototype, which I didn't really study before. I have searched the web and several books, and there isn't a really good example of prototype that could find that isn't just clone. Is the design pattern of prototype basically a language feature of java and C# as clone? ...

3d bin packing algorithm

I am looking for a deterministic implementation for any 3d bin packing algorithm, i.e. for packing many small and different cuboids inside one or many bigger ones. The solution could vary from the optimal one. It should be written in C, C++, Java, C#, IronPython, IronRuby or any other language an can bin to from .Net code. I found this...

Do e-ink / e-paper screens work in the RGB, CMYK, or some other colour space?

Do e-ink / e-paper screens work in the RGB, CMYK, or some other colour space? Will we need to support native CMYK displays in the near future? I'm designing a data structure with colour information and want to know whether the colour part ought to support expansion beyond four colour components (for, say, CMYKA). ...

Book Recommendation: "System/Model Theory"

I recently read Evans DDD, Fowler PoEAA and Fowler Analysis Patterns. These books got me interested in "modeling" as a more general terms. I noticed there are so many parallels to physics or mathematics, so I wonder if there is a field of science that deals with things like leaky Abstractions, defining Systems based on axioms, drawing co...

Push DVCS repository to master without needing codebase

To work on a client's staging environment I have to connect through a VPN which locks all normal network traffic and prevents any connection to the Internet. This would immediately prevent any of the "normal" VCS solutions from being used as it's not possible to gain access to the server. A solution to this would be to create a DVCS rep...

What does this recursive snippet of Java code do?

I passed through this recursion example, but I couldn't find out its purpose. Could you please help me? public static int somerec(int n, int x, int y) { if (n < x*y) return 0; else if (n == x*y) return 1; else { int sum = 0; for (int i = x; i <= n;i++) sum += somerec(n-i, i, y-1);...

What is the actual definition of an array?

Possible Duplicate: Arrays, Whats the point? I tried to ask this question before in What is the difference between an array and a list? but my question was closed before reaching a conclusive answer (more about that). I'm trying to understand what is really meant by the word "array" in computer science. I am trying to reach an...

If I only sanitize GET and POST data, will I be safe from injection?

I'm just thinking about the best way to go about sanitizing my data to prevent injection attacks. Some people like to sanitize immediately before output, or immediately before insertion to the database... but the problem I see with this is twofold: (1) what if you miss a paramater/variable? (2) what if you're over-sanitizing? Not that it...

How can I set only the outer booleans of a 2d array to false?

If I have a 2d array like: boolean[][] map = new boolean[50][50]; How can I set the outer edge of booleans to true only in a loop? So, for the following array: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 You would have: 1 1 1 1 1 1 1 0 0 0 0 1 1 0 0 0 0 1 1 0 0 0 0 1 1 1 1 1 1 1 I'm new to programming ...

How much risk is exposing all the sources to a third party?

I've been arguing with a co-worker about how necessary it is to wipe or destroy the hard disks that were used for storing the sources and are replaced with bigger ones or discarded. His point is that no piece of source code exposed to a third party gives that party any competitive advantage. My point is that it only takes ten minutes to...

Are there any cases when I would want to use an explicit stack over recursion?

Are there any cases when I would want to use an explicit stack data-structure in my algorithms, as opposed to doing recursion (which uses the call stack)? Is there any benefit to doing it one way over the other? I would think using the explicit data-structure would be more performant because it doesn't require the method calls but then...

Storing tasks in the database

I am working on a certain application. Its basic structure is as follows: a database a web interface to control the whole system a number of client applications on remote machines The clients poll the database at regular intervals, to check if there are any tasks to perform. A task is: A formal name of the task (a string), for exam...

What statistics can be maintained for a set of numerical data without iterating?

Update Just for future reference, I'm going to list all of the statistics that I'm aware of that can be maintained in a rolling collection, recalculated as an O(1) operation on every addition/removal (this is really how I should've worded the question from the beginning): Obvious Count Sum Mean Max* Min* Median** Less Obvious Var...

Code Golf: Musical Notes

The challenge The shortest code by character count, that will output musical notation based on user input. Input will be composed of a series of letters and numbers - letters will represent the name of the note and the number will represent the length of the note. A note is made of 4 vertical columns. The note's head will be a capital...

Design to distribute work when generating task oriented input for legacy dos application?

I'm attempting to automate a really old dos application. I've decided the best way to do this is via input redirection. The legacy app (menu driven) has many tasks within tasks with branching logic. In order to easily understand and reuse the input for these tasks, I'd like to break them into bit size pieces. Since I'll need to start a f...

Find commits less than N characters to help spot lazy developers

Is it possible in any of the modern SCMs to grab a complete list of commits, their revision numbers and the user that did it, when given a specific character count? I'd like to find out which -- if any -- of the developers are letting the side down with useless commits. Disclamer: I understand that short commit messages can sometimes a...

Challenges when Designing Large Websites?

Possible Duplicate: What should a developer know before building a public web site? What are the challenges that are commonly encountered when designing and implementing a large site like Stack Overflow? ...

Find if an angle is within X degrees from another

I need an algorithm to figure out if one angle is within a certain amount of degrees from another angle. My first thought was (a-x < b) && (a+x > b), but it fails when it has to work with angles that wrap around from -179 to 180. In the diagram above, the region (green) that the angle must be between wraps between the negative and po...

changed object state after behavior that used the state

I want to give my previous question a second chance since I think I have chosen a bad example. The question is how I should deal with situations where an object still can change after I have used it to do something and the new state is relevant for what is being done. Example in pseudo-code: class Book method 'addChapter': adds a ...

Developing Games - How are things that take more than one game loop performed?

I'm using C#, but this is applicable to developing a game in any language. Most games use a 'game loop', which would look something like this: while (game is running) { UpdateEnvironment(); DrawEnvironment(); } I'm struggling to understand how things which would take more than one game loop fit into the equation. For example, mak...