Comments (3)
I doubt it creates circular dependency
For example, inferStmt
needs inferExpr
:
and inferExpr
needs inferStmt
for Block
expressions which can contain statements:
Perhaps this is a Picasso-like case, where the real mastery of javascript is to go back to the roots and develop like you've just started coding.
Haha, my take on this is that the disgust with large files comes from our habit of Object Oriented programing but in most other paradigms large modules are just fine.
Anders Hejlsberg who was the lead architect of C# and the core developer for TypeScript seems to code this way for the TypeScript compiler and he's definitely not a beginner in either language.
from poy.
Hi, I might consider this in the next refactoring, although this will introduce circular dependencies, for instance infer.expr.ts
<-> infer.stmt.ts
and infer.*.ts
<-> infer.ts
. This is not a huge deal in JS, but poy itself does not support it (like many other resolvers, like in OCaml/Rescript, etc..) so if I want to rewrite the compiler in poy, it will not be able to follow this structure.
benefits outweigh the useless private declaration imo
As you've seen, I don't really use OOP patterns, I used a class here just for the convenience of the dot notation, and one OOP concept is to avoid large methods but I don't really see the benefits of splitting this (not that large) file into multiple ones, maybe you could elaborate, if you want to find inferExpr
for instance, just CTRL+SHIFT+P + @inferExpr inside infer.ts
and you're there, not much worse than going to the infer.expr.ts
file. You must not be a huge fan of some typescript files then ^^ https://github.com/microsoft/TypeScript/blob/main/src/compiler/checker.ts
from poy.
Oh god, I thought those big files were auto-generated. Thanks for showing me that, I hate it 😅
I've seen this quite often, putting all code into one single large file. Perhaps this is a Picasso-like case, where the real mastery of javascript is to go back to the roots and develop like you've just started coding.
I tried getting used to outline, then bookmarks (through an extension), none of which felt cleaner than separating it in different files. I do use command palette to navigate, just not with outline symbols. The separation of logic into files keeps the import dependencies "light" (only useful for bundled browser apps with chunk splitting) and git changes clearer & less entangled in my view. My personal approach to structuring files is by frequency, and moving some common functions outside the class (without impacting their logic or behavior) helps me keep a more tidy mental model of the code, especially when re-visiting the code after few months.
I doubt it creates circular dependency, it's more of a workaround to the lack of partial classes, the least ugly workaround. Functions are "injected" (or I guess you could say prototype is extended with these functions), and they're only used through the class itself with this.myFunc
. I guess you could import the function directly by accident but it would show a warning due to this
binding requirement.
You're definitely right, it's a personal workflow thing, highly doubt it will be a problem if written in poy itself.
Perhaps I simply live in fear that my code may become like my very first successful game, which was a nightmarish undocumented single 10MB file. Source code so dense, it became a historical artifact that even to this day I don't dare to revisit.
Partials in C# were such a godsend and I can only wish they existed in TS.
from poy.
Related Issues (2)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from poy.