Thoughts from Dan Miser RSS 2.0
 Thursday, November 04, 2004
One of the big dilemmas programmers face every day is "Should I write this code as quickly as possible or should I write it to be as robust as possible?". Deadline pressures make some pick the quick option too often. :-( That's why I was pleasantly surprised to find CodeSmith. CodeSmith is a template-based code generator that can output code that can then be used in any ASCII based language (e.g. Delphi).

During development, there are plenty of times when you need to create a collection of objects. For example, you have a TCustomer object and need a TCustomerList object to store a list of those objects. You have a lot of options on how to represent this. Here are some of those options:

  • Place the TCustomer objects in a TList. You need to typecast the code, and you can put any object in the list. Plus, you have to worry about object lifetimes.
  • Use a TObjectList instead of a TList. This allows you to not worry about object lifetimes, but the rest of the problems using a TList still exist.
  • Use a TStrings object (e.g. TStringList), and add your object in to the Objects property
  • Create a custom list class, where you don't have to worry about type safety or object lifetime

Unfortunately, the last option is rarely chosen due to time constraints. It doesn't take all that long to do, but if you have to stop what you're doing to create the custom class, it doesn't get done more times than not.

To solve that, I created a CodeSmith template to generate strongly typed collections. Download my template, install CodeSmith, play with it, and let me know what you think. I can think of some nice improvements, like adding comments (along with an option to include those comments or not). After I get some feedback on this, I plan to upload it to the CodeSmith File Share forum.

Thursday, November 04, 2004 5:08:00 PM (Central Standard Time, UTC-06:00)  #    Comments [4] -
Delphi
 Tuesday, November 02, 2004
On December 21, 2004 from 6:00-8:00 pm, John Kaster will be coming to Milwaukee, WI to show off Delphi 2005. Location is still to be determined, but most likely will be in the Pewaukee/Waukesha/Brookfield area. The event is free, and if you're using Borland tools (or want to know more about life outside the MS camp), you should really find a way to get there.

Please send me an email if you are interested in attending. Response has been fantastic so far. Let's welcome a transplanted Wisconsinite back home in style!

Tuesday, November 02, 2004 9:38:00 AM (Central Standard Time, UTC-06:00)  #    Comments [3] -
Delphi
 Monday, November 01, 2004
While I was thinking about how best to provide a write-up on getting COM Interop working with my pluggable COM architecture, I came across this Delphi 8 paper and this Delphi 2005 paper by Brian Long (of Falafel) in one of his blog entries. It's rather complete from a Delphi perspective, so all that I would need to cover would be how to link a Delphi Win32 COM host with a VS.NET C# client. Somehow, I don't think that's nearly as exciting, since Brian did such an excellent job detailing COM Interop.

Hopefully this will give me a chance to talk about my custom COM audting/profiling solution instead.

Edited on 11/2/04 to update the links based on feedback from Brian Long. Thanks, Brian!

Monday, November 01, 2004 1:12:00 PM (Central Standard Time, UTC-06:00)  #    Comments [0] -
Delphi
 Wednesday, October 27, 2004
This is not YAGDSP (Yet Another Google Desktop Search Post). Well, not completely. ;-)

I like Google Desktop Search. It's lightning fast, and I like the idea and implementation. I think it will really get better once they release an API. For some reason, I never really latched on to IndexServer. I'm not sure why, it just seems too cumbersome or something. I like the concept of IndexServer, but I always end up using grep instead. Maybe it's just that Old Habits Die Hard.

But with GDS, I find myself using it more for some reason. However, as a Delphi or C# developer, you probably aren't deriving much benefit from this version of the GDS beta since pas and cs files are not indexed. Lord CRC (sorry, don't know his actual name) solved that problem by hacking the EXE to change the file extensions that are indexed. He also puts in some information on what you can do to fix this yourself if you're uncomfortable with using his hacked EXE. You can download the hack here.

Wednesday, October 27, 2004 11:07:00 AM (Central Standard Time, UTC-06:00)  #    Comments [1] -
Delphi
 Tuesday, October 26, 2004
