r/badcode • • Apr 07 '21

java Apparently Java can only handle 255 parameters in a constructor...

Post image
4.0k Upvotes

249 comments sorted by

View all comments

631

u/markand67 Apr 07 '21

I remember a friend of mine also hit the limit of columns in one MySQL table because of previous coworkers, total insanity.

491

u/echosalik Apr 07 '21

I can totally see it happening... I once saw a table with 80 - 90 columns... I was at a loss of words when I saw that. AND THAT PERSON REMEMBERED WHAT EACH COLUMN DID. HOW? I don't remember if I had breakfast this morning.

EDIT: I did, just saw the wrapper I failed to throw away after breakfast.

0

u/[deleted] Apr 07 '21

[deleted] — view deleted comment

155

u/SireBillyMays Apr 07 '21

As someone who has inexplicably taken multiple advanced courses in databases:

pls no.

133

u/bundabrg Apr 07 '21

I have one vendor who has a single column of 128 characters in a table. Just one column.

It's a hospital thing so patient number is characters 5-8, ward characters 10-13 etc with every char used.

It gets worse. The patient number got too large so.patient number is now characters 5-8, then append character 106 and character 119.

And there's lots more insanity like this. I swear when we got the documentation the person giving them to us sounded ashamed on the phone (not their fault, they inherited it).

63

u/SireBillyMays Apr 07 '21

So, wait. they have a database, where one of the tables is literally one field consisting of 128 chars, then they have subdivided that field into subfields?

Sounds like hell to work with right now, but honestly doesn't sound that hard to fix.

47

u/bundabrg Apr 07 '21

