What exactly is GUID? Why and where I should use it?
I've seen references to GUID in a lot of places, and in wikipedia,
but it is not very clear telling you where to use it.
If someone could answer this, it would be nice.
Thanks
...
I've seen a few mentions of this on SO, but staring at Wikipedia and at an MFC dynamic dialog demo did nothing to enlighten me. Can someone please explain this? Learning a fundamentally different concept sounds nice.
Edit: I think I'm getting a better feel for it. I guess I just didn't look at the source code carefully enough the firs...
I learned a lot about various languages last time I did one of these, so I figured I'd submit another. Community Wiki of course...
All programming languages are acceptable. The goal is to create the program in a language with the least amount of characters. New lines and indenting should be left in for clarity, but not counted. Try ...
Let's in fact generalize to a c-confidence interval. Let the common rate parameter be a. (Note that the mean of an exponential distribution with rate parameter a is 1/a.)
First find the cdf of the sum of n such i.i.d. random variables. Use that to compute a c-confidence interval on the sum. Note that the max likelihood estimate (MLE...
How can the XOR operation (on two 32 bit ints) be implemented using only basic arithmetic operations? Do you have to do it bitwise after dividing by each power of 2 in turn, or is there a shortcut? I don't care about execution speed so much as about the simplest, shortest code.
Edit:
This is not homework, but a riddle posed on a hacker....
As the title states when would you recommend the use of the mediator design pattern and where do you see it used incorrectly?
...
Design patterns are great in that they distill a potentially complex technique into something idiomatic. Often just the fact that it has a name helps communication and understanding.
The downside is that it makes it easier to try to use them as a silver bullet, applying them to every situation without thinking about the motivation behin...
What are the motivations for using a message based system?
I'm seeing a lot about service buses such as NServiceBus and Mass Transit and I'm wondering what the benefits of the underlying methodology are.
...
As a side project I'm currently writing a server for an age-old game I used to play. I'm trying to make the server as loosely coupled as possible, but I am wondering what would be a good design decision for multithreading. Currently I have the following sequence of actions:
Startup (creates) ->
Server (listens for clients, creates) ->...
An html template is compiled into the application as a resource. A fragment of the HTML template looks like:
<A href="%PANELLINK%" target="_blank">
<IMG border="0" src="%PANELIMAGE%" style="%IMAGESTYLE%">
</A><BR>
%CAPTIONTEXT%
i like it like this because the larger resource HTML file contains styling, no-quirks mode, etc.
But as ...
Partial template specialization is one of the most important concepts for generic programming in C++. For example: to implement a generic swap function:
template <typename T>
void swap(T &x, T &y) {
const T tmp = x;
y = x;
x = tmp;
}
To specialize it for a vector to support O(1) swap:
template <typename T, class Alloc>
void swa...
In the C# example of polymorphism, there is a Cat class which inherits a class called AnimalBase and an interface called IAnimal.
The link in question is: http://en.wikipedia.org/wiki/Polymorphism_in_object-oriented_programming
My question is, why is both a base class and an interface used? Why not one or the other? I was of the schoo...
Whenever I try to write graphical programs (whether a game or really any GUI app) I always wind up with one or two god classes with way too many methods (and long methods, too), and each class having far too many responsibilities. I have graphics being done at the same time as calculations and logic, and I feel like this is a really bad ...
What do you use to denote a member variable in a class?
The most common time this is a problem is when you have a parameter passed into a constructor to set a member variable. Here is an example:
public MyClass(string name)
{
name = name; // arghh!!
}
I've used m_name before, but that stinks of Hungarian.
I've used _name before...
I've seen the term "lexical variable" a few times, mostly in the context of closures. Paul Graham uses the term in his books on Lisp referring to variables defined using the let expression.
I understand that lexical scoping is another name for static scoping. Is lexical variable just a variable that is visible in a program unit's refer...
I've read a lot recently about how writing multi-threaded apps is a huge pain in the neck, and have learned enough about the topic to understand, at least at some level, why it is so.
I've read that using functional programming techniques can help alleviate some of this pain, but I've never seen a simple example of functional code tha...
Quick design question.
ClassA has a method called DoSomething(args)
In DoSomething(), before it can actually do something, it needs to do some preparatory work with args. I believe this should be encapsulated within ClassA, (as opposed to doing the prep work outside and passing it in) as nothing else needs to know that this prep work ...
So in Ruby there is a trick to specify infinity:
1.0/0
=> Infinity
I believe in Python you can do something like this
float('inf')
These are just examples though, I'm sure most languages have infinity in some capacity. When would you actually use this construct in the real world? Why would using it in a range be better than just us...
When testing in any language, how does everybody phrase their assertion messages?
I see three obvious ways:
# assume failure
assert (4-2) == 2, "Subtracting 2 from 4 doesn't equal 2"
# describe success
assert (4-2) == 2, "Subtracting 2 from 4 should equal 2"
# be vauge with failure
assert (4-2) == 2, "Subtracting 2 from 4 is broken"
...
Print all 12 verses of the popular holiday song.
By 12 verses I mean the repetition of each line as is sung in the song, ie
Verse One:
On the first day of Christmas my true love gave to me
a partridge in a pear tree.
Verse Two
On the second day of Christmas my true love gave to me
two turtle doves
and a partridge in a pear tree.
...
...