language-agnostic

Supporting Code Metrics with Case Studies

I'm principally interested in case studies on code metrics, relating code readability to defect reduction, that justify taking seriously cyclomatic complexity or some similar metric. Wikipedia has this example: A number of studies have investigated cyclomatic complexity's correlation to the number of defects contained in a mod...

Check if wind direction is within a specified range

I am representing wind directions using integer values (an Enum) ranging from 0 for North, through to 15 for North-North-West. I need to check if a given wind direction (integer value between 0 and 15) is within a certain range. I specify my WindDirectionFrom value first moving clockwise to WindDirectionTo to specify the range of allowa...

How would you set up a database for this type of problem?

I'm quite a beginner at database design. I have two problems that I'd like to solve using a database, but am not sure how to deal with an unknown number of fields. Here are the two types of data I'd like to store (they represent the same schema issue I think): I want to store a bunch of coordinates for a map route. The proposed DB woul...

Why is there a velocity parameter for Note Off Events?

In MIDI note off event velocity can be specified as well, why? Always when a Note On event's velocity is zero, it basically represents a Note Off event? and vice versa, always when there is a NoteOff event it represents Note Off regardless of its velocity? I noticed in some MIDI files, instead of using Note Off events, there is anothe...

Is there a way to generate a compiler error?

I want to define a Nibble type. I want that if the user sets the value higher than 0xf, it should generate a compiler error. Is this possible? ...

How to handle minor bugs that represent design flaws?

I'm working on a project where I have a few related bugs that are fairly minor in terms of loss of functionality. They are basically minor but annoying aesthetic problems, and based on loss of functionality should be fixed eventually, but not as a top priority. However, these bugs are caused by a fundamental, baked-in design flaw that ...

Finding blank regions in image

This question is somewhat language-agnostic, but my tool of choice happens to be a numpy array. What I am doing is taking the difference of two images via PIL: img = ImageChops.difference(img1, img2) And I want to find the rectangular regions that contain changes from one picture to another. Of course there's the built in .getbbox() ...

How to implement your own WHOIS server?

How would you get the WHOIS information to provide in the first place? Note that I'm not actually intending to do this; I'm just interested in how it would work! ...

Multiple returns versus Exit for

I have the following VB.NET code (but for each loops are in most languages, thus the language-agnostic tag): Public Function VerifyServiceName(ByRef sMachineName As String, ByRef sServiceName As String) As Boolean Dim asServices As System.ServiceProcess.ServiceController() = System.ServiceProcess.ServiceController.GetServices(sMa...

Generating a list of people's names

Hi, I am building a program that will eventually be populated with thousands of users, but I want to be able to test it using a large dataset while developing. What I want to do is get a list of several hundred common first names + surnames from various languages/cultures so that I can pair them together randomly and sequentially to cr...

Interactive TextArea (collapsible bullet points)

I don't work with Graphical interfaces very much, most of my experience has been with Java. I realize the operating system provides some "native" controls that allow you to do things. What if I want to do things that are a little more fancy but feel like the native control? What I'm thinking is having the simplicity of editing in a Text...

How can mathematical concepts help me In web development?

I have seen programmers "battling" it out with really complex mathematical problems in their codes, particularly in the fields of game programming, physics programming, graphics programming, etc. I am a web developer, and I wonder if there are math concepts out there that I can use for web programming. I started web programming a year an...

solve a maze by using DFS, BFS, A*

I want to know the change in results when we use open maze or closed maze for the DFS, BFS, and A* search algorithms? Is there any big difference in the output like increase in number of expanded nodes, cost, etc.? ...

cache behaviour on redundant writes

Edit - I guess the question I asked was too long so I'm making it very specific. Question: If a memory location is in the L1 cache and not marked dirty. Suppose it has a value X. What happens if you try to write X to the same location? Is there any CPU that would see that such a write is redundant and skip it? For example is there an o...

Developer's Log

Possible Duplicates: Do you keep a programming journal? What do you use to keep notes as a developer? I am interested in the benefits of keeping a daily log of my development activities. I was wondering how common this practice is in software development (i.e. Do YOU keep a log of your development activities?) What sor...

How do I write a function to compare and rank many sets of boolean (true/false) answers?

I've embarked on a project that is proving considerably more complicated than I'd first imagined. I'm trying to plan a system that is based around boolean (true/false) questions and answers. Users on the system can answer any questions from a large set of boolean (true/false) questions and be presented with a list showing the most simila...

How can one learn multi-threaded parallel programming?

No matter how proficient you are at programming C or Java, you should consider adding multi-threaded programming to your set of skills. This is NOT something you should try to learn on your own. It is MUCH harder to learn than sequential programming. If you are a Technical Manager, you SHOULD invest in retraining your key staff i...

Code golf: Digital clock

Possible Duplicate: Code Golf: Seven Segments The task: Write the smallest possible program (least number of characters) that takes input in the hh:mm format and outputs this as a digital clock (seven-segment display). Sample input: 19:27 Sample output: _ _ _ | |_| . _| | | _| . |_ | Sample input: 11:...

Using one method with constants as parameters versus several methods

In Kent Beck's Implementation Patterns, one can read "A common use of constants is to communicate variations of a message in an interface. For example, to center text you could invoke setJustification(Justification.CENTERED). One advantage of this style of API is that you can add new variants of existing methods by addi...

Is there a programming language with full and correct Unicode support?

Most programming languages have some support for Unicode, but all have some more or less documented corner cases, where things won't work correctly. Examples Java: reverse() in StringBuilder/StringBuffer work correctly. But length(), charAt(), etc. in String do not if a character needs more than 16bit to encode. C#: Didn't find a co...