Recent

Author Topic: how do you manage types? General question  (Read 925 times)

Weiss

  • Full Member
  • ***
  • Posts: 187
how do you manage types? General question
« on: November 20, 2023, 09:52:04 pm »
Lately I ran into a problem while re-using my own code from other projects. Same type declarations for same things scattered through multiple back-end unit. Obviously I do not have a very large vocabulary or imagination.

What would be a strategy getting out of the mess and keeping things neat? This is a very general question, I am not looking for actual implementation. Should I build a type stockpile unit of some sort, and drag it along to every new project? Or would it be better to combine multiple units into one? Perhaps naming convention of some sort, I am open to any ideas.

Please share your thoughts.

jamie

  • Hero Member
  • *****
  • Posts: 6735
Re: how do you manage types? General question
« Reply #1 on: November 20, 2023, 11:38:29 pm »
depends.

 Use for all, WISxxxxx

 use for a specific project, "ProjectInitials.xxxxxxxx"
The only true wisdom is knowing you know nothing

Joanna from IRC

  • Hero Member
  • *****
  • Posts: 1228
Re: how do you manage types? General question
« Reply #2 on: November 21, 2023, 01:19:03 am »
Put all your reusable types in one unit and use unit when needed
✨ 🙋🏻‍♀️ More Pascal enthusiasts are needed on IRC .. https://libera.chat/guides/ IRC.LIBERA.CHAT  Ports [6667 plaintext ] or [6697 secure] channel #fpc  #pascal Please private Message me if you have any questions or need assistance. 💁🏻‍♀️

Weiss

  • Full Member
  • ***
  • Posts: 187
Re: how do you manage types? General question
« Reply #3 on: November 21, 2023, 04:31:34 pm »
thank you Joanne, I did. Works beautifully, no conflicting types anymore, this will be my schtick.

Jamie, you have a way of sending me to a long and painful learning loops. I usually enjoy it, but this time I can't find what is WISxxx or projectInitials.xxx. Can you please (gently!) nudge me to where I can find what you mean?

cdbc

  • Hero Member
  • *****
  • Posts: 1673
    • http://www.cdbc.dk
Re: how do you manage types? General question
« Reply #4 on: November 21, 2023, 06:54:27 pm »
Hi
I think Jamie is talking about naming-convention...
You should define one of your own, either by using namespaces or by prepending yours or project initials, eg: weiss.utilities.pas or wei_utilities.pas

Anyway, that's what I do, in addition I've modelled my directory structure somewhat after the rtl...
HTH
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

 

TinyPortal © 2005-2018