Malcolm Groves
Subtracting from the sum of human knowledge
 
  Index

  Home
Projects
Writing
About Me

 
   
  Blog Categories

  All Posts
Borland
ECO
Personal
Photos
Projects
Misc.

 
   
  Recent Blog Entries

 

 
   
  Previous Posts

 
March 2006
Sun Mon Tue Wed Thu Fri Sat
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31  
Jan   Apr


 
   
 
 
Recent Posts
Click to see the XML version of this web page.

 

Wednesday, 18 January 2006

ECO III at ADUG Sydney

I'll be showing off some of the new features of ECO III at tonight's ADUG (Australian Delphi User Group) Sydney meeting.

It's essentially a repeat of my Borcon US session. Borland will be providing the pizza and drinks, so come along if you can.

|



Wednesday, 26 October 2005

ECO is Child's Play

I saw the rough recordings of this awhile back, but I just watched it again now that it's been posted on BDN.

I thought I was getting reasonably good at explaining this ECO thing, but I bow to the master (mistress?)

http://bdn.borland.com/article/0,1410,33331,00.html

|



Thursday, 29 September 2005

Centillex ECOAccess

One of the things I've added to my "Things to tinker with when I get time" list is this ECO add-on from Thailand:

Centillex EcoAccess is a free library to enable declarative data access services for Borland ECO. It provides flexibilities to declare methods for querying or accessing ECO objects via OCL expression.

OK, so that meant bugger all to me as well when I read it, but looking at the code in the tutorials on the site, it makes a bit more sense.

Still not sure if I'd use it or not, but their use of attributes has got me curious. Worth a couple of hours playing with it to see, I think.

|



Monday, 26 September 2005

This one's going straight into the pool room

I spoke with Matthew Overington, a journalist in Australia, a little while back about Model Driven Development in general, and ECO in particular. The resulting article showed up on BuilderAU back in August.

I wouldn't normally post links to sites that have linked to an article I'm in, but I'm so tickled by this one, I just had to post. The article has been referenced on the Healthy Hair website, specifically on the Hair Loss blog (Who knew there was a blog about hair loss? Why wasn't I told?).

Now the less kind amongst you who know what I look like, will no doubt be able to construct some terribly amusing reason why I'd be on this site. Oh, how we'd laugh! Sorry to spoil it for you, but you'd be wrong. There were no photos in the article. Ha!

My mum will be so proud. I'm not even upset that they messed up the quote. This one's going straight into the pool room.

|



Monday, 19 September 2005

Real life complexity with ECOII. Part 1

Hans Karlsen has published the first in a series of articles covering his use of ECO II to deal with more real world complexity. Good stuff, especially if you've been wondering about Nestings.

|



Monday, 29 August 2005

ECO : Autoforms and Form Factories

I've been in New Zealand this week doing some Borland Developer Day's events. Mornings we've been focusing on ECO, afternoons we've been focusing on the new MDA features in the next version of Together.

Anyway, during the ECO session in Wellington, I was talking about the AutoForms capabilities, and how you could register your own AutoForms for specific types. This is a really useful feature, as you can use the default AutoForm during early parts of your development, so that you can focus on getting the model developed, and then when ready, you can create custom forms to be used to view and edit your objects. Registering them with the AutoForm service means that you don't have to change any of the code in your app that display's your AutoForm, it will automatically use the new form you have registered.

After the session, one of the guys in the audience who'd been using ECO for awhile came up to me asked how to do this. To be honest, I thought I'd already blogged about this. Apparently not, so I had a few hours to kill in the Qantas lounge in Christchurch while I waited for my flight home, so I thought I'd write something up. You can grab the sample code here.

A few things first. If you haven't seen the default AutoForm capabilities, download the source for this project and open it in Delphi 2005 Architect. Bring up Winform1, and note that I've set the ECOAutoForm property on the grdAllPeople DataGrid to True. Now I can simply double-click on a row in my grid, and an autoform will be created.  This is probably the simplest way to get ECO to display an AutoForm for an object.

NB: If you can't see an ECOAutoForm property in the DataGrid's on your form, you probably need to add an ECOAutoFormExtender component to the form. This will insert some ECO-specific properties into the DataGrid.

Also click on Button3, which is the button labeled "Show  Autoform" next to the upper grid. I've also set it to display an AutoForm for the currently selected Person in the grid. I've enabled this by setting it's ECOListAction property to ShowAutoForm, and setting its BindingContext to my grdAllPeople grid, and its RootHandle property to the ExpressionHandle holding the collection of Person objects, in this case, ehAllPeople. This is probably the second simplest way to display an AutoForm for an object.

