program-design

GOTO still considered harmful?

Everyone is aware of Dijkstra's Letters to the editor: go to statement considered harmful (also here .html transcript and here .pdf) and there has been a formidable push since that time to eschew the goto statement whenever possible. While it's possible to use goto to produce unmaintainable, sprawling code, it nevertheless remains in mod...

How to approach structuring functions / procedures for a newbie

I am a hobbyist programmer and am trying to improve my skills. To that end, I have been reading 'The Pragmatic Programmer' and 'Code Complete' as recommended by some in this forum and I have to say that it has improved my approach and skills. That said, one aspect of programming I am struggling with is the 'Don't Repeat Yourself' (DRY) m...

What is Functional Decomposition?

Functional Decomposition, what is it useful for and what are it's pros/cons? Where are there some worked examples of how it is used? ...

Coding Standards for pure C (not C++)

I come from a java background (from my CS classes) and a semester of C++. I am just finishing up a OpenCV project for my Co-Op that's in pure C, so I'm a bit late in asking this question. What are the design processes and coding standards for pure C? I'm familiar with object oriented programming, design and best practices. I'm jus...

EDITED: How should I separate closely related programs in C#? (user client, admin, and common class library)

I have a suite of programs that are related. One is a user client, one is an admin program, and another is a set of library classes that reside in a Class library. How should I separate the projects? Should I put the user client in one project, the admin program in another, and the common library in a third project? Or should they resi...

java Properties - to expose or not to expose?

This might be an age old problem and I am sure everyone has their own ways. Suppose I have some properties defined such as secret.user.id=user secret.password=password website.url=http://stackoverflow.com Suppose I have 100 different classes and places where I need to use these properties. Which one is good (1) I create a Util class t...

Help with C# program design implementation: multiple array of lists or a better way?

I'm creating a 2D tile-based RPG in XNA and am in the initial design phase. I was thinking of how I want my tile engine to work and came up with a rough sketch. Basically I want a grid of tiles, but at each tile location I want to be able to add more than one tile and have an offset. I'd like this so that I could do something like add in...

Conventions for the behavior of double or triple "click to select text" features?

Almost any mature program that involves text implements "double click to select the word" and, in some cases, "triple click to select additional stuff like an entire line" as a feature. I find these features useful but they are often inconsistent between programs. Example - some programs' double clicks do not select the ending space aft...

Signals and threads - good or bad design decision?

I have to write a program that performs highly computationally intensive calculations. The program might run for several days. The calculation can be separated easily in different threads without the need of shared data. I want a GUI or a web service that informs me of the current status. My current design uses BOOST::signals2 and BOOST...

Managing thread and memory usage while working with a blocking process

I have a bunch of files (on the order of 10 per second) coming into a system (stored into a database). Each file contains an entry for somewhere between 1 and 500 devices. A given device will appear in multiple files (but not every file). This data eventually needs to be stored in another database, stored per-device. There are two differ...

How can I maintain a list of mail recipients in my Perl script?

My Perl script to monitor a directory on Unix, stores a list of users to whom a notification mail is sent when the directory it is monitoring is updated. This is the construct used dirmon.pl my $subject = '...'; my $msg = '...'; my $sendto = '[email protected] [email protected] [email protected]'; my $owner = '[email protected]'; ... ...

How should I format this piece of code?

Here are two ways of calling callscript (in pseudocode): using duplicate calls if flag == true flag = false callscript flag = true else callscript endif using an extra variable flag2 = flag flag = false callscript flag = flag2 conditions I have to make sure is that flag is false when the script is cal...