When you put related code together, you get to *choose* the order that people read the code, and you can optimize it for understanding. One Class Per File is ceding this order to what is effectively randomness, instead of Thoughtfulness
-
-
Prikaži ovu nitHvala. Twitter će to iskoristiti za poboljšanje vaše vremenske crte. PoništiPoništi
-
-
-
Not a great analogy: you don't read code from top to bottom, you mostly follow the call stack, sometimes skipping over a method because you don't need to read what's inside it. One-file-per-class has other advantages especially for understanding change-sets in PRs/code reviews.
-
PS I don't think either absolute (never or always) is the right answer on this question, but mostly one-per-file is a good starting point, especially for beginners.
- Još 4 druga odgovora
Novi razgovor -
-
-
You might, if it were a: Dictionary Encyclopedia Phone book Etc In which the start of the book is unlikely to be what someone opening it is actually seeking.
-
Good thing code is definitely Not That!
- Još 4 druga odgovora
Novi razgovor -
-
-
You wouldn't paint a canvas with your colors already mixed together, that would be confusing AF. Many-classes-per-file is doing exactly that, but for code. Don't do it! (There's no limit to what a wrong analogy can express!
) -
- Još 2 druga odgovora
Novi razgovor -
-
-
in a team, having more code in single file leads to merge conflicts where folks edit the file at the same time. Better split the code into individual units.
-
This is the only compelling counter-reason I've heard all day!
- Još 2 druga odgovora
Novi razgovor -
-
-
What if the language enforces that?
-
Then switch to Kotlin, for many good reasons!
Kraj razgovora
Novi razgovor -
Čini se da učitavanje traje već neko vrijeme.
Twitter je možda preopterećen ili ima kratkotrajnih poteškoća u radu. Pokušajte ponovno ili potražite dodatne informacije u odjeljku Status Twittera.