language-agnostic

Is there any use for a private constant, that is not static?

Is there any reason to have a private constant, that is not static? Are there any situations that you would need a non-static private const? Would it make sense if constants where static by default? I use ActionScript3 and some Java, but I think this is a broader OOP question. ...

How to learn in and out about a control (Such as datagridview, textbox)?

I've been in the software development industry for more than 6 years and I still feel that I dont have 100% knowledge about the features of the controls (it may be any language) I've used. I always try to read the documentation available about that control everywhere but I still find new things about it every now and then. I always wond...

How to handle maximum recursion depth?

Many languages (such as python) have a set maximum recursion depth. I realize you can change that depth, or simply not write recursive functions altogether, but if you do write a recursive function and you hit that maximum recursion depth, how would you prepare for and handle that? ...

Most popular substrings

Hi, I'm trying to parse a large number of short strings into some logical parts. It seems like an interesting problem that someone could've already solved, but I cannot find any papers / solutions (or maybe I'm trying wrong keywords). The strings are have 2-5 parts. If I substitute each word for a letter saying which "part" / "section" ...

If block vs Switch-Case block

Generally is there a performance difference between using an if block with many else ifs compared to a switch case block? Do some languages or style conventions prefer one over the other? Specifically I am curious about Matlab, C, and C++ ...

solving Project Euler #305

Problem # 305 Let's call S the (infinite) string that is made by concatenating the consecutive positive integers (starting from 1) written down in base 10. Thus, S = 1234567891011121314151617181920212223242... It's easy to see that any number will show up an infinite number of times in S. Let's call f(n...

What programming languages will have highest chances to exist if World War 3 happens?

Ok, this might sound like a weird question at first but ... believe me, this is not a stupid one. If World War 3 happens, will Microsoft have any chance to sell Windows? Will they make .NET source open and free? Will C# die? I think Java will have best chance to survive but I want to hear your opinions. Why do I ask this question? Well...

How much documentation do we need and when should we write it?

This question is inspired by the following sources: Clean code by Robert C. Martin Agile Principles, Patterns, and Practices in C# by Robert C. Martin and Micah Martin What is software design? by Jack W. Reeves My current project (where we should comment everything in the code) Mr. Reeves states in his paper that the code is the desi...

What is the best version control practice for this situation?

I'm taking a programming course. I did my first assignment in an HG repo called Assignment1. Now the second assignment is out, and it appears that I'll be able to use large chunks of code from Assignment1 as a base for Assignment2. A few options I see are: Copy and paste the relevant code; create a new repo for Assignment2 Continue c...

Algorithm for permutations of operators and operands

I came across this question on an interview website - We are given 4 numbers say n1, n2, n3, n4. We can place them in any order and we can use the mathematical operators +, -, *, / in between them to have the final result as 24. Write an algorithm for this - it will take 4 numbers and return false or true whether final result 24 is p...

Storing graphs in fully-normalized relational databases

I've nearly killed myself, multiple times, trying to find the perfect, flexible schema for storing many different types of objects with a wide variety of links between them in a relational database. But models such as EAV and things like polymorphic relationships just aren't true to relational databases. After learning about NoSQL graph...

How do I texture map onto a curved surface?

Hello, I'm attempting to create a 3d game using OpenGL. I have a very basic world and am now working on a character. I want to map a texture to the head which will be oval shaped. How do I do the mapping? I know how to map to flat surface. I'm wondering if the normals can be used to help but I've never done this before and when I se...

Looking for a good design pattern for this set of objects.

I originally asked this question on programmers.stackexchange.com, because I figured the answers would be too subjective for stackoverflow. However, in the comments Muad'Dib pointed this out: this would probably be a better fit for StackOverflow ... This is a direct programming problem-related question and discusses programming so...

Why do different operators have different associativity?

I've got to the section on operators in The Ruby Programming Language, and it's made me think about operator associativity. This isn't a Ruby question by the way - it applies to all languages. I know that operators have to associate one way or the other, and I can see why in some cases one way would be preferable to the other, but I'm s...

Generating samples from the logistic distribution

I am working on some statistical code and exploring different ways of creating samples from random distributions - starting from a random number generator that generates uniform floating point values from 0 to 1 I know it is possible to generate approximate samples from a normal distribution by adding together a sufficiently large numbe...

Understanding "randomness"

I cant get my head around this, which is more random? rand() OR rand() * rand() I´m finding it a real brain teaser, could you help me out? Thanks in advance! EDIT: Intuitively I know that the Mathematical answer will be that they are equally random but I can't help but think that if you "run the random number algorithm" twice wh...

How to start implementing a running text algorithm?

I have a dialog implementation that receives a length of text from the user and I'd like to format it over multiple lines in a visually pleasing way. The user can include their own line breaks in the string which I would also like to account for. Is anyone aware of pseudocode or something else publicly available I could use as a referen...

what are the consequences of having unused functions

Hi, I'm wondering what / if any consequences there are in having unused functions in code? If you hunt down and remove all unused functions and variables would there be any percievable improvement in performance? Or is it just good practice to remove unused functions and variables would? ...

Filter Eclipse's "Open Call Hierarchy" to just my company/project

One of my favorite features of Eclipse is the ability to open a caller/callee hierarchy of a method. By default, the view shows calls to/from classes that are outside of my codebase... which I don't usually care about. There is an option to filter out specific package names I don't want, but I need to do the opposite... to filter out a...

Algebraic data types outside of functional languages?

Mostly out of curiosity: Which languages that are not solely functional (I'm also interested in multi-paradigm languages - I know that Ocaml and F# are ML dialects with OO added, so they inherit the algebraic data types from ML) have algebraic data types (or something similar) and pattern matching? They can be kind-of emulated using enu...