If you want to display an autoform for an ECO object via some other method (e.g., via a context menu, etc), then the following code (Which is also in the Click event of Button4 in the sample project) will achieve the desired result:

procedure TWinForm1.Button4_Click(sender: System.Object; e: System.EventArgs);
var
  autoContainer: IAutoContainer;
begin
  if Assigned(cmhSelectedAppointment.Element) then
  begin
    autoContainer := AutoContainerService.Instance.CreateContainer(
                       cmhSelectedAppointment.Element,
                       AutoContainerArgs.Create(EcoSpace,
                                                False,
                                                AutoContainerMemberVisibility.AllMembers,
                                                ContainerReusage.NeverReuse));
    if Assigned(autoContainer) then
    Form(autoContainer).Show;
  end;
end;
 

Firstly, we're checking that an Appointment object has been selected in our grid, by seeing if the Element attribute of our CurrencyManagerHandle is assigned. Then, we're using the AutoContainerService's CreateContainer method to get back a reference to an IAutoContainer for the selected Appointment. Lastly, provided we got back a reference, we're casting it as a Form and calling show to display it.

Running the project should show that clicking the button to invoke this code has the same result as double clicking in the grid.

Personally any time I want to display a form in my ECO apps, I use this code. Yes, it's longer than just creating an instance of a custom form and assigning the ECOSpace and the ECO object you want to edit. However, bear with me for a minute and hopefully you'll see the advantage.

Open the fAppointmentAutoForm unit and have a look at the TAppointmentForm it contains. I designed this form like I would design any other ECO Winforms. File | New | Other...ECO Enabled Windows Form, drop my controls down. set the ReferenceHandle's ECOSpaceType and StaticValueTypeName properties, set up my databinding, etc. To convert this form into an ECO AutoForm, I have to do a few things:

1. Extend your form class so that it implements the IAutoContainer interface. You'll need to add the Borland.Eco.AutoContainers and the Borland.Eco.ObjectRepresentation namespaces to your interface uses clause. Use Ctrl-Space from within your class declaration to declare the BuildControls, HookUpGUI and set_ECOSpace methods, and extend the declaration of your EcoSpace property so that has a setter method (the aforementioned set_EcoSpace).

2. Ctrl-Shift-C from inside the form classes declaration to stub out the implementations of these new methods. The code within them looks like the following:

procedure TAppointmentForm.set_EcoSpace(value: EcoSpace);
begin
  if value <> FEcoSpace then
    FEcoSpace := value;
end;

procedure TAppointmentForm.HookUpGUI(ecoSpace: EcoSpace; element: IElement);
begin
  FEcoSpace := ecoSpace;
  RHRoot.EcoSpace := self.EcoSpace;
  RHRoot.SetElement(element);
end;

procedure TAppointmentForm.BuildControls(element: IElement;
autoContainerArgs: AutoContainerArgs);
begin
  // don't need to do anything, unless you intend writing a generic
  // autoform
end;
 

Most of these should be fairly self explanatory. The BuildControls method is empty, however if you wanted to dynamically create controls on your AutoForm, this is where you'd do it.

3. So, now our AutoForm is complete, however we need to register it with the AutoFormService. To do ths, we define a simple Factory class. In the same unit, you'll see this under my form declaration. Its delcaration looks like this:

AppointmentAutoContainerFactory = class(System.Object, IAutoContainerFactory)
public
  function get_AutoContainer: IAutoContainer;
  function Matches(modelElement: IModelElement): Boolean;
end;

Its implementation looks like this:

function AppointmentAutoContainerFactory.get_AutoContainer: IAutoContainer;
begin
  Result := TAppointmentForm.Create(nil);
end;

function AppointmentAutoContainerFactory.Matches(modelElement: IModelElement): Boolean;
begin
  Result := modelElement.Name.Equals(Appointment.ClassName);
end;

You may need to add the Borland.Eco.UmlRt namespace to your Interface uses clause. The get_AutoContainer method is where we actually create an instance of our form. The Matches method will be called by the ECO Framework, passing in a reference to the model element for which it is trying to create an AutoForm. Your job in this method is to decide if your form will handle this class, in this case I'm checking whether it represents an Appointment, and if so returning true.

4. Lastly, I need to register my Factory with the AutoForm service, by adding the following code to the initialization section of the unit:

