Jump to content
TheOnlyOne

Need a "Delphi programming guideline"

Recommended Posts

My current company does not follow any Delphi programming guideline. You know the document that recommends to use short function, long variable names, use of try/finally, etc.
I never needed one, because in the previous companies everybody was doing good code "by default". But in this company..... every programmer does whatever it wants (function that have 2000 lines of code, as strings are named s, k or i, etc).

I expected to find such a guideline on Emba's website. But cannot find it. Anyone can point to such document or if you wrote one, upload it somewhere?

 

My colleagues refuse to read Delphi books (they don't know how to make classes), and our boss is not a technical guy. He only looks in the scrum if for the GUI DoD (definition of done) if the task is ready or not.

 
Edited by TheOnlyOne
  • Like 1
  • Sad 1

Share this post


Link to post

There is a "style guide" which focuses on Delphi-relative conventions like that weird "F" prefix for field names and such:

Delphi’s Object Pascal Style Guide - RAD Studio (embarcadero.com)

 

Embarcadero does not provide official guidelines on how to write good and re-usable code in general.

 

20 minutes ago, TheOnlyOne said:

function that have 2000 lines of code, as strings are named s, k or i, etc

At some point, probably most of us have dealt with with ancient Pascal spaghetti code that is almost impossible to understand. I feel your pain.

 

If your colleagues are stuck one or two decades ago and refuse to study further, I doubt an "official" guide from the vendor of your IDE is going to change much.

Edited by Der schöne Günther
  • Like 1
  • Sad 1

Share this post


Link to post

about the nomenclatures, really, only the programmer can define it. But the IDE provides some internal tools that can help in the quest to produce better coding or even improve the look (for better readability).

  • Tools->Language->Formatter: reformating you code with CTRL+D (I love this) on unit or for all project: Project-> Format Project Sources
    • you can create your "way" ( as you named all procedure/functions/vars/objects/etc.. ), then, the "formatter" will use as your "pattern" to fix all next occurrences -> it's great helper!
    • the main idea, it's create the first occurrences (names) then the "formatter" will use it!
  • in Project->QA Metrics, QA Audits -> you will have some info about your project with some tips about your coding
  • in Project -> Method Toxicity Metrcis -> you will know "how is it?" a general idea of how your code is doing, with respect to complexity (which can affect performance)

 

But nothing will save you from a sloppy project manager! If the boss doesn't care, who needs that boss!

Edited by programmerdelphi2k
  • Like 2

Share this post


Link to post

Hi...:classic_cool:

Quote

But in this company..... every programmer does whatever it wants (function that have 2000 lines of code, as strings are named s, k or i, etc)

:classic_blink: Sorry, but it is not the right company. That's where the developers get in their own way. Uniform styles are important to understand all "developers" and their code. The management must set the standard!

Try to talk to the others about a simple standard (prefixes for components, meaningful variable names, begin/end styles - separate lines or not, CTRL+D for all...).

 

What is the total number of lines of source code? Do you have a trainee for the implementation of the styleguide in the old code? :classic_tongue:

 

no matter what you do...

Quote

But nothing will save you from a sloppy project manager! If the boss doesn't care, who needs that boss!

...that is the problem!

 

 

another one... PDF 😉 ...great work! :classic_cheerleader:

 

Manual_on_Object_Pascal_Style_Guide.pdf

Edited by haentschman
  • Like 1
  • Thanks 1

Share this post


Link to post
20 hours ago, TheOnlyOne said:

 

 ...Plenty of reasons to perhaps look for a new employer...

 

That sounds dismal. What struck me though is this: How does this make any form of version management possible? If every developer has their own style they might be tempted to reformat code as they work on it, causing a multitude of changes and in essence a merging nightmare.

  • Like 1

Share this post


Link to post
7 hours ago, Sherlock said:

That sounds dismal. What struck me though is this: How does this make any form of version management possible?

We merge once at the end of the sprint (two weeks). Yes, merging is not easy. But not the formatting is making the merge difficult. It is the spaghetti code that makes it difficult. If you want to fix or implement something new, you do changes all over the place. 
All data is transported through strings - integers, booleans, everything is a string! In a way I admire the guy that created all this code, because the code somehow works (is true that we use try/except in hundreds of places (thousands?))

 

Even with this nightmarish code, I like the workplace because the work is not strenuous. I worked on hardware drivers for a million-dollar industrial robot - electronics and software combined. That was a fabulous work place, but the work was really, really intense.

The payment here is not great, BUT I work from home, and I am happy that I am with my family and I don't have to drive 2h per day again.

And as I said, all we do is convert back and forth integers to strings and strings to integers :classic_laugh:. What can be easier than that? The most complicated math I did for this project was to calculate a VAT :classic_biggrin: - the program works with money. No advanced math, no micron-precision measurements, no worries that the robot crushes somebody's head. When I have the chance to write my own code in this project, it feels like holidays. Not when I have to fix their code....

 

On the other hand, I feel that this work makes me stupid. If I don't have advanced programming issues to solve, I decreased my daily Delphi reading quota.
The job is easy, but might be detrimental for me on long term...
Since I am still here in this job, probably I am getting old too :classic_wacko:. I like to think that this is not a work place but a relaxed hobby  🙂

 

I wrote the program from zero on my VERY personal time (a total of about 8 days) - all the backbone is there, main parts of the GUI also. 100% OOP (naturally). Searches in 0.1 million customers in 80 msec. The old program searches in 2000 customers in 4 seconds 🙂 (to get of sense what we have there).

I can't convince my boss to switch to it. The old program had an exporter to export some financial info. There are about 10000 lines of code in there (all the math is done in the strings, literary). I did mine with 60 lines.🙂
 

As you see, in the old code is "special" like I have never seen before. There are many funny parts. If you are not a grumpy person, and you are predisposed to smile instead to grim... Life can be sweet even in projects like this....


:classic_cheerleader::classic_cheerleader::classic_cheerleader::classic_cheerleader::classic_cheerleader::classic_cheerleader::classic_cheerleader::classic_cheerleader::classic_cheerleader::classic_cheerleader::classic_cheerleader::classic_cheerleader::classic_cheerleader::classic_cheerleader:


____________

Anyway, I diverge. I am interested to make my colleagues read some Delphi books. Since that won't happen (you know... the age) at least I need to find a way to cut down some of their most dangerous habits. This is why I am interested not in a code formatting style guide but in some clear definitions about what is allowed to do in Delphi (use try/finally don't use (abuse) try/except).

