Programming
Welcome to my programming page. I plan on putting coding snippets, tips, ideas, or anything related to programming here. Everything I put on here will be totally free for use; I'll work out a proper license soon, but for now, assume everything is placed in the public domain.
Visual Studio.net stupidity
I really need to put the following on a seperate page:
Visual Studio .NET 2003 is the environment that I have to work in. There are a lot of good things in the .NET programming stuff, including how much better the C++ compiler is.
The following list is the list of problems I have with the IDE itself, not with the programming languages or compilers. All of these issues are things that Microsoft made worse than Visual Studio 6. I'm not asking for new features, or anything like that, just for old stuff. I'm also not going to go into the BRIEF keyboard layout issue, as I don't use it.
- Titlebar: In .NET the current active PROJECT is shown in the caption bar, not the currently active solution. This is a piece of useless information that is actually a problem. The thing is that often, very often, programmers have multiple Solutions with the same project. And a lot of the time you have the same project selected. So alt-tab or the taskbar become useless tools.
- Fullscreen: On of my favorite things about Visual Studio is the ability to work 'fullscreen', but in Visual Studio.NET they have basically made the feature useless. In Visual Studio.NET normal mode, there are two window layouts. One for when you are editing, and one for when you are debugging. In Visual Studio 6 they had the same feature, but it also worked in fullscreen, in Visual Studio .NET it doesn't. So while editing you have to have windows like the output window covering your text, which is exactly the wrong effect.
- Macro Recording: Both Visual Studio 6 and Visual Studio 6 have quick macro recording features. These are extremely useful, and I use them all the time. Since I have been using Visual Studio .NET I use them a lot less though. The reason I use them a lot less is that in Visual Studio .NET they are extremely slow. The first time you start recording, it takes about 3 seconds to respond. Then every time you stop recording and the first time you playback a recently recorded macro, there are big pauses (about 10 secs on my work pc). The reason (as far as I can see) for these delays is that visual studio writes the recorded macro to disk, and then loads it back in to play the macro. This is simple stupidity. Why not do it all in memory (and cache it to disk in a separate thread)?
Character Animation
A few links I saw go buy on the GD-Algo mailing list, and I'm putting them here so I can find them again in the future :)
http://grail.cs.washington.edu/projects/
http://www.cs.wisc.edu/graphics/Gallery/Kovar/
Singleton Class
Here is my singleton class, I really like it, but it's nothing ground breaking. The main reason I'm putting it here is to play with the program I use to syntax hi-light C++ code and so I can get the CSS stuff setup correctly. Sadly the tool doesn't generate fully compliant code, but I'll fix that and give a patch back to the guy that wrote it. Hmm, after looking at the resulting code, I think I might need to find a better tool :)
////////////////////////////////////////////////////////////////////////////////
/**
Declare a class as a singleton.
\param __class Class name of the singleton
\remark
This class sets Singleton<__class> as a friend class. We need this so that
CreateInst() and DestroyInst() can use new and delete on the singleton class
even tho they are declared protected or private.
*/
////////////////////////////////////////////////////////////////////////////////
#define DECLARESINGLETON(__class) friend class Singleton<__class>
////////////////////////////////////////////////////////////////////////////////
/**
Singleton base class.
*/
////////////////////////////////////////////////////////////////////////////////
template <class _TDerivedClass> class Singleton
{
friend class Singleton<_TDerivedClass>;
private:
static _TDerivedClass *ms_pInstance;
public:
////////////////////////////////////////////////////////////////////////////
/**
Get a pointer to the created instance.
\return Pointer to the created instance.
\remark
In debug builds this method will assert if the instance was not created. It
is a logical error to call this on a non created instance.
\sa
CreateInst()
RemoveInst()
IsInstanced()
*/
////////////////////////////////////////////////////////////////////////////
static _TDerivedClass *GetInst ()
{
ASSERT (ms_pInstance); return ms_pInstance;
}
////////////////////////////////////////////////////////////////////////////
/**
Create the singleton Instance
\return <b>true</b> if the instance was created.<br>
<b>false</b> if the instance was already created or on error.
\remark
In debug build this function will assert if the instance was already created.
It is a logical error to call this function more than once.
\sa
GetInst()
DestroyInst()
IsInstanced()
*/
////////////////////////////////////////////////////////////////////////////
static bool CreateInst ()
{
// Make sure we are creating the first instance.
ASSERT (!IsInstanced());
// In release builds the assert will not happen, so return
// false if the instance exists.
if (IsInstanced())
return false;
// Create the Instance
ms_pInstance = new _TDerivedClass();
return IsInstanced();
}
////////////////////////////////////////////////////////////////////////////
/**
Destroy the singleton instance.
\return <b>true</b> if the instance was destroyed.<br>
<b>false</b> if the instance was not initialized before this
method was called.
\remark
In debug builds this function will assert if the method was already destroyed
or never created. It is a logical error to call this function on a non-created
instance.
\sa
CreateInst()
GetInst()
IsInstanced()
*/
////////////////////////////////////////////////////////////////////////////
static bool DestroyInst ()
{
// Make sure the instance was created.
ASSERT (IsInstanced ());
// In release builds, the above assert will not happen, so return false
// if there is no instance.
if (!IsInstanced ())
return false;
SAFE_DELETE (ms_pInstance);
return true;
}
////////////////////////////////////////////////////////////////////////////
/**
Query if the singleton instance has been created.
\return <b>true</b> if the singleton instance has been created.<br>
<b>false</b> if the singleton instance has not been created <br>
\sa
CreateInst()
GetInst()
DestroyInst()
*/
////////////////////////////////////////////////////////////////////////////
static bool IsInstanced ()
{
return (0 != ms_pInstance);
}
};