Sign in Join

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

Mailing lists / lazarus / 2016-06

Quick Modern Object Pascal Introduction, for Programmers

12 messages · 5 people · –

Reply by email Subscribe to this list Your subscription

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

Michalis Kamburelis

Hi everyone,

Over the last few days, I wrote a document describing many features of the modern Object Pascal language. It is available on:

http://michalis.ii.uni.wroc.pl/~michalis/modern_pascal_introduction/modern_pascal_introduction.html

http://michalis.ii.uni.wroc.pl/~michalis/modern_pascal_introduction/modern_pascal_introduction.pdf

The document covers the easy language concepts, and then jumps quickly into more "advanced" stuff, like class references, generics, class helpers and so on. I hope that this is informative:)

This is directed at programmers (who know a bit of some programming language, though not necessarily Pascal). Which is really an excuse to not explain in detail some basic stuff ("what is a variable", "what is a class"). I tried to explain more the "advanced" stuff, and illustrate everything with examples.

The source code is in AsciiDoc and available on GitHub https://github.com/michaliskambi/modern-pascal-introduction . All comments are welcome:)

P.S. I already posted about this on fpc-pascal mailing list, I'm posting also here --- I hope that this is useful:)

Regards,
Michalis

Reply by email

Anastasios Karidis
to Michalis Kamburelis
Michalis Kamburelis wrote 28 lines
Hi everyone, Over the last few days, I wrote a document describing many features of the modern Object Pascal language. It is available on: http://michalis.ii.uni.wroc.pl/~michalis/modern_pascal_introduction/modern_pascal_introduction.html http://michalis.ii.uni.wroc.pl/~michalis/modern_pascal_introduction/modern_pascal_introduction.pdf The document covers the easy language concepts, and then jumps quickly into more "advanced" stuff, like class references, generics, class helpers and so on. I hope that this is informative:) This is directed at programmers (who know a bit of some programming language, though not necessarily Pascal). Which is really an excuse to not explain in detail some basic stuff ("what is a variable", "what is a class"). I tried to explain more the "advanced" stuff, and illustrate everything with examples. The source code is in AsciiDoc and available on GitHub https://github.com/michaliskambi/modern-pascal-introduction . All comments are welcome:) P.S. I already posted about this on fpc-pascal mailing list, I'm posting also here --- I hope that this is useful:) Regards, Michalis

Great job thanks !

I have also an introduction on Object Pascal section on my site

http://www.trustfm.net/ebooks/ObjectPascal.php

but i had never time to finish it :S

Anastasios Karidis aka TrustFm www.trustfm.net The gmail email

Reply by email

Travis Ayres
to Anastasios Karidis

While we're talking about books on Object Pascal, if anyone is looking for Object Pascal book ideas I'd suggest a book of patterns in Object Pascal. It seems like there's a lot of info about the structure of the language, but limited examples of how it is used in practice. The Observer, MVVM, Adapter patterns, whatever - it would be great to find more examples of these.

Anastasios Karidis wrote 51 lines
On 6/22/2016 18:50, Michalis Kamburelis wrote: > Hi everyone, > > Over the last few days, I wrote a document describing many features of > the modern Object Pascal language. It is available on: > > http://michalis.ii.uni.wroc.pl/~michalis/modern_pascal_introduction/modern_pascal_introduction.html > > http://michalis.ii.uni.wroc.pl/~michalis/modern_pascal_introduction/modern_pascal_introduction.pdf > > The document covers the easy language concepts, and then jumps quickly > into more "advanced" stuff, like class references, generics, class > helpers and so on. I hope that this is informative:) > > This is directed at programmers (who know a bit of some programming > language, though not necessarily Pascal). Which is really an excuse to > not explain in detail some basic stuff ("what is a variable", "what is > a class"). I tried to explain more the "advanced" stuff, and > illustrate everything with examples. > > The source code is in AsciiDoc and available on GitHub > https://github.com/michaliskambi/modern-pascal-introduction . All > comments are welcome:) > > P.S. I already posted about this on fpc-pascal mailing list, I'm > posting also here --- I hope that this is useful:) > > Regards, > Michalis Great job thanks ! I have also an introduction on Object Pascal section on my site http://www.trustfm.net/ebooks/ObjectPascal.php but i had never time to finish it :S -- Anastasios Karidis aka TrustFm www.trustfm.net The gmail email -- _______________________________________________ Lazarus mailing list http://lists.lazarus-ide.org/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20160622/e0216513/attachment.html>

