Re: peer code review/advice needed for noob programmer
On Tue, 22 May 2007 11:57:14 -0400, Joseph M. Newcomer
<newcomer@flounder.com> wrote:
Within Microsoft it is a religion. The fact that it has no useful purpose is no longer
considered relevant.
In addition, the original HN, designed by Charles Simonyi, does not at all resemble the
bastard offspring used by the Windows group. In Simonyi's original notation, the physical
representation was NEVER relevant. So a name like 'wsz' or 'sz' would have been
considered, from what my source told me, as silly.
Some code taken randomly from the ATL Server shared-source project
follows:
ComplexType.cpp
===============
// the Smart-Pointer thing:
CAutoPtr<CAttribute> spOut;
CContent * CComplexType::AddContent(CContent *pContent)
{
if (pContent == NULL)
{
pContent = new CContent;
}
delete m_pContent;
m_pContent = pContent;
return m_pContent;
}
WSDLServiceParser.h
===================
HRESULT __stdcall startPrefixMapping(
const wchar_t *wszPrefix,
int cchPrefix,
const wchar_t *wszUri,
int cchUri);
HRESULT OnUnrecognizedTag(
const wchar_t *wszNamespaceUri, int cchNamespaceUri,
const wchar_t *wszLocalName, int cchLocalName,
const wchar_t *wszQName, int cchQName,
ISAXAttributes *pAttributes) throw() ;
XMLElement.h:
=============
HRESULT GetNamespaceUri(const CStringW &strPrefix, CStringW &strUri);
LPCWSTR GetNamespaceUri(LPCWSTR wszPrefix, int cchPrefix = -1);
HRESULT SetNamespaceUri(const CStringW& strPrefix, CStringW &strUri);
HRESULT SetNamespaceUri(LPCWSTR wszPrefix, int cchPrefix, LPCWSTR
wszUri, int cchUri);
As you can see, they use 'wsz' for const wchar_t * (i.e. LPCWSTR),
'str' for CStringW, etc.
I find e.g. useful when they have:
LPCWSTR GetNamespaceUri(LPCWSTR wszPrefix, int cchPrefix = -1);
I think the above is better than e.g.:
LPCWSTR GetNamespaceUri(LPCWSTR prefix, int <what here?> = -1)
// Maybe:
// LPCWSTR GetNamespaceUri(LPCWSTR prefix, int charCount = -1) ?
In some cases, if the rules are clear and make sense and are followed
consistently, I think that these rules might help.
However, I do agree that HN must not become a 'religion'. :)
If you want to know the declaration, you hover over the name and it tells you the type. Or
you look at the declaration using the browser.
Yes, you're right. I agree with this point.
[...] calling an int a pBufferLength is a clear
violation of the naming convention, and is misleading.
I do agree.
MrAsm