language-agnostic

How big should a language vocabulary be?

I started looking at the upcoming C++0x specification today, and I started thinking on what is the right size for a language vocabulary. Initially, it struck me as very annoying that new keywords were introduced. At some rough level, the number of keywords in a language is, I think, an estimate of its complexity. That is, in the case of ...

Separating groups into nearly-equal stacks

I have a list of documents and I want to display them grouped by the first letter of their name on a web-page, over three columns. In short, something like this: A | C | E A | D | F B | D | F B | D | F | D | An important difference from say, the Windows Explorer view style is that I want letters to stay with each other. No breaking...

A brilliant example of effective encapsulation through information hiding?

"Abstraction and encapsulation are complementary concepts: abstraction focuses on the observable behavior of an object... encapsulation focuses upon the implementation that gives rise to this behavior... encapsulation is most often achieved through information hiding, which is the process of hiding all of the secrets of object that do no...

Should I always/ever/never initialize object fields to default values?

Code styling question here. I looked at this question which asks if the .NET CLR will really always initialize field values. (The answer is yes) But it strikes me that I'm not clear that it's a always a good idea to have it do this. My thinking is that if I see a declaration like this: int myBlorgleCount = 0; I have a pretty goo...

Designing chart drawing software

I am designing software that needs to draw several different kinds of charts--bar charts, pie charts, flow charts/graphs, charts over time. I am looking for resources related to both the programming side of the issue as well as the UI/display side. Books, online resources would all be helpful. Thanks. ...

When to disable "save password" functionality on your login form?

I have a public-facing website that is used to manage business infrastructure equipment for my clients. A security breach on this website could cause expensive problems for clients. A number of different websites--mostly banks, health care, and government--disable the "save password" dialog from appearing in Firefox, IE, and other brows...

New and improved with clarification: XML feed design best practice for structured data when there is no pre-existing DTD/Schema

When designing an XML feed for structured data, what is good practice, and what anti-patterns are there? I'd like answers that cover XML structure and content, and/or transport mechanisms. Transport Mechanisms With current technologies is FTP/SFTP a good technology? Are there cases where it is the best fit as a solution? Generally I...

Any name for this concept?

Say, we have a program that gets user input or any other unpredictable events at arbitrary moments of time. For each kind of event the program should perform some computation or access a resource, which is reasonably time-consuming to be considered. The program should output a result as fast as possible. If next events arrive, it might ...

How should release notes be written?

Is there any sort of guidelines or best practices on how release notes should be written? I guess I am trying to find the proper balance between making the point without being too specific. Also, do developer usually provide a much more release notes for QA team compare to the one submitted for public view? ...

Modification history in a file

I have worked a few places which haven’t used source control. They seemed to get into the habit of putting comments around code they changed explaining the change so that things could be reverted. I have found that this makes the code very difficult to read, and have been fairly adamant that such comments are not needed after introduci...

How to understand the why/reason behind programming?

As a beginner programmer, I often look at code and wonder why it was done a certain way or the reason why someone chose to implement a method one way over the other. Usually my lack of expertise or knowledge sometimes makes me feel frustrated. What are ways to not only know what someone did, but the reason why they did it, so if you ev...

What coding style for error checking is better and why?

What coding style for error checking is better and why? (leave Exceptions away, imagine we do not have them) int foo() { int errCode = some_system_call(); if (errCode != OK) { return myErrCode; } // continue doing foo stuff return myOK; } Or: int foo() { int returnCode = myOK; int errCode = som...

Artificial intelligence - interesting topic.

I have to give a short lecture in some artificial intelligence topic i choose and i'm looking for an interesting one. we've already had "self organising maps" "chatterbots" and "ai in fpp games" - to give you a taste of what i'm looking for. i've been searching the internet for last two days and i just can't find anything special. any id...

Who should a method belong to?

I'm trying to design a simple game ---Pong, Arkanoid--- using strictly "Proper OO", whatever that means. So, by designing myself to death, I'm trying to get to a point where I'll know what to do or not do next time... Who should handle, for example, colissions? And scorekeeping? My first idea was giving a couple jobs to the ball, but ...

What's the difference between data and code?

To take an example, consider a set of discounts available to a supermarket shopper. We could define these rules as data in some standard fashion (lists of qualifying items, applicable dates, coupon codes) and write generic code to handle these. Or, we could write each as a chunk of code, which checks for the appropriate things given th...

A bit of tiling...

I just finished writing a small script to combine a lot of png pictures into a bigger one for CSS Sprite. So basically, I have a list of dimensions [(w1,h2), ..., (wn,hn)] and I need to put them into a frame with dimension (W,H) with WH as small as possible. (Of course they cannot overlap) The heuristic I used is obviously not optima...

Suggestions for Data Access Interface Name

I am looking for suggestions for an interface name. The interface is for the primitive CRUD methods that will be defined later in the DAL, however I need to use it in a lower-level API. The interface itself will just have the four members, Create(), Read(), Update(), and Delete(). I am currently thinking something along the lines of ID...

Fastest way to find most similar string to an input?

Given a query string Q of length N, and a list L of M sequences of length exactly N, what is the most efficient algorithm to find the string in L with the fewest mismatch positions to Q? For example: Q = "ABCDEFG"; L = ["ABCCEFG", "AAAAAAA", "TTAGGGT", "ZYXWVUT"]; answer = L.query(Q); # Returns "ABCCEFG" answer2 = L.query("AAAATAA"); ...

Which comes first - The Interface or the Class

During the process of designing new features in your software, which process is the best practice Design the Interface that the Class will implement. Writing the Class and extracting the Interface later. If going the route of number 2, when do you decide that an Interface is needed? ...

How do you create a function that returns a function in your language of choice?

Recently I've been learning Lua and I love how easy it is to write a function that returns a function. I know it's fairly easy in Perl as well, but I don't think I can do it in C without some heartache. How do you write a function generator in your favorite language? So that it's easier to compare one language to another, please wri...