Reply by email

Graeme Geldenhuys
to Travis Ayres
Travis Ayres wrote
The Observer, MVVM, Adapter patterns, whatever - it would be great to find more examples of these.

You mean like these... a series of articles I wrote about design patterns implemented in Object Pascal. ;-)

http://geldenhuys.co.uk/articles/

As for MVVM, I had a different spin on MVP (Model-View-Presenter) and MVC (Model-View-Controller). Both MVP especially implements everything from scratch. Instead I implemented MGM (Model-GUI-Mediator) which is very similar to MVP in concept, except it reuses available widget events found in all modern GUI toolkit widgets. There is an article on MGM too, but that was kept simple for the sake of the article. For a much improved version of MGM, take a look at the code available as part of the tiOPF project (on SourceForge). The tiOPF implementation of MGM supports VCL, LCL, fpGUI and FMX (Delphi's Firemonkey) toolkits.

ps:
Design Patterns are meant to be documented as an idea of how to solve a commonly found problem. It isn't meant to serve as a code template. So there can be many ways of implementing the same design pattern. eg: Most books and articles I've read implement the Visitor pattern in a very limited way. tiOPF implements it in a more generic way, and actually makes it even more flexible.

The tiOPF project is what got me hooked on design patterns. That framework uses many different design patterns, and improved the quality of the framework tremendously.

Regards,
Graeme

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ My public PGP key: http://tinyurl.com/graeme-pgp

Reply by email

Travis Ayres
to Graeme Geldenhuys

Hi Graeme,

I don't understand the problem tiOPF is trying to solve well enough to fully grok it in context - I've never used a database, only flat files. GUI programming in an understandable way... clueless, it always devolves into miserable, miserable spaghetti code.

That said, it's better spaghetti code than when I started with Lazarus, so maybe eventually it'll be acceptable. Hah!

On Wed, Jun 22, 2016 at 2:21 PM, Graeme Geldenhuys <

Show quoted text 49 lines
wrote: On 2016-06-22 18:57, Travis Ayres wrote: > The Observer, MVVM, > Adapter patterns, whatever - it would be great to find more examples of > these. You mean like these... a series of articles I wrote about design patterns implemented in Object Pascal. ;-) http://geldenhuys.co.uk/articles/ As for MVVM, I had a different spin on MVP (Model-View-Presenter) and MVC (Model-View-Controller). Both MVP especially implements everything from scratch. Instead I implemented MGM (Model-GUI-Mediator) which is very similar to MVP in concept, except it reuses available widget events found in all modern GUI toolkit widgets. There is an article on MGM too, but that was kept simple for the sake of the article. For a much improved version of MGM, take a look at the code available as part of the tiOPF project (on SourceForge). The tiOPF implementation of MGM supports VCL, LCL, fpGUI and FMX (Delphi's Firemonkey) toolkits. ps: Design Patterns are meant to be documented as an idea of how to solve a commonly found problem. It isn't meant to serve as a code template. So there can be many ways of implementing the same design pattern. eg: Most books and articles I've read implement the Visitor pattern in a very limited way. tiOPF implements it in a more generic way, and actually makes it even more flexible. The tiOPF project is what got me hooked on design patterns. That framework uses many different design patterns, and improved the quality of the framework tremendously. Regards, Graeme -- fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ My public PGP key: http://tinyurl.com/graeme-pgp -- _______________________________________________ Lazarus mailing list http://lists.lazarus-ide.org/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20160622/65ebfc4f/attachment-0001.html>

Reply by email

Michalis Kamburelis
to Anastasios Karidis: Great job thanks ! I have also an introduction on Object Pascal section on my site…
Show quoted text 5 lines
I have also an introduction on Object Pascal section on my site http://www.trustfm.net/ebooks/ObjectPascal.php but i had never time to finish it :S

I like it! - but without the 1st part, "Introduction"... I would not advice using CodeTyphon, as I had very bad experience with the quality of their stuff. I would much rather advice users to just install Lazarus straight from http://www.lazarus-ide.org/ .

