Recent

Author Topic: Project Overview  (Read 2573 times)

mm_coder

  • Jr. Member
  • **
  • Posts: 50
Project Overview
« on: March 14, 2017, 01:46:51 am »
In my vb projects it was easy to have 50-100 files in a project.

As i progress in the Lazarus environment, is it preferred to use a unit file to hold the
specific uses clause of other required units.....or just add files, and add to the uses section where needed?

Suppose i create the following header pascal unit files:  header1.pas , header2.pas, header3.pas, header4.pas

Then create another unit file called: header_files.pas ...  then populate the uses clause with the other header files?

eg;
uses header1, header2, header3, header4 etc

Am I over thinking this??

comments




Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Project Overview
« Reply #1 on: March 14, 2017, 03:18:28 am »
In my vb projects it was easy to have 50-100 files in a project.

As i progress in the Lazarus environment, is it preferred to use a unit file to hold the
specific uses clause of other required units.....or just add files, and add to the uses section where needed?

Suppose i create the following header pascal unit files:  header1.pas , header2.pas, header3.pas, header4.pas

Then create another unit file called: header_files.pas ...  then populate the uses clause with the other header files?

eg;
uses header1, header2, header3, header4 etc
It's impossible to use functionalities of unit C used by unit B from unit A, where unit A only uses B, which I believe is your purpose of having a single unit that uses all other units. Unit A must state explicitly unit C if it really wants to use unit C's functionalities. Classic VB & C/C++ has no notion of modules (or units), and what you have in mind is often done to emulate modular programming.
Am I over thinking this??
Not really, as when you learn a new language, you will often think in your existing one POV.

kapibara

  • Hero Member
  • *****
  • Posts: 610
Re: Project Overview
« Reply #2 on: March 14, 2017, 03:29:10 am »
If you want overview of all your units, use the Project Inspector.

I have this setup that you see in the attached clip. (Editor Toolbar at left and then fast switching between Object Inspector, Project Inspector and Code Explorer)

EDIT: The mouse pointer was not recorded.. but it was the second and third button from the top that I used to switch between tool windows.
« Last Edit: March 14, 2017, 04:07:47 am by kapibara »
Lazarus trunk / fpc 3.2.2 / Kubuntu 22.04 - 64 bit

Edson

  • Hero Member
  • *****
  • Posts: 1302
Re: Project Overview
« Reply #3 on: March 14, 2017, 04:27:36 am »
VB haven't the concept of modularity, in the sense Pascal have. One of the strengths of Pascal is precisely this modularity.

Pascal forces to declare all the units you are going to use in the USES clause. There are no backdoors. If you need some unit, you need to declare you are using it. It seems strange at the beginning, but it's a really secure way for programming.

This behaviour, creates some kind of hierarchy on your units, and it's part of a good design.
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

Thaddy

  • Hero Member
  • *****
  • Posts: 14373
  • Sensorship about opinions does not belong here.
Re: Project Overview
« Reply #4 on: March 14, 2017, 06:14:58 am »
It's impossible to use functionalities of unit C used by unit B from unit A, where unit A only uses B, which I believe is your purpose of having a single unit that uses all other units. Unit A must state explicitly unit C if it really wants to use unit C's functionalities. Classic VB & C/C++ has no notion of modules (or units), and what you have in mind is often done to emulate modular programming.

Well actually something like this is possible and FPC even uses it a lot. It is called include files.
You can split up header, what we call interface, and inmplementation section of a unit or part of a unit and include them in resp, the interface section and the implementation section of another.
Code: Pascal  [Select][+][-]
  1. // file myincl_h.inc
  2. function somefuction:sometype;
  3. ... more declations,
  4.  
Code: Pascal  [Select][+][-]
  1. // file myincl.inc
  2. function somefuction:sometype;
  3. begin
  4.   Result := Sometype;
  5. end;
  6. ... more implementations
  7.  
Code: Pascal  [Select][+][-]
  1. unit usemyinclude;
  2. interface
  3. {$I myincl_h}
  4. implementation
  5. {$I myincl.inc}
  6. end.
  7.  
FPC uses this system to have platform dependent implementations while maintaining a single set of headers .
If you don't need this, it is better to stick with units, but as  you can see,it is possible and for X-platform units where some of the code is platform dependent even recommended. The compiler sources and the RTL are full of examples.
« Last Edit: March 14, 2017, 06:18:08 am by Thaddy »
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

 

TinyPortal © 2005-2018