What are my options for code reuse?
Creating units for common code?
Any other method?
Mailing lists / fpc-pascal / 2009-04
Best method for code reuse?
8 messages · 5 people · –
- FFrancisco Reyes 2
- GGraeme Geldenhuys 2
- MMattias Gaertner 2
- DDiego Antonio Lucena Pumar 1
- RRichard Ward 1
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
What are my options for code reuse? Creating units for common code? Any other method?
Units is the right way.
And even better: create a lazarus package for the new units.
Mattias
Mattias Gaertner wroteUnits is the right way. And even better: create a lazarus package for the new units.
Most of what I do is CLI, have not even installed lazarus.
Could someone doing CLI use a lazarus package?
What advantage of doing a lazarus package over just making it a unit?
Right now I am just getting back into pascal doing a simple open source utility so may be a little bit before I am up to speed. Was thinking of trying Lazarus later. Would I have any advantages on doing my CLI work from Lazarus?
Show quoted text 6 lines
Lazarus is an IDE for any kind of FPC program.
You can even edit the compiler itself with it.
Could someone doing CLI use a lazarus package?
Of course.
What advantage of doing a lazarus package over just making it a unit?
A lazarus package helps to
- write documentation for it,
- handle translations,
- simplifying integrating it into programs with different compiler settings
Right now I am just getting back into pascal doing a simple open source utility so may be a little bit before I am up to speed. Was thinking of trying Lazarus later. Would I have any advantages on doing my CLI work from Lazarus?
Lazarus has a lot of tools for searching and writing code faster.
Mattias
Mattias Gaertner wrote 6 lines
Plus
- Allows for much easier code reuse
- applies compiler paths and units paths for you
eg: Create a new CLI project add the MyCoolUnits.lpk as a requirement package and Lazarus IDE does the rest. All unit paths are setup automatically. PS: Remember to specify in the Package Options that the MyCoolUnits.lpk is a runtime only package. That way it doesn't rely on any Lazarus units or LCL.
> thinking of trying Lazarus later. Would I have any advantages on > doing my CLI work from Lazarus? Lazarus has a lot of tools for searching and writing code faster.
+1
I write a lot of CLI tools or non-LCL applications. Lazarus as programmer IDE (editor) is fabulous.
Regards,
- Graeme -
_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/
Estimated programmers:
What is the diferent between the art and hand made program? In my opinion don't have diferent. The code is poetry, this the expresion of new problematic existencially. What is really problem? I think than the problem resist on properly idea, or concept about supose the act of programmer. When I write a program translate my state, if I very nervous asked code, and never feel anything. In change, when work amparate in the world of ideas, the expresion of my code is obviously poetry. Form existencilly to expresionist, the code speak about this art, the art of programmer. So, what is my problem? We surrender to the enterprise. I think that is the moment, the moment to separate informatic to computer science, the science esencially can life independent to the industry. Whose teorem, coloralys and the rest to compain the science of calculus compunting. I trate to chage my reallity, and demostrate that programmig is the tool of science.
Sincerily, i wait that there coming to change your conception about computer science.
Bad enterprise forever. Diego Antonio Lucena Pumar.
P.D. Sorry for my english, is very poor.
Francisco Reyes writes : (snipped)
>The sample code in the ref document doesn't document the simplest
case, but goes over what I think is a more complex example of a unit that uses another unit.
It also doesn't have any actual code to do anything, so it is kind of an abstract example . I was looking on the other docs to see if there were any examples, but did not find any.
--- I see some people have answered and provided one or more examples. If you need more, I have several demo programs I have used in my own learning of FPC which you are welcome to. If interested, email me privately. Also, it took me a while to find out how to get at the example sources for the code snippets included in the various manual. If you need these, I can try to save you some time searching there as well.
>For starters I don't really follow the diagrams in the ref
document. It probably is some type of formal definition, but I am neither familiar with it, nor seem to get it. Even when I look at a simpler case like procedure declaration I can't follow those blocks.
--- I personally have never been able to grasp syntax diagrams too well on first (or second+ glance) either and like to look at examples and go back and forth till I understand it or think I do. Examples are good and my vote is for more examples but they do make the manuals a lot lengthier which might be better served by tutorials. And yes, I have found it hard to find good tutorials due to broken links and what not, and like you mention, looking for Delphi information can yield good results.
>I am finding many contributed units with broken links to both the
code and the homepage URL.
>A few thoughts. We could clean all entries to which both the code
and the refering URL are broken. We could email the author and give them a week or two, but if we get no replies then we should remove the entry.
--- This is a good idea. I would go further and suggest that some of the wiki pages be reorganized to make them easier to navigate and find things. Since FPC is a community effort, that means that someone has to take the time and do it and it usually comes down to the "someone" being the one who suggests it. Pointing a finger at myself in this case :)
--- _If_ you have access to a Macintosh, I would suggest downloading and trying out Ingemar's Lightweight IDE. This IDE is VERY easy to use and hides a lot of complexity which is especially useful for newbie's . You can concentrate on learning syntax and trying out Pascal code immediately rather than having to initially wade through linking peculiarities, makefiles and command line stuff ... unless you like or need them for whatever reason. - ROW
Richard Ward wrote--- This is a good idea. I would go further and suggest that some of the wiki pages be reorganized to make them easier to navigate and find things.
Here are some of the reason's I hate wiki's.
* You must edit pages while online. Not everybody has internet connections like in USA.
* Wiki's tend to be disorganized by nature.
* They become popular due to (semi)automated cross-referencing
* You cannot use the collected information in any other format
Standard web pages (plain HTML) can be easily organized better than wiki's. You can have the website html live in a source code repository, so the community can submit patches. An automated update script could be run to update the real website from the repository every 30 minutes etc... But you still sit with the same problem that the original content cannot be used in any other format or use...
This is why 'fpdoc' is so useful. One format that is easy to edit offline, and you can generate HTML, PDF's, CHM's, plain text etc... Much more useful data format.
Regards,
- Graeme -
_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/
