language-agnostic

Multiple Browser Windows Synchronization

Hello, I am trying to create an inline chat. The problem arrives when two windows of my site are open. Because then my script sends the new message to the the window which requests it for (for the time being i am using simple polling, will move to comet later). Is there any good technique that I haven't thought of, so that I can send a...

Can you explain the Context design pattern a bit?

I've started to read about the Context design pattern. Here's what I understood from the text : you have a map containing all your variables you pass it around to whoever needs it, so that you won't have to send all the variables as method parameters Did I "get" it? ...

Log in one place versus multiple logs

For a web app or a standalone server app, which would you recommend, and why? have the giant application.log, where everything is logged; have many smaller logs: security.log performance.log lifecycle.log integration.log ...

Improving the way we write code?

While thinking about software-engineering in general I came across the question why we don't see any improvements in the way we write/document code. Think about it: There has not been a revolutionary improvement since we've moved from punch cards to text editing. The last improvement I've seen is syntax highlighting and context sensitiv...

How should you build your database from source control?

There has been some discussion on the SO community wiki about whether database objects should be version controlled. However, I haven't seen much discussion about the best-practices for creating a build-automation process for database objects. This has been a contentious point of discussion for my team - particularly since developers a...

Is the linked list only of limited use?

I was having a nice look at my STL options today. Then I thought of something. It seems a linked list (a std::list) is only of limited use. Namely, it only really seems useful if The sequential order of elements in my container matters, and I need to erase or insert elements in the middle. That is, if I just want a lot of data and ...

Regular expression to mask strings using string substitution

I would like to use a regular expression to mask all but the first three alphanumeric characters of each word in a string using a mask character (such as "x"), so "1 Buckingham Palace Road, London" would become "1 Bucxxxxxxx Palxxx Roax, Lonxxx". Keeping the first three characters is easily done using s/\b(\w{0,3})(.*)\b/$1/g but I c...

How do I release/sell/promote a semi-commercial/open-source project?

I've got a framework for PHP that I've developed for about 3 weeks total, but it's quite ready to be released ... if I choose to do so. In this economy I cannot just take what I have done and release it for free and feel just (because I need the money it could garner), and yet I am torn by my appreciation for open source projects. I wa...

How to quickly count the number of neighboring voxels?

I have got a 3D grid (voxels), where some of the voxels are filled, and some are not. The 3D grid is sparsely filled, so I have got a set filledVoxels with coordinates (x, y, z) of the filled voxels. What I am trying to do is find out is for each filled voxel, how many neighboring voxels are filled too. Here is an example: filledVoxel...

Function/Class Comment Formatting Conventions

Who has the most readable and useful function/class commenting convention? I'm not looking for something that generates docs, but I'm considering adopting something like JavaDoc because all the info is there. /** * This function processes data * * @param p1 the first piece of data * @param p2 the second piece of data * @return t...

How to explain an object?

It's been years since I thought of this, but I am training some real juniors soon and need to explain what an object is to someone who doesn't know what it is. Based on what you use in the real world, what are the key points of objects that I should focus on explaining. For example: Access Levels Inheritance Encapsulation Polymor...

Allen Holub wrote "You should never use get/set functions", is he correct?

Allen Holub wrote the following, You can't have a program without some coupling. Nonetheless, you can minimize coupling considerably by slavishly following OO (object-oriented) precepts (the most important is that the implementation of an object should be completely hidden from the objects that use it). For example, an object's insta...

accelerator keys in bilingual / multilingual input environment

On my Windows there are at least keyboard sets, for completely different languages. If, for example, I click Alt-T in Firefox, the Tools menu will open, both if the keyboard layout is Hebrew or English. (Mozilla's behavior is inconsistent in that respect, but forget it for now). When building a wxWidgets applications, the language must...

Using functional language concepts with OO - is there a language?

Dear gurus, I was recently thinking how I'm not always using the beautiful concepts of OO when writing Pythonic programs. In particular, I thought I'd be interested in seeing a language where I could write the typical web script as # Fictional language # This script's combined effect is to transform (Template, URI, Database) -> HTTP...

How do you remember the LESS THAN and GREATER THAN operators?

I have been programming for about 5 years now, and still can't seem to understand, nor remember, what is less than, and what is greater than (< and >, respectively). I tend to debug twice every time I need to use this in a conditional, because I almost never get this right. Any guides to remembering and learning this? ...

Transaction-like style of programming or the wise exception handling

Question by abstract example Suppose you have 2 methods: DoJob1(), DoJob2(). Each of them has transaction-like behavior, that is, either does its job or reports an error. How should I write a method which executes DoJob1() then DoJob2(), but is transaction-like itself, that is, guarantees the roll-back of the action performed by DoJob1...

Design Patterns for Interfacing with Relational Databases?

Does anyone know of any design patterns for interfacing with relational databases? For instance, is it better to have SQL inline in your methods, or instantiate a SQL object where you pass data in and it builds the SQL statements? Do you have a static method to return the connection string and each method just gets that string and conn...

What is your understanding of the Repository Pattern?

I'm in the process of catching up on technical documentation for a project I completed some months ago, and one I'm coming close to finishing. I used repositories to abstract out the data access layer in both and was writing a short summary of the pattern on our wiki at work. It was whilst writing this summary that I realised I took a ...

Is it better to pass an *interface* or an *object* as a parameter to a function?

I'm trying to convince a colleague that a function should take an interface as a parameter, and not the object itself. I think small objects can be fine to pass across, but for large ones I would give them an interface and just pass the i/f over, not the whole thing. Note that there will only ever be one of these large classes - the i/f...

Programmatically detecting "most important content" on a page...

What work, if any, has been done to automatically determine the most important data within an html document? As an example, think of your standard news/blog/magazine-style website, containing navigation (with submenu's possibly), ads, comments, and the prize - our article/blog/news-body. How would you determine what information on a new...