language-agnostic

Captcha validation logic?

I need to write a captcha service for the integration software I am working on. After some thinking I think I don’t fully understand how captcha works tehnologically (I do understand how it works functionally) and therefore haven’t been able to make some design decisions. A few things that bother me are: Should I keep a session for eac...

Implementation of Liquid State Machines

Does anybody know of an (open source) implementation of Liquid State Machines? ...

Scannerless Parser Generators

Prologue: Although the set of languages recognized by parsers (context-free grammars) is strictly larger than the one of scanners (regular grammars), most parser generators need a scanner. (Please don't try to explain the reasons behind it, I know them quite well). I've seen parsers, that do not require a scanner like Elkhound (optio...

Are the implementation details of declarative languages inherently imperative

I'm reading 'Functional Programming' by Tomas Petricek & Jon Skeet and I understand the difference between declarative & imperative programming. What I was wondering is how are the primitive operators & functions implemented, are declarative languages constructed from imperative operators & functions. Cheers AWC ...

Testing clients for public web services

What are approaches to test custom clients for public web services? Today there are many online services which provide an API. There is a boom of little apps using those APIs. Examples: desktop/mobile clients for social networks and blogging platforms, document storage and processing centers, cloud databases, real-time data streams, GIS...

translate by replacing words inside existing text

What are common approaches for translating certain words (or expressions) inside a given text, when the text must be reconstructed (with punctuations and everythin.) ? The translation comes from a lookup table, and covers words, collocations, and emoticons like L33t, CUL8R, :-), etc. Simple string search-and-replace is not enough since...

Haskell pattern matching - what is it?

What is pattern matching in Haskell and how is it related to guarded equations? I've tried looking for a simple explanation, but I haven't found one. EDIT: Someone tagged as homework. I don't go to school anymore, I'm just learning Haskell and I'm trying to understand this concept. Pure out of interest. ...

What is the name for a number which is the same in both big- and little-endian byte order?

One of my old classmates just asked me this and I'm at a total loss. Google gave me a lot of definitions of endian-ness, but not the term for this special case. IS there even a term for this? ...

Should Java Have an "is null" construct?

To check against null we generally do if (object == null). Instead, would it be nicer to have if (object is null) { // Do something } Or if (object is not null) { // Do something } It would be more intuitive, i.e. reads more like english. EDIT : I got lot of answers. Thanks for the people who up voted, although down votes w...

Is it possible to add transparent blocks in a DXF-File?

Is it possible to add transparent blocks in a DXF-File? I browsed through the DXF-Reference without finding much. I am currently using the OpenCascade Data Exchange framework XDE, in C++ ...

With IEEE-754, 0 < ABS(const) < 1, is (x / const) * const guaranteed to return distinct results for distinct values of X?

Assume I do this operation: (X / const) * const with double-precision arguments as defined by IEEE 754-2008, division first, then multiplication. const is in the range 0 < ABS(const) < 1. Assuming that the operation succeeds (no overflows occur), are distinct arguments of X to this operation guaranteed to return distinct results? I...

Is this an abuse of try/finally?

Given that multiple return statements are acceptable (I disagree, but let us digress), I'm looking for a more acceptable way to achieve the following behavior: Option A: multiple returns, repeated code block public bool myMethod() { /* ... code ... */ if(thisCondition) { /* ... code that must run at end of method ... *...

Automatic generation of immutable class and matching builder class

What tools/libraries exist that will take a struct and automatically generate an immutable wrapper and also a "builder" class for incrementally building new instances? Example input: struct Foo { public int apples; public int oranges; public Foo Clone() {return (Foo) base.MemberwiseClone();} } Example output: public clas...

Clever data structure to represent layered circle.

I'm making a game and I need to represent a "layered" circle in some clever datastructure. A circle can have any number of layers. Each layer has a number of "slices", they can be of different lengths and pieces can be missing. The innermost layer is always a full circle. Each segment has a color, multiple segments with the same color c...

Protection of code from its own developers

Perhaps the most obvious way of protecting a company's intellectual property from its own developers seems to be an NDA - Non Disclosure Agreement. Effectiveness of this approach may vary, depending on many factors, and sometimes or somewhere it may not work as expected. What other approaches, apart from this purely legal one, exist for...

Computing Algorithm Complexity - Confusion

I have the following code snippet: sum = 0; for (i = 0; i < n; i++) for (j = 0; j < i; j++) sum++; The complexity would be O(n^2), but if I want to dig a little more for the internal loop complexity then would it be (n (n-1))/2 or (n-1)!? ...

File name? Path name? Base name? Naming standard for pieces of a path.

I keep getting myself in knots when I am manipulation paths and file names, because I don't have a common naming system that I use. I need to come up with a naming standard and stick to it, and I would like to be clear and consistent with others, so I am opening up to learn the canonical answers. Consider this toy problem: (Windows exa...

Should I instantiate a collection or inherit from collection?

I've asked myself this question a number of times when creating classes, particularly those involving collections, but I've never come up with a satisfactory answer. It's a OOP design question. For example, in a checkbook register program say I have a class of BankAccount. BankAccounts contain data involving the Name of the account, the...

When a method has too many parameters?

When debugging some web-service client code today (in Java, with jax-ws) I ran across a web-service method with the mind-blowing amount of 97 parameters! I had to create a test case that calls this method, and I noticed several things: code assist/hover doesn't scale well. I am using Eclipse, and the tooltip over the method is as wide...

How do you cleanly separate code for backwards compatibility from the main code?

I'm interested in what strategies people have come up with for separating all the crufty logic that's necessary to maintain backwards compatibility from the main code of an application. In other words, strategies that let you come closer to having your code look as if there were no backwards compatibility concerns except for separate iso...