language-agnostic

Code Golf: recognize ascii art boxes

Came up with this a while ago while doing some data structure work, though it'd make a good code golf: Given a two dimensional array of characters containing ascii art rectangles, produce a list of coordinates and sizes for the rectangles. Any trivially convertable input or output format is fine (eg: char**, list of strings, lines on ...

PCA: What's wrong with this algorithm?

Can someone please either confirm or correct this Wikipedia algorithm for computing the first principal component? I want a simple implementation of PCA in D, which doesn't have any existing libraries for PCA AFAIK. I've tried implementing this, and it doesn't seem like my results on simple examples match stuff I get from R or Octave. ...

DAL: Is it ok to incapsulate several data sources access in one module?

Application I develop requires several data sources (2 RDBMS and one file storage) to operate. I'm going to incapsulate datasources with DAL library & Business Logic layer. Would you personally create several DAL libraries (each per data source) and cooperate several DAL instances in Business Logic Layer or create monolith DAL library,...

Gettting rid of old thinking patterns when moving to a new language/framework/platform

I have been programming in C then C++ then Java and now doing C#. Here's the embarrassing admission: My C# is being written like I am writing C++ !!! I am having trouble completely shaking the thinking that has been embedded in my mind for 10 years and I need to know how others have solved the same problem. ...

Conditional Random Fields -- How Do They Work?

I've read the papers linked to in this question. I half get it. Can someone help me figure out how to implement it? I assume that features are generated by some heuristic. Using a POS-tagger as an example; Maybe looking at training data shows that 'bird' is tagged with NOUN in all cases, so feature f1(z_(n-1),z_n,X,n) is generated as (...

Appropriate way to structure a database table? (empty columns vs. multiple tables)

Let's say we have a object called a Widget, for which we can construct a database table. Now, let's say we have two sets of additional detail to describe widgets. Each set of data is available at a separate time. So, let's say our widgets have three phases to their life-cycle... In phase 1, we simply have a widget with a name and a des...

Abstract Factory, Factory Method, Builder

Hello: It may seem as if this is question is a dupe, but please bear with me - I promise I've read the related posts (and the GOF book). After everything I've read, I still don't have it clear when to use an Abstract Factory, a Factory Method, or a Builder. I believe it will finally sink in after I see a simple example of a problem wh...

Should I care that passing in a class representation of an XML settings file violates the law of demeter?

I'm using a tool to automatically generate a class representation of a hierarchically organized XML file. The XML file is a settings file my app need to be able to access (read-only). If I pass in the top-level node (e.g., AppSettings) to a class that needs to access one or more settings, I can easily end up with code that looks somethi...

efficient way to find matches against two strings

I need to find all equal substrings against two strings. I've tried to use suffix tree to lookup substrings and it works fast, but too memory consuming (inappropriate for my task). Any other ideas? ...

How can I model this usage scenario?

I want to create a fairly simple mathematical model that describes usage patterns and performance trade-offs in a system. The system behaves as follows: clients periodically issue multi-cast packets to a network of hosts any host that receives the packet, responds with a unicast answer directly the initiating host caches the responses...

Who is doing investigations into measurement of functionality and usability?

I have developed some ideas about system construction, that are a little different to mainstream development. I am developing a demonstration/proof of concept project. So far, I have found that useful information about the completeness of a system can be gathered by taking an indirect view of the development. This indirect view is ba...

Calcuate x/y point that 2 moving balls will collide

Im trying to make what is (essentially) a simple pool game, and would like to be able to predict where a shot will go once it hits another ball. The first part is, I believe, to calculate if the cueball will hit anything, and if it does, where it collides. I can work out collision points for a line and a ball, but not 2 balls. So given...

User-Contributed Code Security

I've seen some websites that can run code from the browser, and the code is evaluated on the server. What is the security best-practice for applications that run user-contributed code? Besides of accessing and changing the server's sensitive information. (for example, using a Python with a stripped-down version of the standard library) ...

How do you organize your code?

I'm not referring to the indentation or the directory structure but the actual file itself. Do you arrange your members and methods alphabetically? Maybe in their order of use or order of complex logic (either ascending or descending)? Is there any rhyme to your madness? I'm thinking about making the switch to alphabetically but some...

Designing the schema for an inventory system...should I calculate quantity or keep track of it?

I'm doing an inventory for a game, rather like a FF-style game. I have two design in mind, and wonder which is better Keep track of quantity as a field; the schema would be: item ( <item_id>, <character_id>, quantity ). If a character equip an item, or remove an item from his inventory, I would need to make sure the quantity field is c...

Naming of classes providing the complete implementation of an interface, but which are designed to be extended / used as mixins.

If you write an interface with a lot of methods, say IPerson, and you expect a lot of different implementations of it, it is quite common practice to provide an abstract class AbstractPerson which implements the bulk of the functionality. Normally AbstractPerson is abstract, since you usually leave some key functionality unimplemented. ...

Generation of uniformly distributed random noise

I've been working on generating Perlin noise for a map generator of mine. The problem I've run into is that the random noise is not distributed normally, and is more likely a normal distribution of kinds. Given two integers X and Y, and a seed value, I do the following: Use MurmurHash2 to generate a random number (-1,1). This is unifo...

bjarne stroustrup about another language?

Has Bjarne Stroustrup made a comment about a language that isnt C or C++(0x)? I saw his comments about C++ CLI but i havent seen him mention anything about another language. Such as D, python, javascript, OCaml, haskel, etc. If so do you have a link? (note: omg bjarne-stroustrup has his own tag!) ...

What are some highly-regarded books on (modern or historic) programming language design?

I greatly enjoyed Douglas Crockford's recent lecture series, particularly the talk which covered the history of programming languages. I'd like to learn about this subject in more detail. Consider this question language agnostic. I'm not interested in books that teach programming. I'm interested in books which discuss decisions made dur...

Who's responsible for the next View?

In an archetypical MVC architectur, where does the logic go, that determines which view to show next? The assumption is some kind of app with several views (windows) that may or may not be visible at different times, depending on user actions. For instance, sometimes the application may need the user to fill out a form with additional ...