[Lazarus] When do I need a component rather than a plain object?

Graeme Geldenhuys graemeg.lists at gmail.com
Tue Nov 16 13:46:08 CET 2010


Op 2010-11-16 14:19, Mattias Gaertner het geskryf:
> 
> lfm files are simple text files just like pascal sources, so a
> revision control system works the same.

I'm not saying it's hard to read lfm (text versions), I'm simply saying
it's an extra file the developer and VCS needs to managed. For one, the
developer needs to remember to commit the lfm file in sync with the .pas
file in the same revision. With today's VCSes that have atomic commits (I
think that's the right term) where a commit is related to all files in the
repository, this is not so much of a problem these days (at least for
checking out files). In the days of Team Coherence, Source Safe, CVS where
a commit was per file, and as in TC and SS where you had to physically
check-out those files before you could edit them, it was a bit of a pain.
But yeah, this is mostly irrelevant these days with SubVersion, Git,
Mercurial etc supporting atomic commits.


> there is no simple source equivalent. For example images and icons.

In fpGUI, I use the same method as 'bin2obj', making such resources simply
arrays of bytes. For readability (before Lazarus supported user defined
code folding) I stored those in include files, but this is not required any
more - see below.


>> So why emulate the C-style (multiple files requirement) in Pascal?
> 
> Readability.
> The form data easily grows to thousands of lines (e.g. icons).
> Putting that into the source code breaks the readability rule to keep

Not necessarily, if you use code folding (which is on by default in Lazarus
IDE). fpGUI's UI Designer creates code as follows:


procedure TMainForm.AfterCreate;
begin
  {%region 'Auto-generated GUI code' -fold}   [...]
end;


So with Lazarus IDE's code folding, by default the above is all that the
developer will see, unless they expand that code-folding region themselves.



Regards,
  - Graeme -

-- 
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://opensoft.homeip.net:8080/fpgui/





More information about the Lazarus mailing list