language-agnostic

.NET should I store references or values?

I need to store in my object which values have already been handlerd, I am doubting what would cost more performance, should I create an array that stores: The instance references (they are not structs, only ref classes) The hashcode of the items The name of the name of the properties (string) that have been handled Update my aim is ...

Any statistics out there on commonly mistyped keys?

I need to find a list of commonly mistyped keys on a keyboard for a project I am working on. Basically I need to know what key a user is trying to press and what key they are actually pressing and a comparative measure of how often this happens. By "comparative measure" I mean that I would like to be able to say that knowing a user m...

Diagnosing pathological behavior of a piece of cluster software

I'm using a kind of load balancer over a small cluster that is able to achieve >2000rps on zero-duration requests (t.i. ones that are immediately satisfied by the worker nodes). But as soon as the requests stop being zero-duration and start taking even 1ms, performance immediately drops >10x. The data being transfered in both directions...

What does "Type" mean, physically?

I have heard a lot about "type system", "strongly typed language" and so on. Currently I am working on some .NET COM interop problem, which addressed "marshaling" a lot. And AFAIK, marshaling is quite about conversion between .NET types and COM types. In many scenarios such as programming language, when talking about types, we are conce...

Scripting language shells?

Are there any software packages or projects that provide the scripting language shells? I know there's csh for C programmers although not in a sense that it's primarily for programming, but for navigation and system administration. I was wondering if there is something inverted for this purpose? I.e. user logs into a shell that's primari...

Binary trees, construct a tree based on preorder

Hello, constructing a tree given it's inorder is easy enough. But, let's say you are supposed to construct a tree based on it's preorder (+ + y z + * x y z for example). It's easy to see that + is the root, and how to continue in the left subtree from there. But.. how do you know when you are supposed to "switch" to the right subtree? ...

How to achieve Scalable code

How can one achieve scalable code. Better to frame the question as "What do you mean by scalability of code" and how to determine the extent to which code is scalable. Waiting for positive replies. Thanks in advance ...

boolean, english negation and simply getting rid of the boolean

Very often when you code you have a flag indicating two possibilities, like this: CACHING_AUTHORIZED CACHING_UNAUTHORIZED or CACHING_ON CACHING_OFF If you then use a boolean to store this, very often it just "reads weird": CACHING_ON = false; CACHING_OFF = true; or CACHING_ON = true; CACHING_OFF = false; One of the possibilit...

GUI: Decoupled view and design patterns for RIA

I made some GUI desktop applications on my first years of development, but my experience and practice have changed, so now I'd like to retake this subject with better knowledge. Most of my experience has been web since then. I've been reading about GUI Architectures, and several related questions here on S.O.. I know I'm still not in ...

Culling interior triangles

I have an array of thousands of quads; 4-sided 3D polygons. All I know are the coordinates of the quad corners. A subset of these quads define the closed outer shell of a 3D shape. The remaining quads are on the inside of this closed solid. How do I figure out which quads are part of the shell and which quads are part of the interior? ...

What encoding format is this?

I'm trying to edit a (slightly) proprietary format and within one of the files it will encode a connection string. I have a way to encode my own data with it, so I can reverse engineer it a bit. ABC123"/3 will encode to rijcmlqXxEeLA4tSspHg5XfWJiq4w== and AB120";2 encodes to rijcmlqiF3LjnFJnYfEi2WvcSoPSg== Is this a know...

How Do I Avoid using Running Totals in My Code?

I am learning programing and software design and Java in school right now. The class that is getting me mixed up is Software Design. We are using Word to run simple VB code to do simple programs. My instructor says I am losing cohesion by using running totals. I am having a hard time thinking of a way to avoid them. Here is an examp...

Sum of numbers making a sequence

While watching the rugby last night I was wondering if any scores were impossible given you can only score points in lots of 3, 5 or 7. It didn't take long to work out that any number greater than 4 is attainable. 5=5, 6=3+3, 7=7, 8=3+5, 9=3+3+3, 10=5+5 and so on. Extending on that idea for 5, 7 and 9 yields the following possible score...

How to keep code behind UI organized?

In my experience code behind UI can easily get ugly, and inorganized, e.g. long functions, lots of variables etc. How do you manage the code behind UI? ...

Code Golf: Frobenius Number

Write the shortest program that calculates the Frobenius number for a given set of positive numbers. The Frobenius number is the largest number that cannot be written as a sum of positive multiples of the numbers in the set. Example: For the set of the Chicken McNuggetTM sizes [6,9,20] the Frobenius number is 43, as there is no solution...

XOR of three values

What is the simplest way to do a three-way exclusive OR? In other words, I have three values, and I want a statement that evaluates to true IFF only one of the three values is true. So far, this is what I've come up with: ((a ^ b) && (a ^ c) && !(b && c)) || ((b ^ a) && (b ^ c) && !(a && c)) || ((c ^ a) && (c ^ b) && !(a && b)) Is th...

Is there any "multi-user-real-time" text editor ?

Hi I'm looking for application like spreadsheet on google docs, where lot of users from internet (or ethernet) can edit one document, and see changes from everybody in real time. I need this for putting some fixes or new variables to SMARTY template files, when another person is styling that file from another computer. It could be exce...

which web framework gives more functionality for free?

Hello there, I'm using codeigniter for a little time and I find it really good, but sometimes it's difficult to find pre-cooked examples on the web that will guide me on what I want to do...so my question is which web framework(independent of language) will offer more examples, better tutorials and more resources in general?thanks in adv...

Alternatives to OOP?

OOP is probably the most used programming paradigm in today's software design. My question is -- what other paradigm(s) can compete with it and can stand in the place of oop? To clarify that question, I'm not asking about what other paradigms there are. There are many of them and I'd like to know which one: Has been used in practice, n...

What's the use of metaprogramming?

I've read: Wikipedia Code Generation vs. Metaprogramming The art of Metaprogramming Metaprogramming at c2.com and I confess some confusion at the purpose behind metaprogramming/code generation. Does anyone have a concrete example of where they use metaprogramming/code generation? Even better would be an accompanying explanation of w...