Also, as a Linux user, the instructions to modify the "sudoers" (to never ask for password), and then run the CodeTyphon with "sudo" are kind of a show-stopper. Running with "sudo" is something you should never do with an IDE... And it's certainly absolutely not required for vanilla FPC or Lazarus.

That said, the rest of the book starts really good! You describe using Lazarus for a "Hello world" GUI programs, which is a cool approach, to quickly show new users that they can do fancy GUI trivially easy with Pascal. And presented with screenshots and basic code samples that should get anyone started. Then you have a nice description of the language.

So, might I make a suggestion: how about just making the "Hello World" part the 1st one, not the 2nd? And just start it with a simple paragraph

"""
Install Lazarus from http://www.lazarus-ide.org/ . Alternatively, you can install CodeTyphon (link to existing installation instructions here).
"""

That would make it simpler (faster start into actual coding), and also don't scare off Linux users with instructions about "sudo":)

Regards,
Michalis

Reply by email

Michalis Kamburelis
to Michalis Kamburelis
Show quoted text 5 lines
Also, as a Linux user, the instructions to modify the "sudoers" (to never ask for password), and then run the CodeTyphon with "sudo" are kind of a show-stopper. Running with "sudo" is something you should never do with an IDE... And it's certainly absolutely not required for vanilla FPC or Lazarus.

Sorry, reading the instructions closer -- it seems you only need to run "sudo codetyphon" to update it, not for regular usage. Well, that's still rather bad (together with the description to modify sudoers) and should not be necessary (it would be nice to be able to install it for current user, without sudo, not system wide). Although it's not as scary as I made it out to be above:)

Regards,
Michalis

Reply by email

Dennis
to Michalis Kamburelis

Instead of doing an svn update in place, it should store the binaries in your home folder, and then run those instead (kinda like what Dropbox does). I agree.. should never have to sudo.. either make a repository for updates, or store the source and svn it from the user home folder if necessary (or both).

- Dennis Fehr

PM Michalis Kamburelis wrote 21 lines
> Also, as a Linux user, the instructions to modify the "sudoers" (to > never ask for password), and then run the CodeTyphon with "sudo" are > kind of a show-stopper. Running with "sudo" is something you should > never do with an IDE... And it's certainly absolutely not required for > vanilla FPC or Lazarus. Sorry, reading the instructions closer -- it seems you only need to run "sudo codetyphon" to update it, not for regular usage. Well, that's still rather bad (together with the description to modify sudoers) and should not be necessary (it would be nice to be able to install it for current user, without sudo, not system wide). Although it's not as scary as I made it out to be above:) Regards, Michalis -- _______________________________________________ Lazarus mailing list http://lists.lazarus-ide.org/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20160623/583890ee/attachment.html>

Reply by email

Graeme Geldenhuys
to Travis Ayres: I don't understand the problem tiOPF is trying to solve well enough to fully grok it in…
Travis Ayres wrote
I don't understand the problem tiOPF is trying to solve well enough to fully grok it in context - I've never used a database, only flat files.

Well, you wanted quality examples of design patterns using Object Pascal. tiOPF gives you that, and so does my articles.

tiOPF is an Object Persistence Framework (and more). Instead of working with Datasets, TFields, a database specific component, a ton of event handlers and all code dumped into the Form unit (gui layer) — which 99.9% of the time ends up being unmaintainable and not very reusable.

tiOPF steers you into separating your storage, business rules and UI into separate layers. This makes for much more maintainable code, much easier to unit test and code reuse of the business rules. In many of my applications I’ve created GUI, Console and CGI applications from the same set of business rule classes — thanks to tiOPF.

tiOPF also allows you to switch between DB connection component (SqlDB, Zeos, DOA, IBX etc) and even switch between database storage (Firebird, Oracle, MS SQL Server, MySQL, TAB, CSV, XML etc)… all without needing to make a code change in you application. Simply toggle a compiler define and recompile. The same goes for Client/Server and 3-tier applications.

As I hinted at above, tiOPF can also do persistence to something other than a database. Like a flat file, and currently supplies CSV, TAB and XML persistence layers to accomplish that.