It gets worse (sorta). I have to use SOAP to interface with it :(

10

u/-IoI- Apr 07 '21

That fucking sucks, hopefully something like WCF or LINQ in the middle to ease the pain a bit

32

u/Lost4468 Apr 07 '21

So, wait. they have a database, where one of the tables is literally one field consisting of 128 chars, then they have subdivided that field into subfields?

It sounds like it was originally a paper implementation, in which case this sort of string representation can be incredibly efficient. If I give you a ton of drawers filled with patient details and tell you "find this patient", then if the records were assigned this sort of string, it would be very easy for you to narrow it down to a few records. I don't know how old the system is, but /u/bundabrg maybe it's because of this?

So then when they get digitised people don't want to move to a new system, or more likely you can't even change it because the hospital(s) are running two systems at once for a while. So you end up with weird data structures that make sense for paper records, but make no sense for computers.

Sounds like hell to work with right now, but honestly doesn't sound that hard to fix.

I don't know so again maybe /u/bundabrg could chime in. But one of the problems with this sort of thing is there's frequently literally hundreds of exceptions. Because it's a paper system over the years people have said e.g. "oh let's just start this one with 'OUTSIDE' since it comes from outside the country" or all sorts of weird similar exceptions. Well for 'OUTSIDE' it's easy to write an exception, but there's often so many of these exceptions, and no documentation, the people working there don't have a list of the exceptions they've made over the decades. And then once you end up with enough exceptions you realise there are plenty of ambiguous ones you can't possibly decide by writing basic if statements.

And it's medical as well, so you really don't want to risk mixing up records, violating HIPAA, not properly finding a record, etc. So you end up just being stuck with the stupid system. To fix it you need to go through everything manually and change it all out at once, which requires a fuck ton of time and money.

13

u/EvilPencil Apr 07 '21

Yeah, I think the fix would be to create a view that gives a more "normal" representation and yet doesn't create a second source of truth. Once all the consumers are interacting with the view instead of the underlying tabe, then do a migration and switch the inserts/updates over to the new schema.

6

u/Tornadic_Outlaw Apr 07 '21

If it really is bad enough that you couldn't write code to fix it, then it isn't usable as is. Exceptions nobody knows about aren't exceptions, they are errors, and if a human tried to look at the data they would make the same mistakes the computer made.

And if you are that concerned about losing ambiguous information in the current filing method you could even keep that column for legacy data and not populate it for new records.

→ More replies (4)

9

u/shh_coffee Apr 07 '21 edited Apr 07 '21

Sounds like it may be getting populated by a COBOL system where they're not dividing the patient record by it's fields when writing to the DB and they're just sending the whole patient record as one DB field. That would also explain the weird patient number append as in COBOL fields have fixed length and that sounds like someone just went "we can add another number by adding a field at the end of the record called ws-patient-num-append" or something so not to mess with the existing field lengths.

Just taking a wild guess though.

7

u/fakehalo Apr 07 '21

I wonder if this is the result of a migration from ancient times where they needed the original "database" structure for some portion of their codebase, which is likely no longer around.

Reminds me of things I've seen from decades ago.

→ More replies (1)

6

u/slower-is-faster Apr 07 '21

I worked for an insurance company that had an oracle database they paid a lot of money for. Their apps “document”, was stored as encrypted XML in a table with just one column - this was what they used oracle for.

→ More replies (1)
→ More replies (1)

19

u/echosalik Apr 07 '21

Yeah there comes a time where whatever you learned in the courses get thrown out... Like normalisation... It's good to have but not applicable everywhere... And idk why whenever I get newbies and i tell them to create joins without FKs, thier first statement is can we do that?

I'm like yeah, FKs are not required, makes things fast but not required.

FKs can really create a mess where inter-dependent data doest not come in a linear fashion, offline first apps.

7

u/PurpleMysticLlama Apr 07 '21

Lol bois, let's just take the relationship out of a relational database. We'll handle all of this in code np. Future developers? What happens when I leave? 'Fuck them' is what happens.

8

u/SireBillyMays Apr 07 '21

I mean, what you just mentioned was literally part of one of my courses (that course was, admittedly "applied databases".)

A lot of that course centered around grounding us a little though. "What you learn in the other courses might be theoretically perfect, but it's hardly necessary - nor efficient - for most systems you're likely to work on."

With that being said:

If you have a database with 80-90 columns you should probably look at what you're actually doing, and whether or not it's actually optimal. That could easily make things a giant headache to work with...

(I also must say I do enjoy only doing databases recreationally, where I can bend the "rules" a fair bit...)

→ More replies (4)
→ More replies (4)
→ More replies (8)

9

u/zakomo Apr 07 '21

The worst I witnessed, but luckily didn't have to maintain, was a database in which some tables had a column "notes" and in that column additional data stored in a csv format.

→ More replies (4)

10

u/bog5000 Apr 07 '21

80-90 columns per table is normal for big ERP

6

u/Lost4468 Apr 07 '21

AND THAT PERSON REMEMBERED WHAT EACH COLUMN DID. HOW

I would say descriptive column names and column comments. But then I'm not sure the type of person to do this would do that...

Although I could see how maybe you could get to this and it being excusable. Originally it was normalised, but they were getting performance issues when they reached scale X or whatever. For whatever reason the normal ways of improving performance in these situations didn't work well enough/couldn't be applied, so denormalisation was the only option.

The appropriate thing to do would have been to change the implementation, but given deadlines maybe this was the best thing to do as a temporary fix. After all it might be 1% of the work of changing the implementation, and could easily speed it up by a ton. But as everyone knows (especially in software dev), there's nothing more permanent than a temporary fix.

Or alternatively the table was auto-generated or reasonably abstracted out? If you're dealing with entirely auto-generated code and tables, then I think it's perfectly fine to have tables like this. It only possibly makes debugging harder when it comes up. Of course people will dislike it because it's "not elegant", but to the computer you could argue it's more elegant, it can easily have a much easier and less complex time dealing with this sort of data, we only consider it inelegant because we would struggle with it.

4

u/noXi0uz Apr 07 '21

We currently have to parse an excel file with over 400 columns.. Which might aswell be a sql table

→ More replies (5)

17

u/knightofren_ Apr 07 '21

Sometimes I fear that the entire downfall of human society hangs upon a junior developer being given database credentials

5

u/code_monkey_001 Apr 07 '21

I knew a dude who wrote a framework that routinely ran up against MSSQL's limit to table joins in a single query (also 255). Guy wasn't right in the head.

→ More replies (4)