There had to be one, right? In no particular order: Scratch that. Add to the top - the nail that sticks out gets the hammer. ;)
Data type | Naming example |
---|---|
int | iValue |
char | chChar |
long | lValue |
unsigned int | uValue |
WORD | wValue |
DWORD | dwValue |
CString | strValue csValue (if STL string) |
struct X | sxValue |
X * | pxValue |
if (<exp>) { <stmt list> } else { <stmt list> }Early exit in if statements is fine, but only if they have no "else"
if (<exp>) { <stmt list> return; } // there is no else here!
#include "stdafx.h" #include "project.h" // Recorder.h, Producer.h, etc. #include "class.h" #include "other.h" // headers required ONLY by the class implementationPrefer forward declarations in class headers to inclusion. Angle brackets (i.e. #include <header.h>) for MS windows and MS library files. All other use quoted names.
CString strFileName = "MyFile.txt"; CString strProgPath = "\\Recorder\\"; CString strFullName = ::GetProgPath() + strProgPath + strFileName;can be done as,
CString strFullName; strFullName.Format("%s\\Recorder\\MyFile.txt", ::GetProgPath());And if later we do folder APIs:
strFullName.Format("%s%s\\MyFile.txt", ::GetProgPath(), ::TargetFolder());
The interaction between these 2 classes is artificially convoluted.
In order allow the edit dialog to update the calling CTransparentWnd the dialog overloads PreModal() to pass pointers to the CTransparentWnd window and its members that control transparency. Then as the user edits the values the dialog calls CTransparentWnd::InvalidateTransparency to update the image. All this was done using pointers and casts. Ugh. The dialog class has been changed to force the caller to use the constructor to pass in references to the control values it uses and a pointer to itself. As before, the dialog will call CTransparentWnd::InvalidateTransparency when the values change.
What should be done is to pass the new values as arguments to CTransparentWnd::InvalidateTransparency(bool bEnable, int iLevel) and let it deal with its own internal state. The call to the edit dialog should simply pass in the current state values and copy the new state after the dialog completes. Note that the dialog still retains the old values and restores them on cancel.
Here is the quick fix, but it doesn't really deal with the fact that the type of iTemp should be bool.
int iTemp = 0; f(iTemp ? true : false);