Great. I've read about spamming in blog comments from some of the blogging luminaries. I've had a couple of spams so far, and I could deal with that. But, this morning I had 12 spams that I had to go delete. I guess I could spin this into some kind of positive that it means that someone actually thinks my blog is worth spamming, but I'm not going to go that far. :-)

So, if anyone has any links on how to effectively deal with blog comment spam (especially with .Text), I'm all ears. I don't want to turn off comments because I enjoy reading the responses. Thanks for any help.

Tuesday, October 26, 2004 8:42:00 AM (Central Standard Time, UTC-06:00)  #    Comments [3] -

 Monday, October 25, 2004
I love it when things just work the way they should. I've been developing a new product that relies heavily on a pluggable architecture using COM. During development, I started thinking that it would be nice to test out how well a C# component would work inside the architecture. As you can tell from the first line of this entry, it worked rather well. I plan on detailing a write-up of the details, but the short story is: it just works.

It's always refreshing to find technology that makes your life easier, instead of making the waters muddy and more difficult.

Monday, October 25, 2004 8:23:00 AM (Central Standard Time, UTC-06:00)  #    Comments [0] -
.NET
 Wednesday, October 20, 2004
We have several DataSnap (ugh, it still pains me to say that instead of MIDAS :-)) servers in our application suite. We can run them either as regular processes or services. Recently, one of our customers went to Windows 2003 and our applications quit working. It turns out that Microsoft made some changes in Win2003 that causes a "Server Execution Failed" error when running a COM server as a service.

While searching Google, I found one post from Anders Evensen, who had contacted Microsoft directly about the issue. According to him, "The problem is that Microsoft requires StartServiceCtrlDispatcher to be called before CoRegisterClassObject. However, this requirement has not been implemented in earlier versions of Windows than 2003. Windows 2003 checks that the service has been started before it allows CoRegisterClassObject to be called."

Delphi does this backwards, since StartServiceCtrlDispatcher is called in TService.Execute, and CoRegisterClassObject is called during the call to Application.Initialize. I ended up with the following solution, and things now work wonderfully on all Windows versions.


function IsRunningInInstallMode : Boolean;

  function FindSwitch(const Switch: string): Boolean;
  begin
    Result := FindCmdLineSwitch(Switch, ['-', '/'], True);
  end;

begin
  Result := FindSwitch('REGSERVER') or FindSwitch('UNREGSERVER')
    or FindSwitch('INSTALL') or FindSwitch('UNINSTALL');
end;

procedure TService1.ServiceExecute(Sender: TService);
begin
  { Windows 2003 Server support. The problem is that you should always call
    StartServiceCtrlDispatcher (done in VCL) before calling CoRegisterClassObject
    (done from Application.Initialize). Win2003 now enforces this explicitly, but
    earlier versions did nothing if this was done improperly. }
  if not IsRunningInInstallMode then
    SvcMgr.Application.Initialize;

  while not Terminated do
  begin
    ServiceThread.ProcessRequests(false);
    Sleep(500);
  end;
end;
Wednesday, October 20, 2004 3:51:00 PM (Central Standard Time, UTC-06:00)  #    Comments [3] -
Delphi
 Tuesday, October 19, 2004
Well, there's more there than just DataSnap stuff, but the DataSnap info coming out of this blog is top shelf.
Ondrej Kelle's Blog
DataSnap.NET
DataSnap Perfomance Counter Libraries writeup
DataSnap Performance Counter Libraries download

Keep up the good work, Ondrej!

Tuesday, October 19, 2004 8:08:00 AM (Central Standard Time, UTC-06:00)  #    Comments [1] -
DataSnap
Navigation
Archive
<November 2004>
SunMonTueWedThuFriSat
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2008
Dan Miser
Sign In
Statistics
Total Posts: 307
This Year: 22
This Month: 1
This Week: 1
Comments: 604
All Content © 2008, Dan Miser
DasBlog theme 'Business' created by Christoph De Baene (delarou)