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.

  • expr@programming.dev
    link
    fedilink
    arrow-up
    1
    ·
    20 minutes 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).

  • 𝕱𝖎𝖗𝖊𝖜𝖎𝖙𝖈𝖍@lemmy.world
    link
    fedilink
    arrow-up
    1
    ·
    edit-2
    45 minutes 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 filters. Our hot list 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
      1
      ·
      21 minutes 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.

  • softkitteh@lemmy.blahaj.zone
    link
    fedilink
    English
    arrow-up
    3
    ·
    2 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
      0
      ·
      2 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
        2
        ·
        50 minutes 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
          1
          ·
          33 minutes 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

  • kryptonianCodeMonkey@lemmy.world
    link
    fedilink
    arrow-up
    1
    ·
    2 hours ago

    Joined a new team and one of my first tasks was a refactor on a shared code file (Java) that was littered with data validations like if ("".equals(id) || id == null) { throw new IllegalArgumentException() }

    The dev who wrote it clearly was trying to make sure the string values were populated but they apparently A) didn’t think to just put the null check first so they didnt have to write their string comparison so terribly or else didnt understand short circuiting and B) didn’t know any other null-safe way to check for an empty string, like, say StringUtils.isEmpty()

      • kryptonianCodeMonkey@lemmy.world
        link
        fedilink
        arrow-up
        1
        ·
        edit-2
        31 minutes ago

        Sure. There were worse problems to. SQL injection vulnerabilities, dense functions with hundreds of lines of spaghetti code, absolutely zero test coverage on any project, etc. That’s just the easiest to show an example of and it’s also the one that made me flinch every time I saw it.

        "".equals() 😨

        • vrek@programming.devOP
          link
          fedilink
          English
          arrow-up
          2
          ·
          37 minutes ago

          If it makes you feel better at my last company I asked the “senior validation specialist” what the validation path would be for a program which incorporated unit tests.

          The answer I got was “what’s a unit test?”

  • wahooyeeha@lemmy.world
    link
    fedilink
    arrow-up
    2
    ·
    3 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
      2
      ·
      1 hour 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.

  • RagingRobot@lemmy.world
    link
    fedilink
    arrow-up
    4
    ·
    4 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
      1
      ·
      11 minutes ago

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

  • jjjalljs@ttrpg.network
    link
    fedilink
    arrow-up
    8
    ·
    5 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
      4
      ·
      4 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.

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

      Yeah but simply using entity framework would of made the configuration file a list of systems.

  • CetaceanNeeded@lemmy.world
    link
    fedilink
    arrow-up
    4
    ·
    5 hours ago

    At a small company I used to work for we agreed to take over the management system for someone trading physical resources. The guy that originally wrote it was self taught. We did a hand over with him where he took us through the code base. It was written in dotnet but it was a huge mess, he had blended multiple different dotnet paradigms, there was mixed business and UI code all over the place, large chunks of html were stored in the db, db code was just scattered through the application. We took it over briefly but it was a nightmare to work on and we found a SQL injection vulnerability. So as kindly as possible we told the client that his software was a piece of shit and the dev he hired had no idea what he was doing.

  • Hasherm0n@lemmy.world
    link
    fedilink
    arrow-up
    1
    ·
    3 hours ago

    There are a couple that come to mind.

    Definitely the worst, a C# .net mvc application with multiple controllers that were 10s of thousands of lines long. I ran sonarqube on this at one point and it reported over 70% code duplication.

    This code base actively ignored features in the framework that would have made things easier and instead opted to do things in ways that were both worse, and harder to do. For example, all SQL queries were done using antiquated methods that, as an added benefit, also made them all injectable.

    Reading the code itself was like looking at old school PHP, but c#. I know that statement probably doesn’t make sense, but neither did the code.

    Lastly, there was no auth on any of the endpoints. None. There was a login, but you could supply whatever data you wanted on any call and the system would just accept it.

    At the time I was running an internal penetration test team and this app was from a recent acquisition. After two weeks I had to tell my team to stop testing so we could just write up what we had already and schedule another test a couple months down the line.

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

      What is a sonarqube? I never heard that term before. Could you also provide the names of some software to run them?

      • AliasVortex@lemmy.world
        link
        fedilink
        English
        arrow-up
        1
        ·
        edit-2
        2 hours ago

        Sonarqube is a kind of like an automated code quality checker that works for a bunch of programming languages. It’s pretty configurable (though I’ve never configured it myself), so it can be set up to check a code base for a wide range of things.

        There’s a couple of different ways to run it, in my experience bigger companies usually have a dedicated server on their internal networks that connects to their CI/CD pipelines so that code gets checked before it gets merged in.

        On a smaller scale, it’s also possible to run locally (either on metal or inside a docker container). From there you’d install a plugin to your IDE of choice.

        More info:

  • Xerxos@lemmy.ml
    link
    fedilink
    arrow-up
    3
    ·
    5 hours ago

    Here is my story:

    There were console outputs after nearly every line. I asked about them: “Oh, I couldn’t get the debugger to work, so I print everything to the console” This was everywhere. The whole program was like this. On a standard Linux machine. It wasn’t even remote debugging or something. Just a local C++ program. The filenames where written in 8+3. Again, on a modern Linux machine. His answer? “You never know where we’ll port this software to” Onto computers that were outdated decades ago? To embedded systems? Of course he had no answer for this except “just in case…”

    I could tell you more, that software was the stuff for nightmares.

  • SaveTheTuaHawk@lemmy.ca
    link
    fedilink
    English
    arrow-up
    4
    ·
    7 hours ago

    My university uses ORACLE. To make a payment from a research account, you need to manually input a 15 character chart string. Every time.

  • invertedspear@lemmy.zip
    link
    fedilink
    English
    arrow-up
    18
    ·
    12 hours ago

    First of all, lack of ORM isn’t bad. It’s not a good or bad thing to use them out not use them. What’s bad is not sanitizing your query inputs and you don’t need an ORM to do that.

    I think the worst thing I’ve seen is previous devs not realize there’s a cost to opening a DB connection. Especially back when DBs were on spinning rust. So the report page that ran one query to get the all the items to report on, then for each row ran another individual query to get that row’s details was probably one of the slowest reports I’ve ever seen. Every DB round trip was at minimum 0.1 seconds just to open the connection, run the query, send back the data, then close the connection. So 10 rows per second could be returned. Thousands of rows per page has people waiting several minutes, and tying up our app server. A quick refactor to run 2 queries instead of hundreds to thousands and I was a hero for 10 min till everyone forgot how bad it was before I fixed it.

    • BehindTheBarrier@programming.dev
      link
      fedilink
      arrow-up
      4
      ·
      7 hours ago

      It’s the round trips that kill you.

      Oracle drivers for .NET are fun. Have a user client application which uses quite a lot of data, but a few thousand rows are fetched some queries. It’s way too slow for any larger query, turns out for the batch query kind of work we do, the default FetchSize for Oracle is just a performance killer. Just throw it to 128 MB and it doesn’t really hurt at all.

      Worst thing i’ve seen though, apart from the 150 line long dynamic sql stored in our database, was probably a page in our program that loaded about 150 rows from the database. Normally we do create a new connection for each query, but it’s fine since Oracle has a connection pool. Whatever millisecond is trumped by the round trip. But imagine a UI so badly written, it did 4 separate database queries for EACH row it loaded into the UI list. Useless things like fetching a new ID for this row in case it is changed, reading some data for the row i think, and more. Thing took a solid minute to load. There was so many bad patterns in that page that even during the PR for improving the speed it was just dealing with a mess because you couldn’t just rewrite the entire thing, so they had to make it work within the constraints. Horrible thing to work with.