Recent

Author Topic: Programming Standards and Practices questions  (Read 3194 times)

wpflum

  • Sr. Member
  • ****
  • Posts: 287
Programming Standards and Practices questions
« on: September 09, 2015, 07:15:42 pm »
Is there any documentation on what is considered standard convention for Lazarus/Free Pascal??

What I mean is that I'm mostly self taught and I find that a lot of sample programs I see have different ways of naming variables, functions, etc and other small things that perhaps were taught in an academic setting or are something that is normally done in the 'real' world of programming.  My programs work, mostly, but I'm always looking to learn and a baseline might be a good thing to go back to.

Here is one question, I had a problem and someone posed a bit of code which used Result instead of the function name to return the data, I went looking and didn't see anywhere where one is preferred over the other or why so I'm wondering if there is a preference.  I kinda like using the name but using Result looks more standard across all the functions.  Thoughts?

derek.john.evans

  • Guest
Re: Programming Standards and Practices questions
« Reply #1 on: September 09, 2015, 07:32:19 pm »
Personalty, I think the non-Result return value should be taken out of the language.

Thats just me.


kapibara

  • Hero Member
  • *****
  • Posts: 656
Re: Programming Standards and Practices questions
« Reply #2 on: September 09, 2015, 07:42:52 pm »
Here is one question, I had a problem and someone posed a bit of code which used Result instead of the function name to return the data, I went looking and didn't see anywhere where one is preferred over the other or why so I'm wondering if there is a preference.  I kinda like using the name but using Result looks more standard across all the functions.  Thoughts?

Result did not exist until, hm.. was it Delphi or TurboPascal? Earlier the return data was assigned to the function name. You can still do it the old way, but I guess thats because of compatibility with old code.

"Result" is the modern and prefered way of returning the value from a function.
Lazarus trunk / fpc 3.2.2 / Kubuntu 24.04 - 64 bit

Leledumbo

  • Hero Member
  • *****
  • Posts: 8835
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Programming Standards and Practices questions
« Reply #3 on: September 09, 2015, 07:46:57 pm »
Is there any documentation on what is considered standard convention for Lazarus/Free Pascal??

What I mean is that I'm mostly self taught and I find that a lot of sample programs I see have different ways of naming variables, functions, etc and other small things that perhaps were taught in an academic setting or are something that is normally done in the 'real' world of programming.  My programs work, mostly, but I'm always looking to learn and a baseline might be a good thing to go back to.
http://wiki.freepascal.org/DesignGuidelines
Here is one question, I had a problem and someone posed a bit of code which used Result instead of the function name to return the data, I went looking and didn't see anywhere where one is preferred over the other or why so I'm wondering if there is a preference.  I kinda like using the name but using Result looks more standard across all the functions.  Thoughts?
Pascal -> function name
Object Pascal -> Result

wpflum

  • Sr. Member
  • ****
  • Posts: 287
Re: Programming Standards and Practices questions
« Reply #4 on: September 09, 2015, 07:47:07 pm »
This is why I'd love a "standards" document.  Guess I'll be using Result from now on  :D

Thanks

 

TinyPortal © 2005-2018