Recent

Author Topic: OOP structures in fpc and Lazarus  (Read 23819 times)

jollytall

  • Sr. Member
  • ****
  • Posts: 303
OOP structures in fpc and Lazarus
« on: November 05, 2021, 03:50:50 pm »
I read a lot the documentation, this forum and made my own experiences with various OOP structures, like advanced records, objects, classes. Over time I gathered a lot of information, and put it all in one document originally for myself, but now I share it hereby.
It is rather long, but I tried to cover everything that caused a problem to me and what was not obvious to find in the documentations.
I am glad if I can help anyone with it, and also would be very thankful to those who know more about these topics and take the time to read it and provide feedback.
Please feel free to write any error you find, any comment you have or any topic that should be added.
For the time being it will be here, so if you want to share, please distribute this link rather than a copy of the document. I expect it to be updated, so a copy is a dead-end with a half ready document.

P.S. It was written as.odt originally (55Kb), but it could not be attached, so I saved as .docx (47Kb). Neither could upload that. Tried to save as .doc or .pdf (250Kb) and even renaming the smaller .docx to .doc, but none of them worked. For the three latter cases the form to Post simply did nothing. Any idea, what can be wrong?

MarkMLl

  • Hero Member
  • *****
  • Posts: 6646
Re: OOP structures in fpc and Lazarus
« Reply #1 on: November 05, 2021, 03:56:00 pm »
Try putting it in a pdf and zipping it.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: OOP structures in fpc and Lazarus
« Reply #2 on: November 05, 2021, 04:02:55 pm »
Any idea, what can be wrong?
I'm sorry. but your approach to distributing the techy information in 21st century is wrong.

Don't make people download your file and read it.
Instead you need to write up the article on some online blogging platform and share the link.
(And Google will be your friend, in terms - your article will become the part of the "search results" for Pascal and OOP)

You can write the same article on the Freepascal wiki, yet this might undermine your authorship of the content. (as wiki page is intended to be multiauthor)

If you really want to go old-school, you might want to write a book about pascal.
But sharing the book on the forum... is good as dead.  Sure... 5 people will download and maybe even read it. But that's it.
Don't let your effort to get wasted - go public! go online!

jollytall

  • Sr. Member
  • ****
  • Posts: 303
Re: OOP structures in fpc and Lazarus
« Reply #3 on: November 05, 2021, 04:14:49 pm »
It is a shame, the zip-ed pdf is still 220 Kb.

jollytall

  • Sr. Member
  • ****
  • Posts: 303
Re: OOP structures in fpc and Lazarus
« Reply #4 on: November 05, 2021, 04:17:30 pm »
I'm sorry. but your approach to distributing the techy information in 21st century is wrong.

You are right, but...
I see that in this community there are always people who are willing to help, correct, etc.
If once it goes through the validation, I am happy to share it in any form, wiki, whatever; I do not have copyright concerns.

BobDog

  • Sr. Member
  • ****
  • Posts: 394
Re: OOP structures in fpc and Lazarus
« Reply #5 on: November 05, 2021, 04:26:23 pm »

"OOP structures in fpc and Lazarus"
I like the OOP in fpc, I haven't posted much OOP, but I am working away in the background.
But not being a Lazarus ide user (very much), is there a difference in OOP between the two?

jollytall

  • Sr. Member
  • ****
  • Posts: 303
Re: OOP structures in fpc and Lazarus
« Reply #6 on: November 05, 2021, 05:13:37 pm »
Not really. Lazarus is just an IDE for FPC.
The only difference, (what is not yet included in my doc), that Lazarus has a whole set of classes defined for visual access, but they are start from TObject, then TPersistent and TComponent. Those can also be accessed from a plain source, but the great benefit of Lazarus that you can design your visuals WYSIWYG. Actually there are many other non-visual components, what I am not too keen on (anything from networking to database, etc.), but there I personally prefer programming them the normal way.

ccrause

  • Hero Member
  • *****
  • Posts: 843
Re: OOP structures in fpc and Lazarus
« Reply #7 on: November 05, 2021, 05:24:04 pm »

