language-agnostic

Postfix notation to expression tree

There are enough resources on how to convert an expression tree into postfix notation, and it's not that hard. But I have to parse a postfix expression into an expression tree. The expression is: A 2 ^ 2 A * B * - B 2 ^ + A B - / I don't really have a clue on how to interpret the expression. Does someone has a clue on how to proc...

Determining "Owner" of Text Edited by Multiple Users

You may have noticed that we now show an edit summary on Community Wiki posts: community wiki 220 revisions, 48 users I'd like to also show the user who "most owns" the final content displayed on the page, as a percentage of the remaining text: community wiki 220 revisions, 48 users kronoz 87% Yes, there could be top (n...

Have you ever bought a commercial implementation of a programming language for personal programming projects?

Commercial products are often a source of ideas and inspiration for open source projects. There are free and open source implementations of almost every programming language ever devised, and a lot of them are very good. For non-work related personal programming projects, have you ever bought an expensive commerical implementation of a ...

Arguments or parameters?

I often find myself confused with how the terms 'arguments' and 'parameters' are used. They seem to be used interchangeably in the programming world. What's the correct convention for their use? ...

What should programmers know when moving from XP/Vista to Windows 7?

I have not used Windows Vista. I knew that many APIs have been changed/deprecated in Vista, so programs need to be fixed or configured to execute in XP Compatible mode. So, what should windows programmer know when they move from XP/Vista to Windows 7? ...

How to capitalise acronyms in entity names?

Let's for a moment assume that you're programming in a language that uses camelcase words for identifiers, by convention. All you Ruby types with your underscore-separated method names get to sit this one out. What approach do you take to capitalising the letters after the first when your name contains an acronym? For example, would y...

How should I handle errors in Perl methods, and what should I return from the methods?

Hi I've wrapped Perl's Net::SSH::Expect with a small module to reduce the boilerplate code needed to write a new configuration script for use with our HP iLO cards. While on one hand I want this wrapper to be as lean as possible, so non-programmer colleagues can use it, I also want it to be as well-written as possible. It's used like s...

The "Waiting lists problem"

A number of students want to get into sections for a class, some are already signed up for one section but want to change section, so they all get on the wait lists. A student can get into a new section only if someone drops from that section. No students are willing to drop a section they are already in unless that can be sure to get...

On your very first program, which construct hooked you on programming?

To me it was the If statement, I'm psyched up, since then I believed that computers are very intelligent, or I can at least make it appear intelligent because of it. ...

Will providing APIs help deter screen scraping?

I have been thinking quite a bit here lately about screen scraping and what a task it can be. So I pose the following question. Would you as a site developer expose simple APIs to prevent users from screen scraping, such as JSON results? These results could then implement caching, and they are much smaller for traffic than the huge amo...

How should I start designing an AI algorithm for an artillery warfare game?

Here's the background... in my free time I'm designing an artillery warfare game called Staker (inspired by the old BASIC games Tank Wars and Scorched Earth) and I'm programming it in MATLAB. Your first thought might be "Why MATLAB? There are plenty of other languages/software packages that are better for game design." And you would be r...

1-1 mappings for id obfuscation

I'm using sequential ids as primary keys and there are cases where I don't want those ids to be visible to users, for example I might want to avoid urls like ?invoice_id=1234 that allow users to guess how many invoices the system as a whole is issuing. I could add a database field with a GUID or something conjured up from hash function...

As our favorite imperative languages gain functional constructs, should loops be considered a code smell?

In allusion to Dare Obasanjo's impressions on Map, Reduce, Filter (Functional Programming in C# 3.0: How Map/Reduce/Filter can Rock your World) "With these three building blocks, you could replace the majority of the procedural for loops in your application with a single line of code. C# 3.0 doesn't just stop there." Should we increasin...

The stories behind keywords and operators?

Know any good stories that describe how a keyword or an operator got it's name? For example, why is main() the starting point on so many programs? Or why is the pipe (|) used as an OR operator in some languages? Most are derived from older syntax, but why were these chosen to begin with? I was just reading about why we use an asterisk...

how can I diff two sections of the same file?

I have a source file with two similar yet subtly different sections. I'd like to merge the two sections into one subroutine with a parameter that handles the subtle differences, but I need to be sure I'm aware of them all so I don't miss any. What I usually do in such cases is copy each of the sections to a separate file and then use tk...

How to design a simple class structure that allows defining validations?

my company processes paper forms so that written data is being put to databases. every form has a set of fields. i'm writing a simple internal app to define the form's fields and that includes field's validations. i'm thinking of classes structure now and i can think of two approaches: i could write a set of classes, each representi...

Where to split Directrory Groupings? A-F | G-K | L-P

I'm looking to build a "quick link" directory access widget. e.g. (option 1) 0-9 | A-F | G-K | L-P | Q-U | V-Z Where each would be a link into sub-chunks of a directory starting with that character. The widget itself would be used in multiple places for looking up contacts, companies, projects, etc. Now, for the programming part... ...

undo/redo with cascading deletions

I'm trying to implement an undo/redo feature into my application, using the Command Pattern. I'm facing a problem. To illustrate it, let's imagine you can create with my application 2D profiles (as many as you want). From these 2D profiles, you can then create a 3D part with different attributes (name, colour, scale, etc.). +---------...

What is your system for avoiding keyword naming clashes?

Typically languages have keywords that you are unable to use directly with the exact same spelling and case for naming things (variables,functions,classes ...) in your program. Yet sometimes a keyword is the only natural choice for naming something. What is your system for avoiding/getting around this clash in your chosen technology? ...

Language Agnostic API

I am planning on putting up a web service, or some other service exposed over the internet. I would like to create an API for applications to interact with this service. I would like the API to be usable in different languages, such as Java, C++, C#, or PHP. How can I maintain one code base for my API, but distribute nice packaged bin...