language-agnostic

What does refactoring mean to you?

Hi, bit of a subjective question but - I'm not looking for a definition, I'm more interested in what it means to you? What does refactoring mean to you? ...

What is a Type?

A newb question /+: ... In programming, we come across the word Type frequently enough. What should it be meant to convey, and when should it not be used? ...

Is there a language with object-based access levels?

A common misconception about access level in Java, C#, C++ and PHP is that it applies to objects rather than classes. That is, that (say) an object of class X can't see another X's private members. In fact, of course, access level is class-based and one X object can effortlessly refer to the private members of another. Does there exis...

When to use private members - when to pass as function/method parameter

I often found myself when writing a new class that inside a class I pass a parameter inside of many private methods. On the other side I also create sometime private members and just use them in one method. So my question is "After which rules do you create a private member and when you don't and pass the variable from private method to...

Function name for creating something if it's not there yet

From time to time I write a function that just creates something if it's not there yet and otherwise does nothing. Names like CreateFooIfNecessary() or EnsureThereIsAFoo() do work but they feel a bit clumsy. One could also say GetFoo() but that name doesn't really imply that foo may be created first and it only works if the function r...

Smallest Chess Playing Program

I was wondering if anyone knew of a "World's Smallest Chess Program". By this I mean a text based program that can play a game of chess following all the rules (castling, en passent, underpromotion, game ends with mate(stale), draw by repetition or insufficent material) in the least amount of code. I found some forums on this when I ch...

Why is the heap (as in where we put objects) called that?

Possible Duplicate: What is the origin of the term heap for the free store? Why is the heap called the heap? I mean the bit of memory which we dynamically allocate bits of. ...

What is tail-recursion elimination?

Steve Yegge mentioned it in a blog post and I have no idea what it means, could someone fill me in? Is it the same thing as tail call optimization? ...

Best language for a personal code library?

I'd like to begin a personal code library to contain all the small utility functions I use on a daily basis but can't find elsewhere on the 'net (I work in a specialized field). In my work, I switch pretty often between different products, so I want something flexible enough that I won't need to recode it over and over again. My paramet...

Language Evaluation question: Eager Vs. Lazy

I was reading Shriram's PLAI and this I got stuck in these questions: Can you prove that the eager and lazy regimes will always produce the same answer? (Shriram asks to look at the language he developed but is there another way to prove this and how?) Will eager evaluation always reduce with fewer steps? Here is the Code of Substitu...

Least Squares solution to simultaneous equations

I am trying to fit a transformation from one set of coordinates to another. x' = R + Px + Qy y' = S - Qx + Py Where P,Q,R,S are constants, P = scale*cos(rotation). Q=scale*sin(rotation) There is a well known 'by hand' formula for fitting P,Q,R,S to a set of corresponding points. But I need to have an error estimate on the fit - s...

Smaller SpreadsheetML files through Excel 2007

I have a SpreadsheetML file that I am generating server-side. Such files are rather large, in contrast to Excel 2007 files, which make use of zip. So, I am wondering if there is a simple way, without use of automation, to create an a zip file with that file inside...which Excel 2007 must know how to open. I do know that Excel 2007 kno...

Monty Hall Problem

Through trying to explain the Monty Hall problem to a friend during class yesterday, we ended up coding it in Python to prove that if you always swap, you will win 2/3 times. We came up with this: import random as r #iterations = int(raw_input("How many iterations? >> ")) iterations = 100000 doors = ["goat", "goat", "car"] wins = 0.0 ...

Algorithm for linear pattern matching?

I have a linear list of zeros and ones and I need to match multiple simple patterns and find the first occurrence. For example, I might need to find 0001101101, 01010100100, OR 10100100010 within a list of length 8 million. I only need to find the first occurrence of either, and then return the index at which it occurs. However, doing...

Finding points on a line with a given distance

I have a question i know a line i just know its slope(m) and a point on it A(x,y) How can i calculate the points(actually two of them) on this line with a distance(d) from point A ??? I m asking this for finding intensity of pixels on a line that pass through A(x,y) with a distance .Distance in this case will be number of pixels. ...

Improve proficiency in programming

How can I increase my proficiency in programming? I have a grasp of the basics of C#, but don't feel too confident about my ability. ...

How much weight should the ability to write code in an interview carry?

Possible Duplicate: Any reason to not ask an interviewee to write code? IMO, Syntax can be learnt. At the same time, it helps if a candidate knows how to use the language efficiently, and this would probably reflect in the resume if the candidate is experienced. When looking at a candidate for a developer profile, I look first ...

Huge area texture?

This is a very general question that's not related to a specific language. I'm having this array of int's: int[100][100] map; This contains just tile numbers, and is rendered as 256x256 tiles. So it's basically just a tile map or whatever it should be called. Thing is I want to be able to write anything to the map, anywhere, and it sh...

Make SVN directory locally read-only

Two teams are working on two different projects "A" and "B". Some files are common to both projects and are stored in a directory "Common". When a release date of project A approaches, the team of project A does not want to be bothered by modifications to "Common" made by team "B". Most people like branches for such issues but i don't...

Best way to define your web applicaion URLs

I've always found that defining URLs for other "pages" in a Web Application seems either clumbsy and fragile or bloated. E.g. you have an application that manages customers, sales, prospects and thus has the following "pages". customerlist viewcustomer editcustomer addcustomer viewcontact editcontact addcontact prospect (x3? x4?) sale...