language-agnostic

When should i consider using named parameters against normal parameters?

I was splitting RenameFolder to two pieces and i notice visual studios 2010 supports named parameters! (example below). I know this has existed for a number of years in other languages. I remember a professor saying why he likes named parameters and that he uses them in all of his code. But i am sure its not in all of his code. I was wo...

I need to choose a compression algorithm

I need to choose a compression algorithm to compress some data. I don't know the type of data I'll be compressing in advance (think of it as kinda like the WinRAR program). I've heard of the following algorithms but I don't know which one I should use. Can anyone post a short list of pros and cons? For my application the first priority ...

code for optimized watch

i want to implement a code to keep a watch on suppose some event ...at the meantime i don have any inbuilt eventwatcher so i hv to implement one of mine..which consumes least cpu & memory. can u suggest me one.. for example a pseudocode is given: while(true) { if(process.isrunning) process.kill(); } ...

Autotesting a network interface

Hi All, I'm developing a software component responsible for testing if a network interface has conectivity with the internet. Think of it as the same test the XBOX360 does to inform the user if it's connected with the Live network (just as an example). So far I figured the autotest would run as this: 1) Test the physical network interf...

Where to ask practical unit-testing questions?

Before i can understand unit testing, i have to see real world examples. Every book, blog, article, or answer i've seen gives hypothetical examples that don't apply to the/my real world. i really don't want to flood StackOverflow with hundreds of questions all titled "How do i unit-test this?" There must be another place i can go to as...

What's the reason for leaving an extra blank line at the end of a code file?

Eclipse and MyEclipse create new Java files with an extra blank line after the last closing brace by default. I think CodeWarrior did the same thing a few years back, and that some people leave such blank lines in their code either by intention or laziness. So, this seems to be at least a moderately widespread behavior. As a former hu...

When I'm iterating over two arrays at once, which one do I use as the limit?

Hi, I'm always struggling with something like the following Java example: String breads[] = {"Brown", "White", "Sandwich"}; int count[] = new int[breads.length]; for (int i = 0; i < ****; i++) { // Prompt the number of breads } ****: which array.length should I choose? I can choose between breads.length and count.length I know it ...

Can I change class types in a setter with an object-oriented language?

Hello, Here is the problem statement: Calling a setter on the object should result in the object to change to an object of a different class, which language can support this? Ex. I have a class called "Man" (Parent Class), and two children namely "Toddler" and "Old Man", they are its children because they override a behaviour in Man cal...

Code Golf: Triforce

This is inspired by/taken from this thread: http://www.allegro.cc/forums/thread/603383 The Problem Assume the user gives you a numeric input ranging from 1 to 7. Input should be taken from the console, arguments are less desirable. When the input is 1, print the following: *********** ********* ******* ***** *** ...

What question(s) does an object's behavior answer?

Reading a book I have found the following statement: (Object) Behaviors answer either of two questions: What does this object do (for me)? or What can I do to this object? In the case of an orange, it doesn’t do a whole lot, but we can do things to it. One behavior is that it can be eaten. In my understanding of object behaviour th...

Deleting an element from a kd-tree of two dimensions.

I would like to extend a kd-tree (2D) class to be able to remove nodes (points). This removal should be conducted without having to rebuild large sections of the tree. The algorithm described in these slides, on slide 13 seems to be what I am after. However, I am trouble following the description of "findmin()" found on slide 7, which is...

Do the Nagle Algorith and Delayed ACK's affect TCP Connection Setup?

Do the client's SYN and the servers SYN+ACK get delayed by Nagle? Will the client's ACK of the server's SYN get delayed? Will connect return after rtt+spt or will it take rtt + spt + 2x Nagle Delay? Or more generally, how do the Nagle Algorith and Delayed ACK's affect TCP Connection Setup? ...

Should I pass in or encapsulate a connection in a DAO?

Is it better to encapsulate the connection inside a DAO, ie have the DAO create or retrieve the connection and then close, or is better to pass the connection into the DAO and handle the details in code external to the DAO? Follow-up: How do you mange closing connections if you encapsulate the connection inside the DAO? ...

What is the name of this sequence generation problem? Any comments?

I need to iterate over an ordered sequence that is defined by an array of numbers ai, i = 1..n, where n is the length of each sequence element, and each ai specifies the max number of possible values at position i in the output sequence. Example: a = {10,10,10} Sequence: 000, 001, 002, ... 999 (the decimal numbers from 000 to 999) a ...

Where can I get graphics for startup screens?

I really like to have some graphic on my startup/login screen when starting my applications. In one of my past employments, we had this on startup/login screen: Where do you get your graphics for this purpose, and what are your favorites. ...

Refactoring large method in .NET

Hi, If I have a large .NET method, I want to know if it is good practice to split it up into multiple methods or not. My concerns are: 1 - Is there any point creating a method if it will only be called once? 2 - If I'm calling a private method from within my class, I try not to use instance variables. Is this good or bad practice? Fo...

Toolkit / webservice which allows creation of drag-drop wizard creation?

Descritpion of backend: a workspace where users can create "nodes". Each node can be an "info node" or a "choice node". Info nodes just contain information. Choice nodes present a set of choices for the user to select from. The user should be able to easily "link" a choice in a "choice node" to another node. Desc of frontend: When being...

Associating an Object with other Objects and Properties of those Objects

I am looking for some help with designing some functionality in my application. I already have something similar designed but this problem is a little different. Background: In my application we have different Modules. Data in each module can be associated to other modules. Each Module is represented by an Object in our application....

How can I compute a Cartesian product iteratively?

This question asks how to compute the Cartesian product of a given number of vectors. Since the number of vectors is known in advance and rather small, the solution is easily obtained with nested for loops. Now suppose that you are given, in your language of choice, a vector of vectors (or list of lists, or set of sets, etc.): l = [ [1...

Parsing language for both binary and character files

The problem: You have some data and your program needs specified input. For example strings which are numbers. You are searching for a way to transform the original data in a format you need. And the problem is: The source can be anything. It can be XML, property lists, binary which contains the needed data deeply embedded in binary junk...