Hopefully, I could convince my boss to put it in the DoD.

But I don't want to start writing such document on my own time.


 

Edited by TheOnlyOne

Share this post


Link to post

The boss needs to be changed:classic_biggrin:

The book mentioned above is required reading in good companies.

25 minutes ago, TheOnlyOne said:

But I don't want to start writing such document on my own time.

Try to convince your boss that you can at least write the mandatory outline during working hours.

Share this post


Link to post
22 minutes ago, Stano said:

The boss needs to be changed:classic_biggrin:

The book mentioned above is required reading in good companies.

Cannot be done. He owns the business/the program 🙂
He is not a bad guy. He just don't have any technical knowledge. I told him that the technical debt reached a maxim (cannot exist higher than that)
but I had to explain him what is technical debt. I don't think he believed me. Last month we implemented no new feature. We only fixed bugs. 
I keep posting links to simple tech documentation for my Delphi colleagues. For my boss I linked to videos from https://www.youtube.com/@ContinuousDelivery channel (a great channel). I don't think anybody is clicking the links. 🙂

Edited by TheOnlyOne

Share this post


Link to post

Um, it wouldn't help if you had him read some discussion on the subject. There is also something on this forum. And good.
You won't pay anything for trying.
That boss change was a joke. See smiley.

Share this post


Link to post
1 hour ago, TheOnlyOne said:

... It is the spaghetti code that makes it difficult. ....  Even with this nightmarish code, ... I worked on hardware drivers for a million-dollar industrial robot - electronics and software combined ....

I'm not afraid of new technology, robots, KI, self-driving cars,  ...  but I'm very unsure if I would risk to meet your robot anytime soon :classic_unsure:

 

The full reality is maybe that all the coolest, newest hip technolgy out there in the streets will be "Spagetti" to some degree  :classic_biggrin:

Good technology need usually also some time to get ripe.

Edited by Rollo62

Share this post


Link to post
10 minutes ago, Rollo62 said:

I'm not afraid of new technology, robots, KI, self-driving cars,  ...  but I'm very unsure if I would risk to meet your robot anytime soon :classic_unsure:

