Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2012-10

Design Patterns Questions

11 messages · 5 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

bsquared

Hi all,

It has been some time since I have used FPC/Laz. I was looking for some information on 'observer pattern' the other day, and I found this article[1]. I notice that it is a bit old, and it makes me question whether or not I have made an error following it.

I get an invalid cast error at this code
   (DigitalClock1 as ISubject).Attach(fClockTimer as IObserver);
which is actually flipped and should be
   (fClockTimer as ISubject).Attach(DigitalClock1 as IObserver);

So, my questions ...
Is the article out of date?
Are these patterns implemented in the base code?
And as an aside, what is the state of tiOPF, I could not get it to install in Lazarus 1.02.

Thank you.

[1] - http://blogs.teamb.com/joannacarter/2004/06/30/690

Regards, Brian
bsquared
to bsquared
bsquared wrote 6 lines
Hi all, It has been some time since I have used FPC/Laz. I was looking for some information on 'observer pattern' the other day, and I found this article[1]. I notice that it is a bit old, and it makes me question whether or not I have made an error following it.

While stepping through the code I found that I had made an error.

Show quoted text 16 lines
I get an invalid cast error at this code (DigitalClock1 as ISubject).Attach(fClockTimer as IObserver); which is actually flipped and should be (fClockTimer as ISubject).Attach(DigitalClock1 as IObserver); So, my questions ... Is the article out of date? Are these patterns implemented in the base code? And as an aside, what is the state of tiOPF, I could not get it to install in Lazarus 1.02. Thank you. [1] - http://blogs.teamb.com/joannacarter/2004/06/30/690

I am still interested in the other questions.

Thank you.

Regards, Brian
Ewald
to bsquared: It has been some time since I have used FPC/Laz. I was looking for some information on…

You might find some info on the list archive for fpc-devel: http://lists.freepascal.org/lists/fpc-devel/2012-October/030149.html

Ewald On 10/28/2012 04:09 PM, bsquared wrote: > Hi all, > > It has been some time since I have used FPC/Laz. I was looking for some > information on 'observer pattern' the other day, and I found this > article[1]. I notice that it is a bit old, and it makes me question > whether or not I have made an error following it. > > I get an invalid cast error at this code > (DigitalClock1 as ISubject).Attach(fClockTimer as IObserver); > which is actually flipped and should be > (fClockTimer as ISubject).Attach(DigitalClock1 as IObserver); > > So, my questions ... > Is the article out of date? > Are these patterns implemented in the base code? > And as an aside, what is the state of tiOPF, I could not get it to > install in Lazarus 1.02. > > Thank you. > > [1] - http://blogs.teamb.com/joannacarter/2004/06/30/690
Michael Van Canneyt
to bsquared: It has been some time since I have used FPC/Laz. I was looking for some information on…
bsquared wrote 15 lines
Hi all, It has been some time since I have used FPC/Laz. I was looking for some information on 'observer pattern' the other day, and I found this article[1]. I notice that it is a bit old, and it makes me question whether or not I have made an error following it. I get an invalid cast error at this code (DigitalClock1 as ISubject).Attach(fClockTimer as IObserver); which is actually flipped and should be (fClockTimer as ISubject).Attach(DigitalClock1 as IObserver); So, my questions ... Is the article out of date? Are these patterns implemented in the base code?

The observer pattern is implemented in tiOPF.

And as an aside, what is the state of tiOPF, I could not get it to install in Lazarus 1.02.

Version 3 is designed to work with Delphi 2009 and higher. Graeme Geldenhuys actively maintains tiOPF version 2. It works definitely with Lazars 1.0.2, I use it myself.

Michael.

bsquared
to Juha Manninen: tiOPF2 works with Lazarus but the visual data-components included in tiOPF do not work.…
Juha Manninen wrote 14 lines
On Sun, Oct 28, 2012 at 5:09 PM, bsquared wrote: > And as an aside, what is the state of tiOPF, I could not get it to > install in Lazarus 1.02. tiOPF2 works with Lazarus but the visual data-components included in tiOPF do not work. It is not a big problem because you can still use the persistence system and MGM (Model GUI Mediator). Juha _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Thank you for responding.

What version of tiOPF should I use. I tried both 2 and 3, but got several different errors when attempting to compile demos.

Regards, Brian
bsquared
to Michael Van Canneyt: The observer pattern is implemented in tiOPF. Version 3 is designed to work with Delphi…
Michael Van Canneyt wrote 35 lines
On Sun, 28 Oct 2012, bsquared wrote: > Hi all, > > It has been some time since I have used FPC/Laz. I was looking for some > information on 'observer pattern' the other day, and I found this > article[1]. I notice that it is a bit old, and it makes me question > whether or not I have made an error following it. > > I get an invalid cast error at this code > (DigitalClock1 as ISubject).Attach(fClockTimer as IObserver); > which is actually flipped and should be > (fClockTimer as ISubject).Attach(DigitalClock1 as IObserver); > > So, my questions ... > Is the article out of date? > Are these patterns implemented in the base code? The observer pattern is implemented in tiOPF. > And as an aside, what is the state of tiOPF, I could not get it to > install in Lazarus 1.02. Version 3 is designed to work with Delphi 2009 and higher. Graeme Geldenhuys actively maintains tiOPF version 2. It works definitely with Lazars 1.0.2, I use it myself. Michael. _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Thank you for responding. I thought I recalled a stipulation for version 3. I noticed it had an Compilers/FPC folder, so I hoped it was compatible.

