Live data from Hacker News

A project with a single 11,000-line code file

austinhenley.com

251–260 of 346 posts

Re: A project with a single 11,000-line code file

#251
post #115

Earlier quoted context omitted.

"Flat is better than nested" - The Zen of Python I had an "everything should be broken into a hierarchy!" stage back when I was learning to code, and boy was I off track. In my defense, at the time (and this dates me) OOP was all the rage.

I find OOP spaghetti can be incredibly difficult to navigate, example: Class hierarchies 4 or 5 layers deep, some subclasses overriding the parent, others not. It can be it very difficult to follow what's actually going on. Procedural spaghetti is more manageable, though I once had to update a C app with a 3000 line case statement. Pure madness.

I remember working on a project with endless exception class hierarchies - that was a monumental pain when trying to diagnose what led to an exception.

In a subsequent project we banned subclassing of exceptions.

Re: A project with a single 11,000-line code file

#252

Earlier quoted context omitted.

> The worst type is when someone had the time to overarchitect and overengineer things. I concur. Refactoring should be as much about removing unneeded abstraction and features as it is about adding same. > there is little incentive or bonuses for improving the situation. Yeah, I just can't seem to believe this in my soul. I just want to fix ugly code and can't stop myself. I get huge satisfaction from speeding up, t…

Just do it. Don’t ask for permission. You will end up more productive not less.

This - I've been doing this for years now and simpler code (both simpler logic and the removal of unused code) makes working on legacy codebases feel completely different.

Re: A project with a single 11,000-line code file

#253

So afraid to write bad, spaghetti code, I ended up writing no code at all. This thread made me realize that it's better to have a working profitable project with bad code, than a perfect unfinished project, with meticulously chosen design patterns. Afraid of being judged for bad code, I could not start until I had the right architecture. I'm glad I read this. This is developers therapy.

Restaurant industry version: I was so afraid to cook in a dirty kitchen, I ended up not cooking at all. This thread made me realize that's better to sell food prepared on dirty surfaces with unrefrigerated ingredientes half-eaten by rodents and roaches that makes people sick, than fresh food prepared on clean surfaces with clean utensils. I'm glad I read this. This is a restaurant worker story. Construction industry…

If you're writing code that controls radiation therapy machines or trains or autoclaves or something, yah, maybe there should be some regulation and potential jail time for negligence. But 95% of all software written (especially if it's the first version of new software) isn't life or death. If the next social media startup or saas-for-painters is spaghetti code it's not going to hurt anyone.

Failure is cheap in our industry. That's largely a very good thing.

Re: A project with a single 11,000-line code file

#254
Those are rookie numbers.

About 10 years ago I was shorty working on an app for bank tellers.

The app was in production for 2-3 years at that point, 4 people where implementing new features.

The whole app was 4 Java files/classes.

2 files had about 1.000LOC, 1 had about 15.000LOC, and last one had 80.000+ LOC.

The big one did it all, UI, db calls, forms for printing, network calls.

Most of the variables where named something like “c12”, “bkf22” etc.

Re: A project with a single 11,000-line code file

#256
post #165

Earlier quoted context omitted.

What's an alternative to files that doesn't just have all the same attributes of files anyway? If it involves breaking code into multiple chunks of related functions, and possibly having these chunks act as namespaces, that sounds like what a file does.

Maybe it's the editors that need updating. It would be pretty neat to have the chunks of functions / namespaces model as lots of tiny separate files on the disk, but a sort of view-layer so that you can view all the related ones in one virtual file. You could even then have multiple virtual files that include the same raw files. For example in a video game your player, monsters, health potions, and attacks could all…

I might be remembering wrong but I thought Visual C++ 6 might have had a class browser as an alternative to a file browser. Maybe modern Visual Studio has it too?

Re: A project with a single 11,000-line code file

#258
This one time, working at a country's state electricity provider, I was tasked with drawing all the power stations in the country on a map. I was stumped, I couldn't figure out why the markers weren't showing up. Then I zoomed out and saw them being drawn on the other side of the world. The latitudes and longitudes were the wrong way around. The data was from a government-maintained database. lol.

Re: A project with a single 11,000-line code file

#259
post #62

Earlier quoted context omitted.

It speaks to the state of software engineering that people are complaining about file length, instead of something meaningful like cyclomatic complexity. A 10k single line program can be easier to understand and better organized than an overly abstracted mess strewn across multiple files, but which checks all the "best practice" checkboxes.

Do you think the people who wrote this were measuring cyclomatic complexity? Obviously you can have >10k LOC file that is well-maintained and useful.. but there's ample evidence in the post that this was _not_ one of those, but a machine held together by duct tape, spit, and hope.

> Do you think the people who wrote this were measuring cyclomatic complexity?

As a first-order guess, I would guess that no code has its cyclomatic complexity measured. As a fraction, I'm probably not too far off.

Re: A project with a single 11,000-line code file

#260

So afraid to write bad, spaghetti code, I ended up writing no code at all. This thread made me realize that it's better to have a working profitable project with bad code, than a perfect unfinished project, with meticulously chosen design patterns. Afraid of being judged for bad code, I could not start until I had the right architecture. I'm glad I read this. This is developers therapy.

Getting something working and out there is 90% of the battle, especially on small or single person teams. I wrote a saas php app with vanilla html and JS that ran without issue for 8.5 years for a fortune 1000 company. About twice a year I would return to it to add or modify a feature and I had no idea how a lot of it worked and even had duplicated or redundant files that I was too afraid to delete. It worked though…

I want to hear more from you.
Post reply on HN