TheOnlyOne 10 Posted January 26, 2023 (edited) 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 January 26, 2023 by TheOnlyOne 1 1 Share this post Link to post
Der schöne Günther 316 Posted January 26, 2023 (edited) 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 January 26, 2023 by Der schöne Günther 1 1 Share this post Link to post
FPiette 383 Posted January 26, 2023 I have this document : http://wiki.overbyte.be/arch/IcsMidwareCodingStyle.pdf It partially answer your request. 2 1 Share this post Link to post
programmerdelphi2k 237 Posted January 26, 2023 (edited) 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 January 26, 2023 by programmerdelphi2k 2 Share this post Link to post
Darian Miller 361 Posted January 26, 2023 Here's one I started: https://github.com/radprogrammer/radteam/wiki/RADProgrammer-Style-Guide 1 1 Share this post Link to post
haentschman 92 Posted January 27, 2023 (edited) Hi... 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) 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? 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! Manual_on_Object_Pascal_Style_Guide.pdf Edited January 27, 2023 by haentschman 1 1 Share this post Link to post
Lars Fosdal 1792 Posted January 27, 2023 Another good read is https://www.oreilly.com/library/view/framework-design-guidelines/9780135896457/ It is not Delphi specific, but the advice is sound and actively applied to C#/.NET code by Microsoft. Also - the book I wish I had read during my education days. https://www.oreilly.com/library/view/code-complete-2nd/0735619670/ 1 1 Share this post Link to post
Stano 143 Posted January 27, 2023 One of the few I have. It is excellent. Share this post Link to post
Sherlock 663 Posted January 27, 2023 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. 1 Share this post Link to post
haentschman 92 Posted January 27, 2023 Quote causing a multitude of changes and in essence a merging nightmare. ...correctly. Share this post Link to post
TheOnlyOne 10 Posted January 27, 2023 (edited) 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 . What can be easier than that? The most complicated math I did for this project was to calculate a VAT - 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 . 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.... ____________ 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 January 27, 2023 by TheOnlyOne Share this post Link to post
Stano 143 Posted January 27, 2023 The boss needs to be changed 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
TheOnlyOne 10 Posted January 27, 2023 (edited) 22 minutes ago, Stano said: The boss needs to be changed 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 January 27, 2023 by TheOnlyOne Share this post Link to post
Stano 143 Posted January 27, 2023 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
Rollo62 536 Posted January 27, 2023 (edited) 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 The full reality is maybe that all the coolest, newest hip technolgy out there in the streets will be "Spagetti" to some degree Good technology need usually also some time to get ripe. Edited January 27, 2023 by Rollo62 Share this post Link to post
TheOnlyOne 10 Posted January 27, 2023 (edited) 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 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 January 27, 2023 by TheOnlyOne 1 2 Share this post Link to post
programmerdelphi2k 237 Posted January 27, 2023 take care about your comments here... who knows who can see it? ... a robot, a BOSS... your ex 👨🏭👨🏭👨🏭👩🎨 1 Share this post Link to post
TheOnlyOne 10 Posted January 28, 2023 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
Patrick PREMARTIN 74 Posted January 29, 2023 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 ! 1 1 Share this post Link to post
TheOnlyOne 10 Posted January 30, 2023 (edited) 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 January 30, 2023 by TheOnlyOne Share this post Link to post
TheOnlyOne 10 Posted January 30, 2023 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. 🙂 I haven't seen them yet appearing in the code 🙂 Share this post Link to post
omnibrain 15 Posted January 30, 2023 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. 4 Share this post Link to post
Tom Chamberlain 47 Posted January 30, 2023 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. Do not suffer fools. 3 Share this post Link to post
Patrick PREMARTIN 74 Posted January 30, 2023 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 1 Share this post Link to post
TheOnlyOne 10 Posted February 2, 2023 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. 1 Share this post Link to post