Having trouble getting V2 demos to work. Have to
Regards,
Brian

Juha Manninen
to bsquared
bsquared wrote
Having trouble getting V2 demos to work. Have to is a different folder for Lazarus demos. The AddressBook demo is

the most comprehensive. I don't have it installed on this machine so cannot check the paths.

Juha

Graeme Geldenhuys
to bsquared: Thank you for responding. What version of tiOPF should I use. I tried both 2 and 3, but…
bsquared wrote 9 lines
On 10/28/2012 08:53 AM, Juha Manninen wrote: > On Sun, Oct 28, 2012 at 5:09 PM, bsquared wrote: >> And as an aside, what is the state of tiOPF, I could not get it to >> install in Lazarus 1.02. > > tiOPF2 works with Lazarus but the visual data-components included in > tiOPF do not work. > It is not a big problem because you can still use the persistence > system and MGM (Model GUI Mediator).

Correct. I gave up trying to implement the tiOPF-aware GUI components with LCL, because LCL and the Lazaurus Forms Designer was simply too buggy. Others are welcome to contribute to this.

MGM is just another implementation of Model-View-Controller with a few tweaks to work better with more modern GUI toolkits that have there own events built-in.

MGM has been used in production systems since 2006, so works very well, and supports fpGUI, LCL and VCL. Any standard GUI components not supported by MGM yet, can very easily (a matter of minutes) be supported.

To getter a better background on MGM and how it uses the Observer and Mediator design patters, you can look at an old article I wrote for the Toolbox magazine.

http://opensoft.homeip.net/articles/

There are a few other articles up there too.

What version of tiOPF should I use. I tried both 2 and 3, but got several different errors when attempting to compile demos.

For use with FPC - you can only use tiOPF2. tiOPF3 is currently Delphi only because it only supports Delphi 2009 and newer features. FPC is still too incompatible to those Delphi versions.

Regards,
- Graeme -

Graeme Geldenhuys
to bsquared: Thank you for responding. I thought I recalled a stipulation for version 3. I noticed…
bsquared wrote
> Graeme Geldenhuys actively maintains tiOPF version 2.

Yeah, his always hard at work. ;-)

> It works > definitely with Lazars 1.0.2, I use it myself.

+1

Thank you for responding. I thought I recalled a stipulation for version 3. I noticed it had an Compilers/FPC folder, so I hoped it was compatible.

tiOPF3 was forked from tiOPF2 a few years back, so the directory structures are identical. We left the Compilers/FPC directory in tiOPF3, but not expecting FPC to take so long to catch up to Delphi languages features.

Having trouble getting V2 demos to work. Have to demos have you tried? I'm reworking and reorganizing the Demos

directory as we speak. You should try the Demos/LCL/ directory if you use LCL toolkit, or Demos/fpGUI/ if you use the fpGUI toolkit. I haven't ported all the VCL demos to LCL or fpGUI yet, but the code is near identical. So even though you can't run the VCL demos, you can still look at them and learn from the code. If still lost, pop in at tiopf.support newsgroup and I'll help where I can.

Using a NNTP news client like Thunderbird:
news://news.tiopf.com

Or using a web browser via the web interface:
http://opensoft.homeip.net/webnews/

Regards,
- Graeme -

bsquared
to Graeme Geldenhuys
Graeme Geldenhuys wrote 47 lines
On 28/10/2012 16:42, bsquared wrote: >> Graeme Geldenhuys actively maintains tiOPF version 2. Yeah, his always hard at work. ;-) >> It works >> definitely with Lazars 1.0.2, I use it myself. +1 > Thank you for responding. I thought I recalled a stipulation for > version 3. I noticed it had an Compilers/FPC folder, so I hoped it was > compatible. tiOPF3 was forked from tiOPF2 a few years back, so the directory structures are identical. We left the Compilers/FPC directory in tiOPF3, but not expecting FPC to take so long to catch up to Delphi languages features. > Having trouble getting V2 demos to work. Have to keep at it. Which demos have you tried? I'm reworking and reorganizing the Demos directory as we speak. You should try the Demos/LCL/ directory if you use LCL toolkit, or Demos/fpGUI/ if you use the fpGUI toolkit. I haven't ported all the VCL demos to LCL or fpGUI yet, but the code is near identical. So even though you can't run the VCL demos, you can still look at them and learn from the code. If still lost, pop in at tiopf.support newsgroup and I'll help where I can. Using a NNTP news client like Thunderbird: news://news.tiopf.com Or using a web browser via the web interface: http://opensoft.homeip.net/webnews/ Regards, - Graeme - _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Thank you. I'll check in at tiopf for follow up.

Regards, Brian