The reason I said “and more” earlier, is because I often write non-database applications, and still use tiOPF. Simply because tiOPF (thanks to all the design patterns it implements) has so many useful features and utility functions. The whole framework is backed by 1700+ unit tests that run every 3 hours, 24/7 to make sure in stays in a stable state, and than any newly introduced errors are very quickly detected and fixed.

Maybe the “Concepts Documentation” will help shed some light on what tiOPF tries to (and does) accomplish. Especially chapters 1–3. It’s a relatively quick read.

http://tiopf.sourceforge.net/Doc/Concepts/index.shtml

Either way, I hope you find the design pattern example code useful.

Regards,
Graeme

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ My public PGP key: http://tinyurl.com/graeme-pgp

Reply by email

Graeme Geldenhuys
to Michalis Kamburelis: I like it! - but without the 1st part, "Introduction"... I would not advice using…
Michalis Kamburelis wrote
Also, as a Linux user, the instructions to modify the "sudoers" (to never ask for password), and then run the CodeTyphon with "sudo" are kind of a show-stopper.

Definitely, and I felt it is an even bigger issue under FreeBSD, especially where CodeTyphon tries to install itself. It doesn’t adhere to the filesystem hierarchy at all, where user installed programs should go to /usr/local/ only. And then adding to the pain, I prefer installing something only I’ll be running in my $HOME directory or in my read/write allocated /data/devel/ path.

Regards,
Graeme

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ My public PGP key: http://tinyurl.com/graeme-pgp

Reply by email

Anastasios Karidis
to Michalis Kamburelis: I like it! - but without the 1st part, "Introduction"... I would not advice using…
Michalis Kamburelis wrote 38 lines
> I have also an introduction on Object Pascal section on my site > > http://www.trustfm.net/ebooks/ObjectPascal.php > > but i had never time to finish it :S I like it! - but without the 1st part, "Introduction"... I would not advice using CodeTyphon, as I had very bad experience with the quality of their stuff. I would much rather advice users to just install Lazarus straight from http://www.lazarus-ide.org/ . Also, as a Linux user, the instructions to modify the "sudoers" (to never ask for password), and then run the CodeTyphon with "sudo" are kind of a show-stopper. Running with "sudo" is something you should never do with an IDE... And it's certainly absolutely not required for vanilla FPC or Lazarus. That said, the rest of the book starts really good! You describe using Lazarus for a "Hello world" GUI programs, which is a cool approach, to quickly show new users that they can do fancy GUI trivially easy with Pascal. And presented with screenshots and basic code samples that should get anyone started. Then you have a nice description of the language. So, might I make a suggestion: how about just making the "Hello World" part the 1st one, not the 2nd? And just start it with a simple paragraph """ Install Lazarus from http://www.lazarus-ide.org/ . Alternatively, you can install CodeTyphon (link to existing installation instructions here). """ That would make it simpler (faster start into actual coding), and also don't scare off Linux users with instructions about "sudo":) Regards, Michalis

I will take in consideration your advices . My point of view was at the 1st chapter to include Lazarus approach (installation and configuration) too...

Anastasios Karidis aka TrustFm www.trustfm.net The gmail email

Reply by email

Anastasios Karidis
to Michalis Kamburelis: Sorry, reading the instructions closer -- it seems you only need to run "sudo codetyphon"…
Michalis Kamburelis wrote 14 lines
> Also, as a Linux user, the instructions to modify the "sudoers" (to > never ask for password), and then run the CodeTyphon with "sudo" are > kind of a show-stopper. Running with "sudo" is something you should > never do with an IDE... And it's certainly absolutely not required for > vanilla FPC or Lazarus. Sorry, reading the instructions closer -- it seems you only need to run "sudo codetyphon" to update it, not for regular usage. Well, that's still rather bad (together with the description to modify sudoers) and should not be necessary (it would be nice to be able to install it for current user, without sudo, not system wide). Although it's not as scary as I made it out to be above:) Regards, Michalis

Thank you, i am based at the official documentation of Sternas. But as i said i wantedto add Lazarus too. My approach ob the online tutorials is to define the sections and then fill them i hope to make some time to conclude this stuff. Locally i have evolving examples for OO not separate ones.

Have a nice day !

Anastasios Karidis aka TrustFm www.trustfm.net The gmail email

Reply by email