<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Programming Habits</title>
	<atom:link href="http://blog.delphi-jedi.net/2010/01/14/programming-habits/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.delphi-jedi.net/2010/01/14/programming-habits/</link>
	<description>Joint Endeavor of Delphi Innovators of Windows Programming</description>
	<lastBuildDate>Thu, 24 Nov 2011 17:58:16 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Wouter van Nifterick</title>
		<link>http://blog.delphi-jedi.net/2010/01/14/programming-habits/comment-page-1/#comment-35850</link>
		<dc:creator>Wouter van Nifterick</dc:creator>
		<pubDate>Sat, 06 Mar 2010 02:57:07 +0000</pubDate>
		<guid isPermaLink="false">http://blog.delphi-jedi.net/?p=612#comment-35850</guid>
		<description>Side note: you could use SysUtils.Win32Check to make your code a bit easier to read:

procedure MyImpersonateUserToken(UserName : String; out UserData : PUserData);
begin
  //get user token here
  Win32Check(GetUserToken);
  //get user information from token here and store it into UserData
  Win32Check(GetTokenInformation); 

  Win32Check(ImpersonateLoggedOnUser(token));
  ...
end;</description>
		<content:encoded><![CDATA[<p>Side note: you could use SysUtils.Win32Check to make your code a bit easier to read:</p>
<p>procedure MyImpersonateUserToken(UserName : String; out UserData : PUserData);<br />
begin<br />
  //get user token here<br />
  Win32Check(GetUserToken);<br />
  //get user information from token here and store it into UserData<br />
  Win32Check(GetTokenInformation); </p>
<p>  Win32Check(ImpersonateLoggedOnUser(token));<br />
  &#8230;<br />
end;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jeroen Pluimers</title>
		<link>http://blog.delphi-jedi.net/2010/01/14/programming-habits/comment-page-1/#comment-33292</link>
		<dc:creator>Jeroen Pluimers</dc:creator>
		<pubDate>Mon, 18 Jan 2010 22:14:17 +0000</pubDate>
		<guid isPermaLink="false">http://blog.delphi-jedi.net/?p=612#comment-33292</guid>
		<description>@Oliver: I must have been sleeping when I skipped everything after the word COM. 

Sorry. You are right. But only partially ;-)

Since Delphi interfaces are completely decoupled from COM (i.e. they don&#039;t depend on COM, they just use the same internal structure so it is easy to consume COM interfaces), you don&#039;t get the bloat that prevents you to be portable. As a matter of fact, descending from TInterfacedObject and using interfaces works just as well in Kylix and Delphi .NET as it does in Delphi Win32.

I find Delphi 2010, 2007 and 7 the most stable versions so far. Delphi 2010 is about as fast as Delphi 7 once was, but Delphi 2007 is not that much slower.
Lately, I had to do some maintenance in Delphi 7, and it was a pain going back so far. It lacks so much productivity I have now (and I do a lot of coding that does not use the form/frame/datamodule designers at all).

@Roddy: read this piece by Allen Bauer about finalizing records: http://blogs.embarcadero.com/abauer/2008/09/18/38869
It is tricky, but can be done. 
But you should hide that stuff as deep as possible though :-)

--jeroen

--jeroen</description>
		<content:encoded><![CDATA[<p>@Oliver: I must have been sleeping when I skipped everything after the word COM. </p>
<p>Sorry. You are right. But only partially <img src='http://blog.delphi-jedi.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>Since Delphi interfaces are completely decoupled from COM (i.e. they don&#8217;t depend on COM, they just use the same internal structure so it is easy to consume COM interfaces), you don&#8217;t get the bloat that prevents you to be portable. As a matter of fact, descending from TInterfacedObject and using interfaces works just as well in Kylix and Delphi .NET as it does in Delphi Win32.</p>
<p>I find Delphi 2010, 2007 and 7 the most stable versions so far. Delphi 2010 is about as fast as Delphi 7 once was, but Delphi 2007 is not that much slower.<br />
Lately, I had to do some maintenance in Delphi 7, and it was a pain going back so far. It lacks so much productivity I have now (and I do a lot of coding that does not use the form/frame/datamodule designers at all).</p>
<p>@Roddy: read this piece by Allen Bauer about finalizing records: <a href="http://blogs.embarcadero.com/abauer/2008/09/18/38869" rel="nofollow">http://blogs.embarcadero.com/abauer/2008/09/18/38869</a><br />
It is tricky, but can be done.<br />
But you should hide that stuff as deep as possible though <img src='http://blog.delphi-jedi.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>&#8211;jeroen</p>
<p>&#8211;jeroen</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Oliver</title>
		<link>http://blog.delphi-jedi.net/2010/01/14/programming-habits/comment-page-1/#comment-33243</link>
		<dc:creator>Oliver</dc:creator>
		<pubDate>Sun, 17 Jan 2010 15:27:33 +0000</pubDate>
		<guid isPermaLink="false">http://blog.delphi-jedi.net/?p=612#comment-33243</guid>
		<description>@Jeroen: this is what I mentioned as the second workaround. It didn&#039;t strike me as easy or simple, though. Let alone portable. And it adds bloat to my binary that I may not be ready to accept ;) ... portability is a &lt;strong&gt;big&lt;/strong&gt; issue for me, btw.

@Ali: thanks, wasn&#039;t aware of it. However, others seem to disagree that this is a full replacement and given the quality of BDS 2006 when I bought it, I&#039;m not ready to shell out another few hundred Euros just to get the latest and greatest (as in most bloated ;)) Delphi. Of course Embarcadero will blackmail me, approximately this year, to upgrade now or never be able to upgrade again from BDS 2006 to the newest version of whatever the BDS is called now. Let&#039;s see whether I will resist.

@stanleyxu2005: Hmm, I&#039;d also argue in favor of D, but there are other clean languages as well. All in all it depends on the problem at hand to figure which tools to use. Oh, and of course a little discipline is required during the development. I have to maintain a horrible legacy project written in BCB6, that shows how the easy &quot;RAD-style&quot; can condone bad programming habits, such as sprouting of code that is &lt;em&gt;based&lt;/em&gt; on the idea of &quot;forms&quot;, rather than separating that code into classes and have the form own such a class instance or similar ...

However, the usability of the tool to be used is of importance. This is something where I have my problem with (Borland/Inprise/Borland/Codegear/Embarcadero)&#039;s solutions since Delphi 7, at latest.

Perhaps, though, those &quot;improvements&quot; which aren&#039;t useful, but instead annoying, to me make a lot of sense to others. And after all (Borland/Inprise/Borland/Codegear/Embarcadero) has introduced Unicode after only a little more than a decade of fully &quot;unicodified&quot; Windows ... and of course they had to do it in the &quot;worst possible way(tm)&quot;. For one, there is now only Unicode, instead of the good old choice between ANSI and Unicode.

Perhaps I should just wait a few more decades ... &lt;em&gt;or&lt;/em&gt; instead continue to use my current tool set and adjust that whenever the need arises.

// Oliver ;)</description>
		<content:encoded><![CDATA[<p>@Jeroen: this is what I mentioned as the second workaround. It didn&#8217;t strike me as easy or simple, though. Let alone portable. And it adds bloat to my binary that I may not be ready to accept <img src='http://blog.delphi-jedi.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  &#8230; portability is a <strong>big</strong> issue for me, btw.</p>
<p>@Ali: thanks, wasn&#8217;t aware of it. However, others seem to disagree that this is a full replacement and given the quality of BDS 2006 when I bought it, I&#8217;m not ready to shell out another few hundred Euros just to get the latest and greatest (as in most bloated <img src='http://blog.delphi-jedi.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> ) Delphi. Of course Embarcadero will blackmail me, approximately this year, to upgrade now or never be able to upgrade again from BDS 2006 to the newest version of whatever the BDS is called now. Let&#8217;s see whether I will resist.</p>
<p>@stanleyxu2005: Hmm, I&#8217;d also argue in favor of D, but there are other clean languages as well. All in all it depends on the problem at hand to figure which tools to use. Oh, and of course a little discipline is required during the development. I have to maintain a horrible legacy project written in BCB6, that shows how the easy &#8220;RAD-style&#8221; can condone bad programming habits, such as sprouting of code that is <em>based</em> on the idea of &#8220;forms&#8221;, rather than separating that code into classes and have the form own such a class instance or similar &#8230;</p>
<p>However, the usability of the tool to be used is of importance. This is something where I have my problem with (Borland/Inprise/Borland/Codegear/Embarcadero)&#8217;s solutions since Delphi 7, at latest.</p>
<p>Perhaps, though, those &#8220;improvements&#8221; which aren&#8217;t useful, but instead annoying, to me make a lot of sense to others. And after all (Borland/Inprise/Borland/Codegear/Embarcadero) has introduced Unicode after only a little more than a decade of fully &#8220;unicodified&#8221; Windows &#8230; and of course they had to do it in the &#8220;worst possible way(tm)&#8221;. For one, there is now only Unicode, instead of the good old choice between ANSI and Unicode.</p>
<p>Perhaps I should just wait a few more decades &#8230; <em>or</em> instead continue to use my current tool set and adjust that whenever the need arises.</p>
<p>// Oliver <img src='http://blog.delphi-jedi.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Christian Wimmer</title>
		<link>http://blog.delphi-jedi.net/2010/01/14/programming-habits/comment-page-1/#comment-33165</link>
		<dc:creator>Christian Wimmer</dc:creator>
		<pubDate>Fri, 15 Jan 2010 21:21:15 +0000</pubDate>
		<guid isPermaLink="false">http://blog.delphi-jedi.net/?p=612#comment-33165</guid>
		<description>Well, mathematicians would argue against that :-)</description>
		<content:encoded><![CDATA[<p>Well, mathematicians would argue against that <img src='http://blog.delphi-jedi.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: stanleyxu2005</title>
		<link>http://blog.delphi-jedi.net/2010/01/14/programming-habits/comment-page-1/#comment-33163</link>
		<dc:creator>stanleyxu2005</dc:creator>
		<pubDate>Fri, 15 Jan 2010 21:02:43 +0000</pubDate>
		<guid isPermaLink="false">http://blog.delphi-jedi.net/?p=612#comment-33163</guid>
		<description>Delphi is really not a good language for clean code. Take a look at language D.</description>
		<content:encoded><![CDATA[<p>Delphi is really not a good language for clean code. Take a look at language D.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Roddy</title>
		<link>http://blog.delphi-jedi.net/2010/01/14/programming-habits/comment-page-1/#comment-33154</link>
		<dc:creator>Roddy</dc:creator>
		<pubDate>Fri, 15 Jan 2010 17:20:57 +0000</pubDate>
		<guid isPermaLink="false">http://blog.delphi-jedi.net/?p=612#comment-33154</guid>
		<description>@Ali - AFAIK, Records can&#039;t have destructors, so they cannot automatically free owned resources.</description>
		<content:encoded><![CDATA[<p>@Ali &#8211; AFAIK, Records can&#8217;t have destructors, so they cannot automatically free owned resources.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Christian Wimmer</title>
		<link>http://blog.delphi-jedi.net/2010/01/14/programming-habits/comment-page-1/#comment-33136</link>
		<dc:creator>Christian Wimmer</dc:creator>
		<pubDate>Fri, 15 Jan 2010 08:57:17 +0000</pubDate>
		<guid isPermaLink="false">http://blog.delphi-jedi.net/?p=612#comment-33136</guid>
		<description>Yes, I also think this is an error. It should have been EOsError.</description>
		<content:encoded><![CDATA[<p>Yes, I also think this is an error. It should have been EOsError.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jolyon Smith</title>
		<link>http://blog.delphi-jedi.net/2010/01/14/programming-habits/comment-page-1/#comment-33109</link>
		<dc:creator>Jolyon Smith</dc:creator>
		<pubDate>Thu, 14 Jan 2010 23:11:14 +0000</pubDate>
		<guid isPermaLink="false">http://blog.delphi-jedi.net/?p=612#comment-33109</guid>
		<description>Not sharing a good habit, but adding that making assumptions about errors to raise can be as dangerous as not raising errors.

There is an assumption in the VCL that cost me countless hours of frustration:

function TWinControl.GetDeviceContext(var WindowHandle: HWnd): HDC;
begin
  if csDesigning in ComponentState then
    Result := GetDCEx(Handle, 0, DCX_CACHE or DCX_CLIPSIBLINGS)
  else
    Result := GetDC(Handle);
  if Result = 0 then raise EOutOfResources.CreateRes(@SWindowDCError);
  WindowHandle := FHandle;
end;

I was getting EOutOfResources errors and spent hours fruitlessly trying to figure out where my seemingly very simple code was haemhorraging resources so badly that I was exhausting the system.

I eventually decided that I was being lied to, tracked the exception back to this assumption and determined that the problem was not in fact a lack of resources but simply an invalid window handle.

With that more accurate information, identifying the problem then took a matter of moments!!!

Thanks for nothing VCL!</description>
		<content:encoded><![CDATA[<p>Not sharing a good habit, but adding that making assumptions about errors to raise can be as dangerous as not raising errors.</p>
<p>There is an assumption in the VCL that cost me countless hours of frustration:</p>
<p>function TWinControl.GetDeviceContext(var WindowHandle: HWnd): HDC;<br />
begin<br />
  if csDesigning in ComponentState then<br />
    Result := GetDCEx(Handle, 0, DCX_CACHE or DCX_CLIPSIBLINGS)<br />
  else<br />
    Result := GetDC(Handle);<br />
  if Result = 0 then raise EOutOfResources.CreateRes(@SWindowDCError);<br />
  WindowHandle := FHandle;<br />
end;</p>
<p>I was getting EOutOfResources errors and spent hours fruitlessly trying to figure out where my seemingly very simple code was haemhorraging resources so badly that I was exhausting the system.</p>
<p>I eventually decided that I was being lied to, tracked the exception back to this assumption and determined that the problem was not in fact a lack of resources but simply an invalid window handle.</p>
<p>With that more accurate information, identifying the problem then took a matter of moments!!!</p>
<p>Thanks for nothing VCL!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Christian Wimmer</title>
		<link>http://blog.delphi-jedi.net/2010/01/14/programming-habits/comment-page-1/#comment-33106</link>
		<dc:creator>Christian Wimmer</dc:creator>
		<pubDate>Thu, 14 Jan 2010 22:48:58 +0000</pubDate>
		<guid isPermaLink="false">http://blog.delphi-jedi.net/?p=612#comment-33106</guid>
		<description>Records are no replacement for classes.</description>
		<content:encoded><![CDATA[<p>Records are no replacement for classes.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ali</title>
		<link>http://blog.delphi-jedi.net/2010/01/14/programming-habits/comment-page-1/#comment-33105</link>
		<dc:creator>Ali</dc:creator>
		<pubDate>Thu, 14 Jan 2010 22:35:23 +0000</pubDate>
		<guid isPermaLink="false">http://blog.delphi-jedi.net/?p=612#comment-33105</guid>
		<description>@Oliver: Delphi 2007 - 2010 support records which contain fields, methods, and properties, just like classes. Such records are stored on stack, so you can use the same technique you mentioned in newer versions of Delphi using records.

For more information about such records, you can refer to this:
http://docwiki.embarcadero.com/RADStudio/en/Structured_Types</description>
		<content:encoded><![CDATA[<p>@Oliver: Delphi 2007 &#8211; 2010 support records which contain fields, methods, and properties, just like classes. Such records are stored on stack, so you can use the same technique you mentioned in newer versions of Delphi using records.</p>
<p>For more information about such records, you can refer to this:<br />
<a href="http://docwiki.embarcadero.com/RADStudio/en/Structured_Types" rel="nofollow">http://docwiki.embarcadero.com/RADStudio/en/Structured_Types</a></p>
]]></content:encoded>
	</item>
</channel>
</rss>

