language-agnostic

Limit the confusion caused by undefined-behavior?

As I understand from my reading, undefined-behavior is the result of leaving the compiler with several non-identical alternatives at compile time. However, wouldn't that mean that if one were to follow strict coding practice (like putting each assignment and each equality in a separate statement, proper debugging and commenting) then it...

What language should I learn next ?

Possible Duplicate: Which Programming Language Should I Learn? So far, I have played with PHP, Javascript, C/C++, SQL, ASM and VHDL. My goal being to learn new paradigms, language constructs, etc., what language should I learn next ? A functional language like Lisp perhaps ? ...

Minimum area quadrilateral algorithm

There are a few algorithms around for finding the minimal bounding rectangle containing a given (convex) polygon. Does anybody know about an algorithm for finding the minimal-area bounding quadrilateral (any quadrilateral, not just rectangles)? I've searched the internet for several hours now, but while I found a few theoretical papers...

What's the most appropriate way to expose lists inside a class?

Imagine the following model: A Table has many Rows A Row has many Cells What would be the preferable interface to deal with these classes in a "object oriented way"? 1 - Provide access to the properties rows / cells (Not necessarily exposing the underlying data structures, but creating for example a class RowCollection...) my_table...

What's the opposite of 'clone'?

I have a class that implements ICloneable. I need it to have a backup of an entity, so when the user clicks cancel, etc., I have all values asides. I want to create in the cloneable class another function, that clones in, i.e. receives another class of the same type and uses the same clone but to the opposite direction while the other m...

Extract the fields of a C struct

I often have to write code in other languages that interact with C structs. Most typically this involves writing Python code with the struct or ctypes modules. So I'll have a .h file full of struct definitions, and I have to manually read through them and duplicate those definitions in my Python code. This is time consuming and error-...

Pseudocode implementation of Excel's TDIST function

I've been doing some research on statistical significance, and I've learned a lot but seem to have hit a wall when it comes to calculating P values. I feel like I'm about 95% of the way there; it's just that everything I read on calculating P values references a table rather than offering a programmatic solution. It seems that Excel's ...

theory of computers and programming (HELP)

I am a student who has done a course in Haskell and I am currently doing object oriented programming using Java. Haskell was great and I did do really well and I am getting on fine with the Java. But I feel that I need to learn more about the underlying theories behind computing and programming in order to really become a good programm...

Using the actor model in web applications

I'm looking to create a web application that's very modular, and was pointed to the actor model by a friend. After investigating it a little, I realised that developing just the back-end using actors wasn't a bad idea at all, but I also came to the conclusion that having client-side actors would be useful: rather than create pages which ...

Can I be good developer?

Hello guys, I am 31 years old. I graduated with a degree in computer science at 25 years old, and until now I haven't worked in my major as a software developer, actually this issue makes me somewhat sad. My current career is as a software tester, and (in my point of view) I consider that this career has no future. So can I change my car...

Is this a safe version of double-checked locking?

Here's an idea I just came up with for a safe, efficient way of handling Singleton synchronization issues. It's basically double-checked locking, but with a twist that involves thread-local storage. In Java/C#/D-style pseudocode, assuming __thread denotes thread-local storage for static variables: class MySingleton { __thread stat...

What real world uses of the "Stack" object (.Net) have you used.

We have all read about or heard about the stack class, but many of us have probably never found a reason to use the LIFO object. I am curious to hear of real world solutions that used this object and why. http://msdn.microsoft.com/en-us/library/system.collections.stack.aspx I recently saw an example where a programmer used a stack to ...

I have a function called by many other functions. Is there an easy way to find where any of it's calling functions (or their calling functions) are called?

I have a function which is called explicitly by 4 other functions in my code base. Then in turn each of these functions is called by at least 10 other functions throughout my code. I know that I could, by hand, trace one of these function calls to the main function of my program (which has 30 function calls) but it seems like this woul...

How to count each digit in a range of integers?

Imagine you sell those metallic digits used to number houses, locker doors, hotel rooms, etc. You need to find how many of each digit to ship when your customer needs to number doors/houses: 1 to 100 51 to 300 1 to 2,000 with zeros to the left The obvious solution is to do a loop from the first to the last number, convert the counter...

Similar language features to compare with Perl and Ruby __END__

Background Perl and Ruby have the __END__ and __DATA__ tokens that allow embedding of arbitrary data directly inside a source code file. Although this practice may not be well-advised for general-purpose programming use, it is pretty useful for "one-off" quick scripts for routine tasks. Question: What other programming languages sup...

Asynchronous loading / error handling

Let's say that I have a bunch of objects (thumbnails in a matrix for example) and I need to load some data files for all of those over the network (HTTP). So each thumbnail has the thumbnail image itself and an xml file for instance. There's a number of things that can go wrong from IO errors to bad URLs to badly formatted XML and so on...

Help with bitwise expression

I want a one line code to check whether a given integer is of form 2i - 2j or NOT. (using bitwise operators) I tried to do it but I don't seem to be getting the answer. Can anyone please help me with this? It's kinda urgent... :-| Thanks. ...

Are there any practical alternatives to threads?

While reading up on SQLite, I stumbled upon this quote in the FAQ: "Threads are evil. Avoid them." I have a lot of respect for SQLite, so I couldn't just disregard this. I got thinking what else I could, according to the "avoid them" policy, use instead in order to parallelize my tasks. As an example, the application I'm currently worki...

Where does input validation belong in an MVC application?

I have a MVC application that receives an input from a form. This is a login form so the only validation that is necessary is to check whether the input is non-empty. Right now before I pass it to the model I validate it in the controller. Is this a best practice or not? Does it belong to the model? ...

Drawing two-dimensional point-graphs

I've got a list of objects (probably not more than 100), where each object has a distance to all the other objects. This distance is merely the added absolute difference between all the fields these objects share. There might be few (one) or many (dozens) of fields, thus the dimensionality of the distance is not important. I'd like to d...