Saturday, June 12, 2010

A faq about using Bold for Delphi

A FAQ about Bold for Delphi
  1. What is the requirements to start using Bold ?
  2. What is UML ?
  3. What is ORM ?
  4. What is OCL ?
  5. What is a derived member ?
Q: What is the requirements to start using Bold ?
A: Currently Bold is only available in 3 editions, all in obsolete versions of Delphi:
  • Delphi 7 Architect.
  • Delphi 2005 Architect
  • Delphi 2006 Architect
  • Delphi 2007 using package from Delphi 2006
So Bold can be used with D2007 if the package was compiled with D2006 as they are binary compatible.

Q: What is UML ?
A: UML (Unified Modeling Language) is a standardized general-purpose modeling language. Bold use MDA (Model-driven architecture) meaning that a change of the model is the first step in development. Then that change is applied on the database. Then the code may be changed to adapt to the previous model changes. In UML you can specify relations between classes as singlelinks (on to one) or multilinks (one to many). Each class can have attributes of basic datatypes and methods attached.
See also UML on Wikipedia

Q: What is ORM ?
A: ORM (Object-relational mapping) means to convert relations in a traditional SQL database to objects in memory that can be used with a objectoriented language. It is of course possible to change objects and store them in the database. This makes programming much easier as it is not needed to write SQL to read and writa data from the database. It is much easier to write complex expressions if you don't need to use SQL.

Compare this by OCL ?:

PlanMission.allinstances->select(created > #2010-02-04).created

and in SQL:

SELECT created FROM PlanMission WHERE (PlanMission.Created > '2010.02.04')

See also ORM on Wikipedia.

Q: What is OCL ?
A: OCL (Object Constraint Language) is a language that is used a lot in Bold. It has no sideeffects meaning that there is no way of changing objects. All operations is read-only. It is easy to work with a list of objects and filter a certain property or type.

You can build an OCL expression in designtime by a dialog that contains a context sensitive list of keywords.












See also OCL on Wikipedia.

Q: What is a derived member ?
A: A derived member is typically not stored in the database. It is transistant and exists only in Bolds objectspace in RAM. For example if you have 3 classes Invoice, InvoiceRow and Vat.
The InvoiceRow have the attribute NetValue and a singlelink to Invoice. Invoice have a single link to Vat and a multilink InvoiceRows. Vat have an attribute VatValue.
Now InvoiceRow can have 2 derived attributes VatValue and TotalValue. Invoice can also have 3 derived attributes NetValue, VatValue and TotalValue. See the model.
UML model
So class Invoice have 3 attributes, InvoiceRow also 3 and Vat have 1. Only 2 of those 7 attributes are stored persistent in the database, The remaining 5 is marked as derived with a / before the name.

We can define the value for a derived attribute in a method or in OCL. Often OCL is simpler and safer. In code you have to take care of subscribing other attributes and objects in case they change. In OCL this occurs automatic.

OCL expressions for derived attributes:

  • InvoiceRow.vatValue: netvalue * mainInvoice.invoiceVat.vatValue
  • InvoiceRow.totalValue: netValue + vatValue
  • Invoice.netValue: invoiceRows.netValue->Sum
  • Invoice.vatValue: netValue * invoiceVat.vatValue
  • Invoice.totalValue: invoiceRows.totalValue->Sum
Derived attributes have the property that they are recalculated every time a dependent object change and that attribute is read.

NOTE: The recalc does only happen if the derived attribute is read.

In this case if one of the Invoicerows netValue change and this InvoiceRows vatValue is read it notice the change and recalc. But totalValue is not recalced until it is read. When Invoice.totalValue is read it will be recalced if any of the other attrbutes have changed value. If nothing has changed the attribute value is cached and the calculation will not happened.

This behaviour save CPU time specially for complex expressions. Compare if those attributes would be methods that do the calculations every time they where called. And of course the chain of derivations can be arbitrary long and complex.

8 comments:

  1. Hi, Roland!

    >There also exists non public versions of Bold compiled with Delphi 2007 as Boldsoft sold the source to some companies before it was bought by Borland.

    Packages for Delphi 2006 works with Delphi 2007

    You had a type this?

    ReplyDelete
  2. Hi, I have never used Delphi 2006 so this was new information for me. Thanks!

    ReplyDelete
  3. Hi, Roland!

    Interesting Your opinion on questions:
    1) Use Mechanism Propagator
    2) Control RAM use object-space (xxx.Free)
    3) Bold + DevExpress

    ReplyDelete
  4. 1) Never heard, can you give a reference ?
    2) Also here not sure what you mean.
    3) An excellent combination! We have bought a solution with source that make the Devexpress grid bold aware. So now we are in the process of converting old grid types to the new one. The benefit will be both a modern GUI and an easy to use (for developer) bold aware grid. Later we may continue with textboxes like TcxTextEdit and make them bold aware.

    ReplyDelete
  5. 1) Propagator falls into standard supply BOLD. It Is Used for synchronizing object-space on different hosts.

    2) You free memory use object-space? , or she is accumulated ad infinitum?

    3) Can You give a reference to this solution (Where possible gets acquainted and buy)?

    ReplyDelete
  6. Ok, now I understand you better.

    1) Yes, as each user have it's own object space we must of course do synchronizing. It is basically done with a simple service (developed by us) on a server that all clients are connected to. That says what boldids are dirty so they can be reloaded from database.

    2) No we currently not free the memory. I have some ideas how it could be done. Each client have a limit of 2 GB. In practice around 1,3 - 1,7 there is a chance of out of memory. I see this as one of the few weakness of Bold. Of course we are waiting impatiently for the release of a 64-bit compiler for Delphi.

    3) We have bought our bold aware DevExpress grid from Christophe Floury, (christophefloury on Skype). He has also developed Bold Express, that makes it possible to get access to Bolds objectspace from a webpage. We have hired Christophe a lot as consultant over the years and still do. Christophe just packaged the grid and other components for our needs. He in turn bought the grid from Daniel Mauric (dmauric on Skype) that did the coding.
    If you are interested I recommend you to contact them. They are both nice to talk with.

    ReplyDelete
  7. Roland, thank you for information.

    I also has developed its Propagator on TCP/IP, as standard DCOM and Bold TCP OSS not can to use.

    I use DevExpress (QuantumGrid6 -> BoldDataSet(Changed by me for DevEx) -> BoldHandle). Beside You, I so understand, is changed itself QuantumGrid.
    Bold Express(for webpage) - interesting lead. What architecture to it? He works with Apache?


    As you value the appearance Bold for Delphi2010 (ver>2009)?

    ReplyDelete
  8. I think Boldexpress is used with Microsoft IIS, not sure if it works for Apache. And yes of course I want a Bold for Unicode so we can use Delphi 2009 or 2010. As we have the source it is just a lot of work to convert it and verify the result... Probably we don't do this until there is a 64-bit delphi compiler as Unicode take more memory and we already have problems with the 2 GB limit per process.

    ReplyDelete