Holger's Thoughts on Delphi

Friday, January 27, 2006

Winter ...

Well, it's Winter in Germany and not only humans love it :-)

 Posted by Picasa

And yes, that is also the reason why I spent a lot of time outside instead of writing technical blog articles.

Tuesday, January 24, 2006

"555" and IP addresses

This post is a little bit different from the last few. However, I have been asking this myself for quite some time, could not find any discussions about it on the net, so I thought I blog about it.

We all know that all American movies have phone numbers that start with "555". I noticed that whenever it is being talked about IP addresses in series and movies something like "355." or "295." is being said. Hmmm... As far as I know the biggest possible address is "". I really cannot believe that the writers of these shows overlooked this detail. I know about newer IP addressing versions, but these are not used on the internet yet as far as I know...

So I am thinking: Are movies and series using IP addresses that are in a range outside real IP addresses for the very same reasons that movie phone numbers start with "555"?

Just something to think about for the day. I am eager to hear your comments.

Saturday, January 14, 2006

Command Line Switch Helps Testing Packages

I never realized this, but Jeremy North gave me a wonderful idea when I had a look at his tool that lets you customize Delphi 2005 personalities for start-up.

BDS has the command-line switch -r which lets you define a registry key that is used instead of "BDS\4.0\" by the IDE.

So basically, if you start the BDS using: bds.exe -rTESTING you end up with an IDE that looks just like a newly installed version. No custom packages, no custom components are loaded that have not been installed with the Borland Installer. Basically, if you e.g. installed IntraWeb that comes with Delphi 2006, that package will be loaded, because it is part of your default install.

However, this environment is ideal if you want to check out packages that you are uncertain about and you can still keep your working environment undisturbed.

If you develop for multiple customers you can build yourself two shortcuts on your desktop. One shortcut executes bds.exe -rCUST_A the other one calls bds.exe -rCUST_B. So you have a customized IDE for your customers.

Also take note of the fact that there is also the -p command-line switch. That will only load a certain personality and can be combined with -r.

BDS 2006 is fast, but using these command-line switches will make it even more handy and snappy.

Monday, January 02, 2006

ECO: Using Building Blocks

My last post introduced you to the nice and pretty "Category" class. I also mentioned that you can use it in any ECO Application you might build. What I did not mention was... "How?"

Let me at first tell you how I built the Category class to make it easy inserting it into other applications. It is not difficult to use ECO classes from multiple packages in one ECO Space. The difficult thing to do is to refer to classes during design-time. In this example I will build an application that assigns categories to a product. That means I have to create an association from a class named "Product" to the already modeled "Category" class.

Step 1: Create a new ECO Package DLL. I used the C# personality for that. That is just my personal taste, of course. I can handle namespaces easier in C# that is the reason why I generate C# code for my models.

For that, go to "File / New...", select "Other..."...

... click on the correct personality and double-click the "ECO Package DLL" item.

Step 2: Name your model library appropriatly, remember to use namespaces. From my own experience, you get name conflicts if you do not create proper namespaces.

Step 3: Switch to the model view and rename "Package_1" to something that makes more sense. I named it "CategoryPkg" as it is the package for the category logic.

Step 4: You are ready to double-click on the package to design your class model. You can have a look at the previous post, what the class looks like.

That's it. This will make sure that you can use the business logic you define in the library in any other ECO application, even during design-time.

So, how do we actually include a model in another application during design-time? Well, I tried to find it in the help of D2006 and I actually could find zero on that topic. So, I will be very verbose and will try to give you as much information as I can.

First, create a new ECO application, of course, it could also be another library that is based on the other library. But we'll create a Delphi .NET Winforms Application in this example.

Before we start to design the classes belonging to that application, we will add a reference to the library, which contains the class "Category". I always use the Project Manager, right-click the "References"-node and click on "Add Reference...".

Select the library-file using the "Browse..."-button and click on "OK" to apply the changes. it is very important that you build your project now. I said build, not compile. Just in case.

The next step is to take care of the fact that we need the category class during design-time already. So right-click the exe-filename and choose the menu item named "Referred ECO Packages... ".
You have to browse for the "ecopkg"-file in your library project. Click on "Add..." to achieve that. Exactly, that means if you deploy a ECO library with classes to a customer, you also have to deploy all files named "ecopkg" as those contain the design-time information that make modeling with the classes in your library possible.
Save your project and close it. Sadly, this is necessary for the Model View to pick up the new ECO Package. I might be wrong, but I found no other means how to do it. If you did it correctly, you will have the referred ECO Package listed in the Model View as shown below.

After re-opening your project, open "Package_1" and add a class named "Product".

Right-click on the modeling workspace and choose "Add / Shortcut...". This will make it possible for you to add the class "Category" to the model.

In order to do it, you will have to expand the "References" node like I did it in the screenshot below. Be sure to select "Category" and not, like it is selected below, "MCategory", any other namespace or package. We want to add a shortcut to a class to the model, nothing else.
Good. Now we have a shortcut (as in Windows it is shown using an arrow in the corner) to Category in our model. Simply add an association between the two classes as you do it with any other class.

That's it. Yes, it is that easy. Build your project, switch to "Winform.pas" and implement the OnLoad event, for example. You will notice if you type the following code...

that the Product has a property called "Category". Even more surprising, it is of type "Category", just as we wanted it to be.

Isn't ECO just great? You just have to love it a little bit more because of this...