initialization
 AutoContainerService.Instance.AddFactory(AppointmentAutoContainerFactory.Create);
finalization

That's it. Now when you run your app, you should notice that when you request an autoform for an Appointment object you'll get back our new form. This is regardless of how you request it (i.e.. double clicking in your grid, using the ECOListAction on your button, using the AutoForm code, ECOSpaceDebugger etc). You don't need to change any of your forms, you can make the change in one place and the rest of your app will follow. Way cool!

In the sample code, the initialization section code is commented out, so you can easily see the before and after effect.

|



Wednesday, 13 July 2005

24 hours of Delphi

So, we're getting close to the 24 hours of Delphi online radio thingy (yes, I think that's the official name). The schedule is up here

I'm going to be on at midnight PST, and then again at 11pm PST (which thankfully is a much more civilised 5pm and 4pm respectively where I am), but I'll be sticking my head in whenever I can. I'll also be making an effort to be online for the ECO bits, which are:

  • 3:00 am PST with Jan
  • 3:45 am PST with Jonas
  • 10:00 am PST with Daniel
  • 7:00 pm pST with Randy
  • 10:00pm with Tim and Dick
Hmm and Brian Long is always good value, and Marco, and..., OK, looks like I'm not going to get much work done for the next 24 hours.

|



Monday, 4 July 2005

OCL : subSequence

I think I've mentioend before that I've been working on an internal website using ASP.NET and ECO II. Partly because replacing the current site (based on static HTML) is going to make my life a lot easier, but also as I kinda miss coding as a day job, and of course if you want to really learn a new technology like ECO, there's no substitute for actually building and deploying an app into production.

Anyway, one of the things I wanted to do was to display summary lists of items on the main page of the site. You know, recently posted items, important upcoming dates, last 10 posts to the SE mailing list, etc. Most of this is easy, OCL like the following will pull out all Items in reverse order (ie. most newest to oldest).

Item.allInstances->orderdescending(ModifiedTime)

Problem is, I don't want to display all Items, only the most recent items, say, the last 10. Enter the subSequence operator:

Item.allInstances->orderdescending(ModifiedTime)->subSequence(1,10)

With this, I have a list of 10 Items, starting at position 1 in my list of Items ordered by ModifiedTime. Perfect!

|



Wednesday, 8 June 2005

ECOSpaceDebugger

ECO lets you move from building your model to executing and interacting with that model incredibly quickly. The model-aware framework with its databinding support, autoforms capabilities, etc mean you can build UI's that let you play with your model faster than any other tool.

However, ungrateful bugger that I am, I'm now spoiled and "incredibly quickly" just isn't fast enough anymore. What I want is a way to create my model, and without setting up anything, I want to be able to interact with it. Or more often, change my model, and test out my changes immediately, without adding the necesary UI bits until I know that it works how I want it to work.

Well, lurking away in a dark corner of the ECO Framework is something that gets me very close to that. The ECOSpace Debugger gives you a UI that lets you, amongst other things:

  • create, edit and delete instances of objects in your model
  • bring up autoforms for an object
  • set Checkpoints, then undu and redo changes
  • start, commit and rollback object transactions

At the moment you still need to write the code to invoke the ECOSpace Debugger, but it's only a couple of lines, so that's still pretty amazing.

Here's the steps to try it out:

  • Create a new Winforms ECO app
  • Define a few classes and associations in your model
  • Add the Borland.ECO.Diagnostics namespace to your mainform's uses clause.
  • Drop a button on your mainform, and in the Click event add the following code:

EcoSpaceDebugger.Create(EcoSpace).Show;

That's it! Run your app, click the button, and you can start playing with your model. Change your model, run the app again and interact with your changes. How simple is that?

If you want to have a bit more of a sniff around, double-click on the Borland.Eco.Windows.Forms.dll in the References section of the Project manager, and drill down into the Borland.Eco.Diagnostics namespace using the Reflection tool built into the IDE.

I did say I was ungrateful. Now that I have this, I want to get rid of that button and line of source. Like maybe by creating a non-visual component that shows the debugger on create, if a boolean property is set to true. Hmmm, maybe on my next flight...

|



Wednesday, 20 April 2005

Custom OCL Operations

Jonas has just updated the ECO pmwiki with an interesting post on creating custom OCL operations, along with an example that implements a bunch of DateTime functionality that you can invoke from OCL. One of the guys mentioned this a few months back, and I've been waiting since then to get my hands on it. Hmmm, wonder if I have time to play tonight.....

|