"OOP structures in fpc and Lazarus"
I like the OOP in fpc, I haven't posted much OOP, but I am working away in the background.
But not being a Lazarus ide user (very much), is there a difference in OOP between the two?
Lazarus also uses fpc as the compiler, so it is not necessary to mention Lazarus when discussing language features (IMHO). 

Lazarus does provide a lot of editorial help that makes it easier and faster to create and maintain classes (and objects, advanced records...) e.g. by creating empty methods in the implementation section that corresponds to methods declared in a class, synchronization of parameters between interface and implementation and so forth.

Edit: I see @jollytall was a bit quicker to post...

Lulu

  • Full Member
  • ***
  • Posts: 226
Re: OOP structures in fpc and Lazarus
« Reply #8 on: November 05, 2021, 08:55:22 pm »
@jollytall: thanks You to share ! :)
wishing you a nice life

MarkMLl

  • Hero Member
  • *****
  • Posts: 6646
Re: OOP structures in fpc and Lazarus
« Reply #9 on: November 05, 2021, 10:01:20 pm »
It is a shame, the zip-ed pdf is still 220 Kb.

Yes, because AIUI PDF is basically compressed Postscript.

I'm working through it with interest, but noting your overall approach you might find http://web.engr.oregonstate.edu/~budd/Books/leda/ of interest.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

jollytall

  • Sr. Member
  • ****
  • Posts: 303
Re: OOP structures in fpc and Lazarus
« Reply #10 on: November 10, 2021, 04:20:50 pm »
Well, not many comments yet, so I try to ask some of the questions raised in the document, explicitly here:
Q1. Mode and Modeswitch for advanced records
I analyzed and wrote that it is a bit tricky what mode to use to be able to use advanced records.
- In Mode delphi everything (instance and class level fields and methods) is possible, no need of modeswitch advancedrecords.
- In Mode objfpc also everything is possible, but advancedrecords is also needed.
- In Mode fpc even with advancedrecords, only the instance level fields and methods are available, class level is not possible.
What is the logic of this set-up? Why are objfpc and advancedrecords sort of independent, and not one including the other (either way)?

cdbc

  • Hero Member
  • *****
  • Posts: 995
    • http://www.cdbc.dk
Re: OOP structures in fpc and Lazarus
« Reply #11 on: November 10, 2021, 06:37:53 pm »
Hi
Short answer:
0)  Get a Github account - It's free.
1)  Create a repository for your document.
2)  Share the link to repo here, easy peasy  ;)
Good luck.
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 2.2.6 up until Jan 2024 from then on it's: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 3.0

jollytall

  • Sr. Member
  • ****
  • Posts: 303
Re: OOP structures in fpc and Lazarus
« Reply #12 on: November 10, 2021, 07:43:10 pm »
Thanks,
As said above, the plan is to share it once the questions, problems are corrected, but I trust this community most to validate and answer the uncertainties I have.

(and I have a github account, but that does not answer my questions  :))

MarkMLl

  • Hero Member
  • *****
  • Posts: 6646
Re: OOP structures in fpc and Lazarus
« Reply #13 on: November 10, 2021, 08:14:57 pm »
If it ain't broke, don't fix it.

So why the Hell should we all be obliged to do absolutely everything via Github or equivalent these days?

He didn't ask about a way to publish his document. He asked about a way of making it available to other members of this forum for review and constructive criticism.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

jollytall

  • Sr. Member
  • ****
  • Posts: 303
Re: OOP structures in fpc and Lazarus
« Reply #14 on: November 10, 2021, 09:45:07 pm »
MarkMLI I think is right, but that is not the point. So, before it turns into a religious war, I ask my second question (and still hope, someone can shed some light on Q1).

Q2. Why is there a static keyword needed for an advanced record class level method?
The good news is that it is at least coherent with the object approach, i.e. a class procedure X; static; can be called with the type tTest.X and there is no Self available.
On the other hand I do not understand why is it implemented this way. To me two ways would be logic:
EITHER
it would be similar to object, but then why not to allow class procedure X; (without static) and procedure X; static; (without class) with slightly different behavior?
OR
accept the fact that record is different than object and in record there is only one way to make a method class level, but then why need to use static at all? Using only class procedure X; would be in line with the record field declaration where there is only one way to define with class var (unlike the object where static is also allowed to define a field, but that is another question).

 

TinyPortal © 2005-2018