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

Show parent comment

59

u/bschlueter Apr 07 '21

There comes a time when even working code needs to be examined. Also, if it was working then why did someone add another parameter?

66

u/Willinton06 Apr 07 '21

Ok let’s just say it’s a very dynamic piece of code

4

u/botle Apr 07 '21

Why can't it be a very dynamic piece of code that organizes the data in some type of structures?

13

u/Lost4468 Apr 07 '21

There comes a time when even working code needs to be examined.

Ha! People would be shocked if they realised just how much of our infrastructure is run on software that we don't even have the source code for anymore, much less the ability to do something about it.

There are companies (and government agencies) out there where a large part of their infrastructure is running and no one in the company knows how, or sometimes even where to it's running. The software industry changes its mind on how thing should be done all the time these days, but you go back a few decades and the etiquette was so much worse, there's so much software and infrastructure out there from back then that had zero regard for documentation, versioning, tidy code, bus factor, even code comments. Oh and a ton of it is also caught up in copyright no mans land, where companies didn't ever properly get the rights to the source code or even the software sometimes.

It's really a mess out there. This is one of the advantages to open source software that is often forgotten.

5

u/646c726f576f6c6c6548 Apr 07 '21

It was from a pragmatically generated file in android studio where each parameter is a view in a single layout and the app had more than 255 views in a single layout

6

u/sharpened_ Apr 07 '21

But why on earth would it need to pass in All The Views if you're only ever going to use 1 at a time?

Seems like a refactor of that function is in order, what hellish software will write code like that? Or is programmatically generated code generally simple?

I've only ever touched it once, and that basically created getters and setters from a table.

4

u/646c726f576f6c6c6548 Apr 07 '21

It's pretty simple, but creates thing thing called a binding and is a wrapper that makes it easier to refer to different views.

We also weren't using Fragments like we should have and ended up having to after this.