Fighting a monster
-
I think the opposite situation is even worse. You get some abstraction/interface monkey at the keyboard and you may find yourself jumping through a dozen different 5 line files to get to the actual code that adds X + Y. Tons and tons of code written to handle the unlikely event that your boss is going to walk into your office one day and say, "Hey, let switch from Oracle to SQL". I understand some vended products feel the need to support that, but they don't.
-
The company was called Norsk Data (when established: "Norsk Data-Elektronikk", "Norwegian Computer Electronics". The machines were named Nord-1, Nord-5 (the 32 bit ones), then Nord-10 and Nord-50. At the time of the story I told, they were ND-100 and ND-500. Later came an ND-5000, but I don't think there ever was any ND-1000. The fun thing about octal for the ND-100 is that it really didn't fit the instruction format at all: Most instructions was built from 4 fields, each 4 bits. In the same period, the MC68K was about to enter the market: With 8 registers, 8 addressing modes, always the low bits, only uppermost opcode field was of 4 bits. Yet binary MC68K instructions was always presented in hexadecimal format (unless, of course, the bit pattern was shown - which often was the case).
-
dandy72 wrote:
decided to take it upon himself to "write it in a weekend"
Hey, I heard of another CEO who wrote FAT on an airplane, for heaven's sake[^] :laugh:
Mircea
-
I think the opposite situation is even worse. You get some abstraction/interface monkey at the keyboard and you may find yourself jumping through a dozen different 5 line files to get to the actual code that adds X + Y. Tons and tons of code written to handle the unlikely event that your boss is going to walk into your office one day and say, "Hey, let switch from Oracle to SQL". I understand some vended products feel the need to support that, but they don't.
My rule-of-thumb for creating functions (/methods/procedures/...): If it represents another level of abstraction, then create it. If it doesn't, write it as inline code. It really is obvious. Yet, I often see code where the programmer obviously went "Ooops! Max line count reached! I'll have to put the lines above this point into a function, and create another function for the remaining lines." Functions representing nothing but some sequence of statements with no common purpose or meaning of life. Of course this is more prominent with junior programmers. But a fair share of programmers never grow up.
-
Around 10 years back, I joined my first company, where I was introduced to a codebase which was in Java/XML, kind of an Android Application. I saw files having 12k lines. It was a nightmare situation for me to even navigate the code and to follow up on a bug we were supposed to fix! As we progressed through the years, we found lower lines per file, saw IDE limiters on number of lines in a File(Max 1000), saw Coding Architectures like MVX(MVP, MVVM, MVI, etc.) asking us to break up code blocks into smaller more testable modules, saw Testing Tooling and other advice from many asking us to test a smallest unit. Overall, the experience is a very rewarding, at each step we learnt the mistake we did previously, made amends and then made some more mistakes :laugh: and then fixed them in the coming months.
-
I started to dive in a new (for me) very large code base. One of the files is 9500 lines. Got me wondering: what's the largest single source file you ever met? I'm not talking about automatically generated source files, but those written by humans. On the same note, when do you think it's time to break a file in smaller pieces? For me, it is somewhere around 1000 lines.
Mircea
I was tasked with "tidying up" a killer demo hacked up by a data scientist on our team during his holidays. After looking at the single 15k line Javascript file he produced, I suggested we rewrite the demo frontend from scratch since it was going to be difficult to work on (even though it looked really polished). That suggestion was shot down as unnecessary engineering, but when I looked closer it became clear that he'd "borrowed" a complete demo published by another company -- a single minified Javascript file -- and swapped out of a few pieces so it called his own prototype backend running on a laptop (that bit at least was entirely his own work). At that point I suggested this might be a good reason for us to proceed with the frontend rewrite, and that I wouldn't be comfortable putting my name on another company's pilfered and tweaked demo. The DS seemed relieved and immediately agreed. He was a good guy, but probably crumpling under delivery pressure from management, and he never really intended for an internal proof-of-concept to suddenly become a user-facing feature of the site, but by then it was hard to backpedal until I forced the issue.
-
I started to dive in a new (for me) very large code base. One of the files is 9500 lines. Got me wondering: what's the largest single source file you ever met? I'm not talking about automatically generated source files, but those written by humans. On the same note, when do you think it's time to break a file in smaller pieces? For me, it is somewhere around 1000 lines.
Mircea
12k lines in Program.cs for a console/batch processing application running at a government authority where I used to work. It was for validating and processing Financial Transactions (MiFID II) The original developer was on extended maternity leave+vacation (1.5 year). No one wanted to give maintenance to it (neither the original dev, when she came back 8 months after I was hired) because it was too unwieldy to do anything there. I was hired specifically to deal with it. Took around two months to have it on my mind to actually start breaking it down. Since no one was interested in working on the beast, I kinda grew fond of the project because it was important, and no one bothered/pressured me when I told them that improving things would take time. Also, I was free to perform any needed refactorings to the thing. I managed to improve its performance by several times first (to remove processing bottlenecks), and then started refactoring it, bit by bit. It was a pity I had to leave that project behind and go back to my home country. Since I was a contractor, and it was before the pandemic started, so people were not very fond of offering me to work remotely.
-
Here in Brazil sales taxes are Lovecraftian levels of nightmarish. We have a form in a shared Windows Forms library that we use in several of our "of the shelf" products that deals with invoicing and taxes of product sales that is 17K lines in and of itself, no counting helpers and specialized components and dialogs. Most of that code it to manage the interacion between the UI and the rules and calculations for taxes. You sometimes see people complaining about doing income tax declarations, they have no idea how it is like to sell a simple piece of candy in Brazil.
não é reddit, mas r/suddenlycaralho ! Que vai querer no print, meu bom companheiro Dev BR, sofredor com cálculo de IPI/PIS/COFINS?
-
I started to dive in a new (for me) very large code base. One of the files is 9500 lines. Got me wondering: what's the largest single source file you ever met? I'm not talking about automatically generated source files, but those written by humans. On the same note, when do you think it's time to break a file in smaller pieces? For me, it is somewhere around 1000 lines.
Mircea
Probably not a reasonable answer because this is from back in the mainframe days but I seem to recall the Unisys A-Series operating System MCP (yes we laughed when Tron came out) was a million - ish lines of code. And not assembly code, written in NEWP, an Algol loke language.
-
Slacker007 wrote:
If all the code is concise and organized well and has purpose
Which is almost never the case in a 9k lines file ;)
Best, Sander Azure DevOps Succinctly (free eBook) Azure Serverless Succinctly (free eBook) Migrating Apps to the Cloud with Azure arrgh.js - Bringing LINQ to JavaScript
Probably has five recursive functions buried in the middle of the file, which calls all of the other functions. Each recursion is controlled by a different combination of global variables defined and controlled in other units.
Our Forgotten Astronomy | Object Oriented Programming with C++ | Wordle solver
-
Slacker007 wrote:
If all the code is concise and organized well and has purpose
Which is almost never the case in a 9k lines file ;)
Best, Sander Azure DevOps Succinctly (free eBook) Azure Serverless Succinctly (free eBook) Migrating Apps to the Cloud with Azure arrgh.js - Bringing LINQ to JavaScript
-
A frightening large fraction of modern programmers believe that putting each method/function into its own individual file, headed by a 90 line open-source license statement, magically solves those problems.
Those guys are posers. I put every word in a separate file. I use a build script that concats all necessary files so it becomes a compilable script again. That way, I never write a single word twice, so it's completely DRY! Let the build server handle the complexities. Also, when a function is compiled it becomes its own service, because a service should do one thing only. Naturally, I'm using Kubernetes to deploy all my services. It's completely SOLID I tell you :D
Best, Sander Azure DevOps Succinctly (free eBook) Azure Serverless Succinctly (free eBook) Migrating Apps to the Cloud with Azure arrgh.js - Bringing LINQ to JavaScript
-
I started to dive in a new (for me) very large code base. One of the files is 9500 lines. Got me wondering: what's the largest single source file you ever met? I'm not talking about automatically generated source files, but those written by humans. On the same note, when do you think it's time to break a file in smaller pieces? For me, it is somewhere around 1000 lines.
Mircea
Mircea Neacsu wrote:
what's the largest single source file you ever met?
File? I found a C++ class which spanned 3 source files - at least. It had 20,000 lines of code and at least 200 attributes and 200 methods. Years later I read the book "AntiPatterns" in which it described the God Pattern. That is what that class was.
-
I think the opposite situation is even worse. You get some abstraction/interface monkey at the keyboard and you may find yourself jumping through a dozen different 5 line files to get to the actual code that adds X + Y. Tons and tons of code written to handle the unlikely event that your boss is going to walk into your office one day and say, "Hey, let switch from Oracle to SQL". I understand some vended products feel the need to support that, but they don't.
MadGerbil wrote:
"Hey, let switch from Oracle to SQL".
To be fair that actually happened to me. But from SQL Server to Oracle. It took me, by myself, a bit less than two weeks and had no impact at all on any other developer. Customer mandated it. The boss that just delivered the news was rather skeptical about what impact it would have. There was a very specific DB API although without a lot of layers. Contrast with the more recent job where the required change from SQL Server to MySQL is closing in on 2 years now. And still not done. That didn't have a DB API layer. It has a mismash of various idioms and misuses of various APIs over years.
-
One "Hacker's dictionary" listed "Cobol Fingers" as "Fingers worn down to a single joint". :-)