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
Tracked by:
http://9nc-information.info/86423578/index.html [Pingback]
http://9nn-information.info/40095048/index.html [Pingback]
http://9nr-information.info/38491772/index.html [Pingback]
http://9nf-information.info/13799448/index.html [Pingback]
http://9nr-information.info/04522613/index.html [Pingback]
http://9no-information.info/89751214/ekg-machine-with-pft.html [Pingback]
http://9nb-information.info/58627883/5-day-greek-islands-cruise.html [Pingback]
http://9nt-information.info/12316740/index.html [Pingback]
http://9ne-information.info/13584719/tv-remote-control-for-elderly.html [Pingback]
http://9np-information.info/21218839/index.html [Pingback]
http://9nv-information.info/36380667/how-do-sonic-games-get-created.html [Pingback]
http://9np-information.info/68290836/home-ownership-and-social-security.html [Pingback]
http://9qb-information.info/90566314/index.html [Pingback]
http://9op-information.info/09738098/office-work-space-for-rent.html [Pingback]
http://9qc-information.info/34820842/negozio-di-accessorio-per-la-casa.html [Pingback]
http://9ox-information.info/76669909/online-marketing-small-business.html [Pingback]
http://9qk-information.info/28434194/alimentazione-nord-sud-mondo.html [Pingback]
http://9qe-information.info/20166610/index.html [Pingback]
http://9oh-information.info/97490039/index.html [Pingback]
http://9sn-information.info/58631959/index.html [Pingback]
http://9sa-information.info/99640221/impostare-cardiofrequenzimetro.html [Pingback]
http://9rn-information.info/42617537/deutz-1015-service.html [Pingback]
http://9rt-information.info/74152015/index.html [Pingback]
http://9st-information.info/13655253/crociera-egitto-brothers-island.html [Pingback]
http://9rq-information.info/77200186/index.html [Pingback]
http://9sr-information.info/84592660/index.html [Pingback]
http://9uafg-le-informazioni.info/75137750/argenina.html [Pingback]
http://9uaeb-le-informazioni.info/22876358/index.html [Pingback]
http://9uaff-le-informazioni.info/08770219/index.html [Pingback]
http://9uafn-le-informazioni.info/94159734/attiva-dominio-primo-anno-gratis.html [Pingback]
http://9uaes-le-informazioni.info/56156556/index.html [Pingback]
http://9uafp-le-informazioni.info/28851724/index.html [Pingback]
http://9uafc-le-informazioni.info/51844701/index.html [Pingback]
http://9uafl-le-informazioni.info/46565082/index.html [Pingback]
http://9uagj-le-informazioni.info/78879746/comunicazione-rspp-direzione-provinci... [Pingback]
http://9uagr-le-informazioni.info/26730615/index.html [Pingback]
http://9uagr-le-informazioni.info/14829568/index.html [Pingback]
http://9uaht-le-informazioni.info/46889833/index.html [Pingback]
http://9uahh-le-informazioni.info/63186267/perl-howto.html [Pingback]
http://9uagl-le-informazioni.info/42588096/index.html [Pingback]
http://9uagd-le-informazioni.info/51458125/index.html [Pingback]
http://9uahi-le-informazioni.info/08415584/zen-essential.html [Pingback]
http://9uagp-le-informazioni.info/85441063/asus-router-wireless.html [Pingback]
Thursday, November 04, 2004 6:43:00 PM (Central Standard Time, UTC-06:00)
Thanks for this Dan, it looks like it will be very useful. Since it seems to be based on ASP.NET I wonder if it's possible to use Delphi as the source language as well as the target language?
Sunday, November 07, 2004 12:07:00 AM (Central Standard Time, UTC-06:00)
You just now found out about this fine product? I registered it, awesome product!
Monday, November 08, 2004 2:57:00 PM (Central Standard Time, UTC-06:00)
I've been looking for more Delphi-orientated CodeSmith templates. I've been creating type-safe lists using GExperts Macro Expert. Basically I have one macro for the interface section and another for the implementation. It prompts for the object you wish the list to contain and does everything else. I'll give this one a whirl and see how it feels compared to the macro expert.
Shawn Oster
Thursday, July 07, 2005 12:42:00 PM (Central Standard Time, UTC-06:00)
Code Smith isn't free.
Dave
Comments are closed.
Navigation
Archive
<November 2008>
SunMonTueWedThuFriSat
2627282930311
2345678
9101112131415
16171819202122
23242526272829
30123456
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: 310
This Year: 25
This Month: 0
This Week: 0
Comments: 605
All Content © 2008, Dan Miser
DasBlog theme 'Business' created by Christoph De Baene (delarou)