I’ll give an example. At my previous company there was a program where you basically select a start date, select an end date, select the system and press a button and it reaches out to a database and pulls all the data following that matches those parameters. The horrors of this were 1. The queries were hard coded.

  1. They were stored in a configuration file, in xml format.

  2. The queries were not 1 entry. It was 4, a start, the part between start date and end date, the part between end date and system and then the end part. All of these were then concatenated in the program intermixed with variables.

  3. This was then sent to the server as pure sql, no orm.

  4. Here’s my favorite part. You obviously don’t want anyone modifying the configuration file so they encrypted it. Now I know what you’re thinking at some point you probably will need to modify or add to the configuration so you store an unencrypted version in a secure location. Nope! The program had the ability to encrypt and decrypt but there were no visible buttons to access those functions. The program was written in winforms. You had to open the program in visual studio, manually expand the size of the window(locked size in regular use) and that shows the buttons. Now run the program in debug. Press the decrypt button. DO NOT EXIT THE PROGRAM! Edit the file in a text editor. Save file. Press the encrypt button. Copy the encrypted file to any other location on your computer. Close the program. Manually email the encrypted file to anybody using the file.

  • Phoenixz@lemmy.ca
    link
    fedilink
    arrow-up
    18
    ·
    4 hours ago

    A program that HR had built so that all employees could they their payment receipts online

    The username was the companies’ email address, the password was a government personal id code that you can lookup online, a don’t change, and you can’t update the password to something else.

    So I told the director of HR this was a bad idea. She told me I was overreacting until I showed her her own receipt, then she finally understood that this is a really fucking bad idea.

    Okay, so now she out me in charge of debugging that program.

    So I setup a meeting with the director of the company they hired, he came by with the developer: a 21 yo girl who I think hadn’t finished college yet. Great start! Apparently it was her idea to do the authentication like that so that explains a few things.

    So we dive in to the code.

    First of all, the “passwords” were stored in blank, no hashing, no encryption, nothing. That wasn’t the worst.

    For the authentication she made a single query to check if the user email existed. Of that was true, then step two was a second query to see if the password existed. If that were true, the email had been authenticated.

    So let’s say, hypothetically, that they had actual passwords that people could change… I could still login with the email from anyone, and then use MY OWN password to authenticate.

    This just blew my mind so hard that I don’t think I ever fully recovered, I still need treatment. The stupidity hurts

    • groet@feddit.org
      link
      fedilink
      arrow-up
      7
      ·
      3 hours ago

      I wouldnt blame that on stupidity as much as on ignorance and naivety. Many people simply don’t think about anybody deliberately misusing their design. The idea that somebody could even want to access somebody elses receipts didn’t occur to them. And if they were still doing their studies they might not have known that you can “combine” SQL queries and ask for two things at once.

      I don’t blame the girl, but whoever chose her to design a system with sensitive information.

  • Mr. Satan@lemmy.zip
    link
    fedilink
    arrow-up
    6
    ·
    5 hours ago

    So this is not as bad as some of the other stories I’ve seen, but I’ll bite.

    It was an old .NET Framework MVC app. Some internal product management system or something. There was a need to do a PDF export in one of the use cases, so someone implemented it. It wasn’t a good implementation: one big controller, mixing UI and business logic, etc. However, it basically came down to a single private method in a specific controller for a page.

    Now time passes and lo and behold, we need a PDF export in another page for a different use case. “No problem,” - same dev, probably - “I already solved this problem. I’ll just reuse the PFD generation logic.”
    Now, any sane person would probably try to refactor the code responsible for PDF stuff into a separate service (class) and reuse it. A less sane, but somewhat, acceptable approach would have been to just copy paste the thing into another controller and call it a day.

    Ha! No no no no no no… Copy pasting is bad, code should be reused…

    The end solution: REFLECTION. So the dev decided that the easiest way to make it work was to: 1) use reflection to inject one controller into another; 2) then use reflection again to get access and call that private method for PDF rendering into a stream.


    Fortunately I didn’t have to fix that fragile mess. But I did my fair share of DevExpress corpse hacking and horrible angular “server side rendering” workarounds.

  • Valmond@lemmy.world
    link
    fedilink
    arrow-up
    19
    ·
    8 hours ago

    The architect sending a pointer over an API, in hexadecimal string format. char *c = “71E4F33B” just cast it on the right structure bro.

    Just to add, we only did C/C++, on windows mfc, in a monolithic software.

    I spent quite some time assuring myself that I was not the insane person before bringing it up with him.

  • quinkin@lemmy.world
    link
    fedilink
    arrow-up
    18
    ·
    9 hours ago

    XML-DOM page templates stored in a database, line by line.

    So rendering a page started with:

    select * from pages

    where page_id = ‘index’

    order by line_number asc;

    Each line of XML from each record was appended into a single string. This string was then XSLT transformed to HTML, for every page load.

    • dejected_warp_core@lemmy.world
      link
      fedilink
      arrow-up
      9
      ·
      8 hours ago

      This has to be one of the worst ways to reinvent a filesystem that I’ve ever heard. At the very least, storing static data in an relational database at this scale should be a slappable offense.

      • quinkin@lemmy.world
        link
        fedilink
        arrow-up
        7
        ·
        8 hours ago

        The session data, that would have been fantastic to have in a relational, queryable, reliable and trustable format was stored as a single giant string of PHP pickled data structure in a session file associated with the users cookie id.

  • NotMyOldRedditName@lemmy.world
    link
    fedilink
    arrow-up
    11
    ·
    edit-2
    10 hours ago

    For anyone who knows and understands Android development, process death, and saved state…

    The previous dev had no understanding of any of it, and had null checks with returns or bypassing important logic littered all over the app, everywhere.

    I could only assume he didn’t understand how all these things were randomly null or why it was crashing all the time so he thought oh, i’ll just put a check in.

    Well, you minimize that app for a little bit, reopen it, and every screen was fucked visually and unusable, or would outright crash. It was everywhere. This was before Google introduced things like view models which helped but even then for awhile weren’t a full solution to the problem.

    It was many many months of just resolving these problems and rewriting it the correct way to not have these problems.

    • Kazumara@discuss.tchncs.de
      link
      fedilink
      arrow-up
      6
      ·
      8 hours ago

      Oh I remember. There are tons of events and associated handlers. Even just switching to landscape view stops and restarts an android view I think. Friends at uni handled that problem by disallowing landscape view instead of handling it hahah

      • NotMyOldRedditName@lemmy.world
        link
        fedilink
        arrow-up
        3
        ·
        edit-2
        8 hours ago

        Friends at uni handled that problem by disallowing landscape view instead of handling it hahah

        😭

        Such a tragic and common ‘solution’ because it doesn’t actually solve it, it just delays it until someones minimizes the app for 30 minutes and re opens it, or one of the many many other ways that also trigger it.

        I’ve had some apps that I do lock to portrait, but I would disable that flag on debug builds, since rotating the phone was the easiest way to test for some of those bugs. I didn’t worry about a good looking UI since it’d be locked in portrait, I just used it to test for bugs.

  • AnarchistArtificer@slrpnk.net
    link
    fedilink
    English
    arrow-up
    20
    ·
    13 hours ago

    I don’t have any specific examples, but the standard of code is really bad in science. I don’t mean this in an overly judgemental way — I am not surprised that scientists who have minimal code specific education end up with the kind of “eh, close enough” stuff that you see in personal projects. It is unfortunate how it leads to code being even less intelligible on average, which makes collaboration harder, even if the code is released open source.

    I see a lot of teams basically reinventing the wheel. For example, 3D protein structures in the Protein Database (pdb) don’t have hydrogens on them. This is partly because that’ll depend a heckton on the pH of the environment that the protein is. Aspartic acid, for example, is an amino acid where its variable side chain (different for each amino acid) is CH2COOH in acidic conditions, but CH2COO- in basic conditions. Because it’s so relative to both the protein and the protein’s environment, you tend to get research groups just bashing together some simple code to add hydrogens back on depending on what they’re studying. This can lead to silly mistakes and shabby code in general though.

    I can’t be too mad about it though. After all, wanting to learn how to be better at this stuff and to understand what was best practice caused me to go out and learn this stuff properly (or attempt to). Amongst programmers, I’m still more biochemist than programmer, but amongst my fellow scientists, I’m more programmer than biochemist. It’s a weird, liminal existence, but I sort of dig it.

  • NigelFrobisher@aussie.zone
    link
    fedilink
    arrow-up
    10
    ·
    12 hours ago

    I think the worst software-gore I remember seeing was a web app that dumped all the data to the browser as a huge XML file and then had JavaScript translate the contents of the xml into views. That probably wouldn’t even sound that far off the reservation now if it was JSON, thanks to the sleepless efforts of the JavaScript industrial complex, but back then you’d just render pages and return them.

  • softkitteh@lemmy.blahaj.zone
    link
    fedilink
    English
    arrow-up
    20
    ·
    15 hours ago

    Oh boy, this one was a doozy…

    Was working at a very big company named after a rainforest on smart home products with integrations for a certain home assistant…

    New feature was being built that integrates the aforementioned home assistant with customer’s printers so they can ask the assistant to print stuff for them.

    The initial design lands from our partner team with a Java backend service fairly nicely integrated with some CUPS libraries for generating the final document to be sent to the customer’s printer. All good.

    They are about to launch when… uh oh… the legal team notices an AGPL licensed package in one of the CUPS library’s dependencies that was absolutely required for the document format needed by the project and the launch is cancelled.

    So the team goes off in a panic looking for alternatives to this library and can’t find any replacements. After a month or two they come back with their solution…

    Instead of converting the document directly in the backend service with the linked CUPS library (as AGPL is a “forbidden license” at this company) the backend uploads the initial document to an S3 bucket, then builds a CUPS document conversion bash shell script using some random Java library, the shell script is then sent (raw) to a random blank AWS host that comes prepackaged with CUPS binaries installed (these hosts were not automated with CI/CD / auto updates as was usually mandated by company practice because updating them might remove the CUPS binaries, so they required a ton of manual maintenance over the service’s lifetime…), the bash shell script is then executed on that “clean” host, downloading the document from S3, converting it via the CUPS command line binary, then reuploading it to another S3 bucket where the Java backend picks it up and continues the process of working the document through the whole backend pipeline of various services until it got to the customer’s printer.

    This seemed to satisfy the legal team at the very least, and I have no doubt is probably still in production today…

    The kicker though? After all those months of dev work from a whole team (likely all on 6 figure salaries), and all the time spent by various engineers including myself on maintenance and upkeep on that solution after it was transferred to us?

    An alternative, completely unrestricted corporate license was available for the package in question for about $100 per year so long as you negotiated it with the maintainers.

    But that was a completely unacceptable and avoidable cost according to upper management…

    • vrek@programming.devOP
      link
      fedilink
      English
      arrow-up
      5
      ·
      15 hours ago

      Wait 100 per year total or 100 per seat per year? If it’s per seat I can understand, if it’s total wtf…

      • softkitteh@lemmy.blahaj.zone
        link
        fedilink
        English
        arrow-up
        10
        ·
        14 hours ago

        $100 total, per year… as a FOSS enthusiast, it made me very angry that such a rich company was so petty over such a small cost for a product that raked in multiple millions of dollars per year 😾

        • vrek@programming.devOP
          link
          fedilink
          English
          arrow-up
          7
          ·
          14 hours ago

          Yeah that’s fucked up. From two perspectives 1. Who ever wrote that library needs money to survive. 2. From the company point of view they wasted WAY more money on the development then the license. Hell if 1 developer spent a day to do it, they paid more than they would for the license

          • NotMyOldRedditName@lemmy.world
            link
            fedilink
            arrow-up
            5
            ·
            edit-2
            10 hours ago

            The first time something goes wrong with that complicated setup, it probably pays for a decade half a century or more of it’s fee.

  • lonesomeCat@lemmy.ml
    link
    fedilink
    English
    arrow-up
    4
    ·
    11 hours ago

    I’ve seen a many-to-many relationship written as a column of CSV ids.

    Also same ppl used “ID” instead of “id” (sometimes Id even) which made ORMs cry hard

    • Fiery@lemmy.dbzer0.com
      link
      fedilink
      arrow-up
      3
      ·
      edit-2
      10 hours ago

      Half our ids are called ‘number’ sooo. Also our entire in-database translation system relies on guids that are not foreign keys. The only reason our ORM doesn’t flip on that is because it’s completely custom made with semi-autogenerated stored procedures resolving that translation in-database (using yet another SP).

      We are at 2696 stored procedures right now, most of those are simple CRUD (can’t do straight selects on our tables because of the translations, so every select with different parameters is a SP)

  • expr@programming.dev
    link
    fedilink
    arrow-up
    10
    arrow-down
    2
    ·
    14 hours ago

    The encryption thing is definitely weird/crazy and storing the SQL in XML is kinda janky, but sending SQL to a DB server is literally how all SQL implementations work (well, except for sqlite, heh).

    ORMs are straight trash and shouldn’t be used. Developers should write SQL or something equivalent and learn how to properly use databases. eDSLs in a programming language are fine as long as you still have complete control over the queries and all queries are expressable. ORMs are how you get shit performance and developers who don’t have the first clue how databases work (because of leaky/bad abstractions trying to pretend like databases don’t require a fundamentally different way of thinking from application programming).

    • Pokexpert30 🌓@jlai.lu
      link
      fedilink
      arrow-up
      2
      ·
      edit-2
      9 hours ago

      Orm are a way to handle seamlessly the model aspect of a codebase. But I agree.

      My first big project (Symfony, with doctrine orm), we had to have several SQL requests made by hand due to the complexity of the databases here and there. So we were kept on our toes when it came to database knowledge haha

      • expr@programming.dev
        link
        fedilink
        arrow-up
        3
        ·
        4 hours ago

        Except it’s not seamless, and never has been. ORMs of all kinds routinely end up with N+1 queries littered all over the place, and developers using ORMs do not understand the queries being performed nor what the optimal indexing strategy is. And even if they did know what the performance issue is, they can’t even fix it!

        Beyond that, because of the fundamental mismatch between the relational model and the data model of application programming languages, you necessarily induce a lot of unneeded complexity with the ORM trying to overcome this impedance mismatch.

        A much better way is to simply write SQL queries (sanitizing inputs, ofc), and for each query you write, deserialize the result into whatever data type you want to use in the programming language. It is not difficult, and greatly reduces complexity by allowing you to write queries suited to the task at hand. But developers seemingly want to do everything in their power to avoid properly learning SQL, resulting in a huge mess as the abstractions of the ORM inevitably fall apart.

  • jjjalljs@ttrpg.network
    link
    fedilink
    arrow-up
    19
    ·
    18 hours ago

    There was a website where users could request something or other, like a PDF report. Users had a limited number of tokens per month.

    The client would make a call to the backend and say how many tokens it was spending. The backend would then update their total, make the PDF, and send it.

    Except this is stupid. First of all, if you told it you were spending -1 tokens, it would happily accept this and give you a free token along with your report.

    Second of all, why is the client sending that at all? The client should just ask and the backend should figure out if they have enough credit or not.

    • vrek@programming.devOP
      link
      fedilink
      English
      arrow-up
      11
      arrow-down
      1
      ·
      18 hours ago

      I agree but I would say if there are variable token costs depending on report it would be nice if client sent request to server, server calculates x tokens to be used, sends x to client, client confirms that’s acceptable, server does work.

      Like if I expected a report to be 2 tokens but because of some quirk or a typo or something it cost 200 tokens I would like a chance to cancel it if it’s not worth it.

  • RagingRobot@lemmy.world
    link
    fedilink
    arrow-up
    12
    ·
    17 hours ago

    We had some super old code in our company monorepo that was written by someone who became the CTO, there was a comment forbidding people from writing private methods in the code base because “we aren’t babies”. It explained so much about the awful code and why everything was crazy.

    • expr@programming.dev
      link
      fedilink
      arrow-up
      2
      arrow-down
      1
      ·
      14 hours ago

      Access modifiers are definitely something I despise about OOP languages, though I understand that OOP’s nature makes them necessary.

  • 𝕱𝖎𝖗𝖊𝖜𝖎𝖙𝖈𝖍@lemmy.world
    link
    fedilink
    arrow-up
    5
    ·
    edit-2
    13 hours ago

    I got forcefully moved onto another team at work. They use Observables to replace signals, change detection, local storage, and even function calls. Every single component is a tangled mess of Observables and rxjs. Our hotlist has over 300 bugs, and the app is like 6 months old.

    I’ve been looking for a new team

    • psivchaz@reddthat.com
      link
      fedilink
      arrow-up
      2
      ·
      14 hours ago

      There’s a part of me that kind of feels like this could work if you just do it right. Like the idea is kind of cool, in a way.

      • 𝕱𝖎𝖗𝖊𝖜𝖎𝖙𝖈𝖍@lemmy.world
        link
        fedilink
        arrow-up
        5
        ·
        edit-2
        13 hours ago

        Unfortunately, it results in a dependency tree that resembles the tangled power lines in Bangladesh. Especially when half the code base is written by new devs using GAI and there isn’t a design doc in sight

  • wahooyeeha@lemmy.world
    link
    fedilink
    arrow-up
    8
    ·
    16 hours ago

    Back in the day, a C program to handle estimating procurement costs for complex government contracts. We had to figure out the code and write in in a different language. It was just one giant loop, no functions, with variables named V1, V2, V3, etc. Hundreds and hundreds of them. I still shudder at the horror of it all.

    • vrek@programming.devOP
      link
      fedilink
      English
      arrow-up
      8
      ·
      15 hours ago

      I worked on a laser seam welder which basically was programmed in a mix of g code and I guess vb??

      The fun part was variables could only be numbers between 100 to 999. So let’s say you have a sensor and need to verify it’s within a certain range. You could set #525 to 10 and #526 to 20 then say #527 = sensor 1 signal. Now lower down you verify it as if(#525 > #527 || #526 < #527){show error}

      Now you could create each variable at the beginning with comment of what it was but then have to keep referring to the top to remind yourself what number was what. Or create the variable at first use so it was closer but now it’s spread across the document.

      I went with first case and just printed out the first 2 pages which listed all the variables.

      Before you ask, I talked to the guy who wrote the language and made the system many times he confirmed you couldn’t use variable names.

      • Machinist@lemmy.world
        link
        fedilink
        English
        arrow-up
        4
        ·
        10 hours ago

        G Code is basically a geometric scripting languge and isn’t Turing complete in basic implementations. Every manufacturer pretty much also has their own dialect that is Turing complete.

        Gcode with control commands and variables is called, no shit, Macro G Code. It’s Turing complete. That form of variable names is normal and is inherited from hardware registers/banks and TTL.

        It’s not unusual for a save dialog to be labelled Punch as it has a direct lineage from punch tape.

        Kind of like assembly and a graphing calculator had an abortion together.

        • vrek@programming.devOP
          link
          fedilink
          English
          arrow-up
          3
          ·
          7 hours ago

          Lol, yeah I’ve written g-code from 4 different manufacturers and yeah it’s a new experience each time.

      • Feathercrown@lemmy.world
        link
        fedilink
        English
        arrow-up
        5
        ·
        13 hours ago

        I wonder at what point it would be easier to make a compiler to convert variable names into those numbers

        • vrek@programming.devOP
          link
          fedilink
          English
          arrow-up
          3
          ·
          6 hours ago

          If you did and it was usable across multiple cnc manufacturers you could make a pretty penny.