language-agnostic

Client/Server are always separated! Or are they?

Its amazing how many programmers in the greater community of programmers ask questions like "How do I do an EXTJS backend?" or "How do I integrate jQuery with Java?", not understanding the distinction between the client and the server. Then I got to thinking, are there frameworks where the server actually sends JS or something to the cl...

Circle-circle intersection points

How do I calculate the intersection points of two circles. I would expect there to be either two, one or no intersection points in all cases. I have the x and y coordinates of the centre-point, and the radius for each circle. An answer in python would be preferred, but any working algorithm would be acceptable. ...

Code Examples For Programming Languages

When you are designing a new programming language, or comparing existing programming languages, what types of code examples should you write? They should: emphasize the important features of the language(s) take considerations into important/common features allow learning by examples. Also, list some simple algorithms that worth to b...

How is it possible for Boruvka's algorithm's complexity to be O(E*logV)?

1 Begin with a connected graph G containing edges of distinct weights, and an empty set of edges T 2 While the vertices of G connected by T are disjoint: 3 Begin with an empty set of edges E 4 For each component: 5 Begin with an empty set of edges S 6 For each vertex in the component: 7 Add the cheapest edge from...

What is the most important properties of programming languages for you?

For me it is : strong type Wikipedia: "strong typing" implies that the programming language places severe restrictions on the intermixing that is permitted to occur, preventing the compiling or running of source code which uses data in what is considered to be an invalid way Why it is important? Because I love compile error much m...

Does a copy constructor/operator/function need to make clear which copy variant it implements?

Yesterday I asked a question about copying objects in C#, and most answers focussed on the difference between deep copy and shallow copy, and the fact that it should be made clear which of both copy variants a given copy constructor (or operator, or function) implements. I find this odd. I wrote a lot of software in C++, a language that...

When is a shallow copy desirable (instead of a deep copy)?

Can someone give an example of a situation where a shallow copy is needed? Note that in some situations, shallow copy and deep copy are the same. This can happen when the object has no ownership over any of its subvariables; that is, all subvariables are aggregated. I'd like to see examples where the an object is composed from variables...

Does a deep copy operation recursively copies subvariables which it doesn't own?

Given an object that has a variable which it doesn't own; that is, the variable is composed by aggregation instead of composition. Will a deep copy operation copy the variable or only the link to it? ...

Why use inheritance at all?

I know the question has been discussed before, but it seems always under the assumption that inheritance is at least sometimes preferable to composition. I'd like to challenge that assumption in hopes of gaining some understanding. My question is this: Since you can accomplish anything with object composition that you can with classical...

How can this circular, bidirectional dependency be resolved?

I have a RequestHandler class and a RequestListener class. A RequestHandler creates a RequestListener and passes it a reference to itself. The RequestListener in turn calls methods on the RequestHandler to handle requests of different types when they are processed (eg handleTypeARequest(), handleTypeBRequest() and so on). Unfortunately, ...

What are pros and cons of using binding instead of template language?

Hello, all, I would like to know what are pros and cons of using JSON or XML binding versus using template languages like Velocity or FreeMaker? What approach is certainly preferable in what situations? ...

Code Golf: The Unisex Restroom Simulation

Background The unisex restroom problem is a classical synchronization problem in computer science. The general class of problems that this simulates is as follows: If you have k types of threads that need to execute tasks using n shared resources, and at any time only one thread type may be using the resources, then it's a generalizati...

What is the syntax getSomeValues()[0] called?

Possible Duplicate: Access array element from function call in php Sorry if this has been asked before, but due to the symbols I can't search Google or Stack Overflow for it. If it's been asked before, feel free to close it as a dupe. In some languages, if a function returns an array, then as opposed to storing the array in a...

How to Manage a dataset together with an application?

The application's code and configuration files are maintained in a code repository. But sometimes, as a part of the project, I also have a some data (which in some cases can be >100MB, >1GB or so), which is stored in a database. Git does a nice job in handling the code and its changes, but how can the development team easily share the da...

Code Golf: Who has the best poker hand?

I love challenges like this, I'll hopefully submit my answer soon. Which player has the best 7 card hand? Given an unordered list of 9 cards (separated by a space), work out which player has the best poker hand. Here is a list of poker hand rankings. Example input: 2C 5H AS KS 2D 4D QD KH 3S (ie: [[2C 5H] [AS KS] [2D 4D QD KH 3S]]) ...

Code Golf: Build Me an Arc

Challenge The shortest program by character count that accepts standard input of the form X-Y R, with the following guarantees: R is a non-negative decimal number less than or equal to 8 X and Y are non-negative angles given in decimal as multiples of 45 (0, 45, 90, 135, etc.) X is less than Y Y is not 360 if X is 0 And produces on ...

Browser script to automatically copy a "locked" file from a user's system (Windows)

Hi, For an automated web-backup solution we're thinking of, how can we access and copy a "locked" file from a user's system onto our webserver? This is of course with the user's permissions. Just seeking code that demonstrate this. Added: I know where the file is located, I do NOT want to prompt the user to select the file everytime. ...

What's the difference between closures and traditional classes?

What are the pros and cons of closures against classes, and viceversa? Edit: As user Faisal put it, both closures and classes can be used to "describe an entity that maintains and manipulates state", so closures provide a way to program in an object oriented way using functional languages. Like most programmers, I'm more familiar with ...

How long will a web based project development take?

I am about to embark on an epic journey of Web development. Epic for myself, that is. The biggest and most difficult one yet. The rough thing about this project is the time involved. My boss wants me to put this project on a schedule, but I just have no Idea how to do this. So, could someone give me an advice: how should I calculate the...

When should you use public static methods

There are a lot of people out there against the use of "public/private" static methods. I have search around,with no luck, and tried to find anyone that advocates good use of static methods. Assuming the methods will always be Cohesive where are the acceptable areas to use public static methods? Do these methods vary between Java an...