A project with a single 11,000-line code file
301–310 of 346 posts
Re: A project with a single 11,000-line code file
#302Re: A project with a single 11,000-line code file
#303Quote: "There was no test environment. If I made a change, I had to test it in "production"." What year is this? 70's and mainframes? Because no way in hell you cannot, on large organization that had "Jeff in marketing", since 80's and PC's, duplicate the environment. Especially given this was used by almost everybody in the organization. And once you're done duplicating the production, and create proper test environ…
If the author was the only person editing the file, and had a reasonable expectation of owning it for at least 6 months, then yes, start building a second environment. But one antipattern might be that the file is being modified by other people, even if on paper he is the only owner. So while you create a test, someone you don't even know exists modifies prod right under you. Another antipattern is forever-changing o…
Yes, there is. Since he clearly stated that started as a job assigned to his team, he could've version it right there where it was officially staying. Then it would've be very easy to see changes done to it by somebody else, even if who was that somebody else was unknown to him.
"Then someone anonymous in some layer above you decides something else"
He also stated in the article that he had a lot of time in his hands and tried a refactoring. You don't have time to do a refactoring of a file with 11k lines of code in only 2 weeks, so he clearly had at least several months.
My conclusion still stands.
Re: A project with a single 11,000-line code file
#304Re: A project with a single 11,000-line code file
#305Earlier quoted context omitted.
There's a YouTube video about beginner musicians vs intermediate vs advanced. The beginner uses simple chords The intermediate uses advanced chords, crazy fills and runs and riffs. The advanced uses simple chords
That's not far from a similar saying in software: expert developers write code that looks like a beginner's, but simpler and with fewer bugs.
Intermediate devs write code that is over-engineered in places where it could be simple, while still needing a lot of extensive refactoring in the parts that deal with irreducible complexity.
Expert devs think deeply about the problem at hand, understand where the complexity is, and create a solution that is as simple as possible, but no simpler. After the fact, beginner and intermediate devs tend to think of this code as something trivial, that anyone could do.
This is why it may sometimes be tactically useful for the expert dev to sometimes take on projects that some beginner or intermediate team has been struggling with for some extended period of time, analyze it properly, and show how elegant the difficult parts can be solved.
Care is needed, though, as it can affect the morale of the other devs and even cause hostility. If the expert dev has a secure position in the organization and want to keep those other devs around, keeping a low profile as well as letting those devs take as much as possible of the credit is adviced.
Re: A project with a single 11,000-line code file
#306I once refactored a 15k plus line sql file. Fun times
I'm guessing / hoping there was a lot of data in there as INSERT statements. My horror story was being asked to do maintenance on PHP sites written in the early days of PHP. Hundreds - maybe thousands - of PHP files with copy-pasted HTML and intermingled logic. As far as I can tell, the idea of instantiating a whole MVC framework from a single entrypoint file came after that particular site was created, so every poss…
Oof. That tbh sounds worse
Re: A project with a single 11,000-line code file
#307I remember many years ago coming across a reimplementation of the server side for a popular MMORPG of the time, reverse-engineered from the client (which was Flash) by what was likely a teenager --- it was over 100k lines in a single file, written in Visual Basic. Global variables everywhere, short names, and not even indentation. All the account data was stored in flat files, there was no actual DB. No "best practic…
I suspect the game was Runescape. My brother used to be a fan of these custom servers.
Re: A project with a single 11,000-line code file
#308This shell script was 9,000 lines long. Each new "menu" after entering a number corresponding to your selection from a previous menu took 60-120 seconds to appear. Needless to say, configuring systems was a painfully slow process.
I quickly found it practically impossible to extend this tool to meet the new requirements, so I quietly rewrote it (also still in shell script, because of host limitations). The new version was 1,000 lines, and menu changes took Management was not happy that I decided to rewrite (since the manager had written it himself originally), but the users were ecstatic about the performance increase. I would not be surprised if that tool was still in use today.
Re: A project with a single 11,000-line code file
#309I ran wc on FreePascal to search for some. There are a few, but not as many as I expected.
9k file, data structures for the compiler itself: https://gitlab.com/freepascal.org/fpc/source/-/blob/main/./c...
30k file: Pascal parser/scope resolver: https://gitlab.com/freepascal.org/fpc/source/-/blob/main/pac...
And the record:
119k file, Sharepoint API (but it seems to be autogenerated): https://gitlab.com/freepascal.org/fpc/source/-/blob/main/pac...
As far as libraries go, this is one of my favorites:
23k file, regular expression library: https://github.com/BeRo1985/flre/blob/master/src/FLRE.pas
I searched my own files and found a 197k file to parse HTML entities. But that was an autogenerated trie (one switch/case for each letter)
Re: A project with a single 11,000-line code file
#310That beats the 1000 lines inside a single if {} block that I once found. (The conditional in that if {} always evaluated to true).
Lol, reminds me of the meme: var a = true; if(a == true) then return true; else if(a == false) then return false; Or something like that.
public static bool ConvertToBoolean(this int number)
{
var TrueOrFalse = false;
if(number != 0)
TrueOrFalse = true;
return TrueOrFalse;
}