Nope, nope, nope.
The robot was a really cool thing we did in the previous company (high-tech labs, clean rooms, fast microcontrollers, CAD, big security all over the place, great salary, high-standards Delphi code).
Not in this current company. In this (current) company, we wouldn't even be able to write the software that puts oil in robot's spare wheel 🙂

 

Edited by TheOnlyOne
  • Like 1
  • Haha 2

Share this post


Link to post
13 hours ago, programmerdelphi2k said:

take care about your comments here... who knows who can see it? ... a robot, a BOSS... your ex  👨‍🏭👨‍🏭👨‍🏭👩‍🎨

1. Well... in the end I tell the truth and only the truth.

2. Also, I was careful not to mention the name of the company...

3. My current boss will never visit a technical forum like this.

But thanks for the warning.

Share this post


Link to post
On 1/26/2023 at 2:21 PM, TheOnlyOne said:

I expected to find such a guideline on Emba's website. But cannot find it. Anyone can point to such document or if you wrote one, upload it somewhere?

Last year (or previous one, I don't remember), Marco Cantù published the updated release of the "official" Delphi's Object Pascal Style Guide. A good start for a lot of coding choices when you have no rules and are not alone on a project.

It's online, you can read it and pick some pages for your colleagues and boss.

 

On 1/26/2023 at 2:21 PM, TheOnlyOne said:

My colleagues refuse to read Delphi books (they don't know how to make classes), and our boss is not a technical guy. He only looks in the scrum if for the GUI DoD (definition of done) if the task is ready or not.

On the Resources / White papers page of Embarcadero website you have a lot of ebooks and books. One of them is a bible for Delphi Object Pascal developers Object Pascal Handbook Delphi 11 Alexandria Edition 

You can also read Code Faster in Delphi to have a lot of coding tips. 

 

Put them on the Windows desktop of your colleagues, they must read books about coding and good practices !

  • Like 1
  • Thanks 1

Share this post


Link to post

Also, we keep all data in strings, but sometimes we keep it in visual controls (listboxes) placed on the form outside the visible area. The form is 1024 pixels, so we have in the main form like 100 invisible (link) controls, starting at pixel 6000, mostly timers.

 

I am trying to convince my boss to throw away all the code and start from zero.
But we will need new programmers with that new code 🙂

The code is now about 200,000 lines of code but can be reduced to 20,000 if objects are used (instead of strings).

Edited by TheOnlyOne

Share this post


Link to post
On 1/29/2023 at 10:06 AM, Patrick PREMARTIN said:

Put them on the Windows desktop of your colleagues, they must read books about coding and good practices !

The problem is not from where to get the books, the problem is how to make them read. They were very clear that they are not interested in reading Delphi books at this age.

I managed to frighten one of them when I posted on company's chat some "cool news" about an AI that can write code, code object-based.
One of the two programmers magically stated the next day that he started to learn to use generics. 🙂 :classic_cheerleader:

I haven't seen them yet appearing in the code 🙂

Share this post


Link to post

Honestly, it would be best if you started looking for a new job. You coworkers don't care. Your boss doesn't care. It works for them (for now), but it will crush you.

  • Like 4

Share this post


Link to post

Do not waste your time, find a new job and leave them in the past.

Got reprimanded once for replacing 2000+ lines of code looking for values by doing 'if Edit1.Value = x' on about 200 edit boxes basically named Edit1, Edit2, Edit3..Edit200 on a form (don't ask), just a huge cut-paste, change the component name procedure. I reduced it to about 10 lines using FindComponent in a loop producing the same results.  I walked out of that job in less than 1 month after I figured out they (staff and management) refused to learn anything new. :classic_cool:

 

Do not suffer fools.

  • Like 3

Share this post


Link to post
3 hours ago, TheOnlyOne said:

The problem is not from where to get the books, the problem is how to make them read. They were very clear that they are not interested in reading Delphi books at this age.

using books pages with a quiz as a captcha on Windows login screen should be a good feature

  • Like 1

Share this post


Link to post
On 1/30/2023 at 3:47 PM, Patrick PREMARTIN said:

using books pages with a quiz as a captcha on Windows login screen should be a good feature

ok. you just made my day.

  • Haha 1

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×