Comments (1)
As I read it, you're asking for libraries to have a global namespace, where each library has a unique name.
And there is no suggestion for how to map from library name to actual library location. That's the biggest issue.
In main.dart
you didn't write an import
, so I assume referring to Product
automatically imports the Product
library.
I'll assume that only works within the same package, because a global cross-package namespace for libraries is not going to work. Or scale. Referring to libraries by a single-identifier name is too restrictive, if it means there can't be two libraries with the same name in the same program, even if they are from different packages.
Implicit imports makes dependency control harder. You can't easily see which libraries a library depends on, and you can easily add an undesired dependency simply by writing the wrong name in the wrong file.
Or if it assumes that all libraries are just available to all other libraries, it makes modular compilation impossible. Explicit dependency control makes it possible to control the sizes of mutually dependent library clusters, which is the unit of modular compilation.
immediately clarifies which library a part belongs to
I'd say it doesn't. It specifies a name, but if names are not globally unique (they aren't) then it doesn't actually say much.
You can give your library a name today by importing it with a prefix:
import "package:my_package/product.dart" as Product; // ignore: ... something ...
The URI uniquely and globally defines the library.
- Lack of Clarity: Using URI or relative directories for
part of
is not as descriptive as using the library name. It makes it difficult to quickly understand the relationship between different.dart
files.
I disagree. Using the library URI is very descriptive because it uniquely defines the library and its relation to the project. The URI includes the path-position in the the larger project, which is presumably chosen to be in accordance with whatever architectural pattern you use to manage the project.
- Difficulty in Management: Tracking and managing file relationships using URI or relative paths in large projects can be cumbersome. This is particularly problematic in architectural patterns emphasizing modularity and clear separation of concerns.
Relative paths can be annoying to update if you move files. Luckily the IDE will do that for you.
Relative paths are also signals of the relation between the files and the file it relates to.
And for part files and their part of
, only that author of the library needs to look at that, and they should know which file is the library file, and which are part files. If you choose to name them project.dart
and project_subfeature_part.dart
, project_substructure_part.dart
, etc., then it's pretty clear what they are. If you put all parts inside a project_parts/
sub-directory, that's also fine. You get to define the path structure, something you can't do with a flat namespace.
If anything, using URIs gives you more tools for managing and controlling the architecture of the project.
A practical reason for part of "path_to/library.dart";
is that any Dart tool pointed to the part file can find the parent file.
If it just said part of Project;
, you'd have to scan the entire package to find a library Project;
. (And hope you only find one.)
For the benefits;
- Improved Readability: The new syntax immediately clarifies which library a part belongs to, improving code readability and maintainability.
Here, unsurprisingly, I disagree again. A library is identified by its URI, nothing clarifies which library is being referred better than that URI.
- Better Project Organization: Helps organize and manage large projects by making the relationships between files more explicit and easier to follow.
Don't see how. If anything, it removes the information about relationship between files.
Reduced Redundancy: Eliminates the need for redundant naming conventions and shorten class names, such as:
ProductCatalogPage
toProduct::CatalogPage
ProductDetailsPage
toProduct::DetailsPage
ShopCatalogPage
toShop::CatalogPage
ShopDetailsPage
toShop::DetailsPage
That can be done today with import prefixes. You have to name the prefix where you import it, not where the library is declared, but that's also how it avoids name clashes.
I'm not seeing a concrete problem that this is solving. Can you elaborate on what concrete problems you've had with tracking and managing file relationships in large projects?
from language.
Related Issues (20)
- could support static extension? HOT 2
- Macro - Augment class with generic HOT 7
- Macro annotation information in yaml files next steps HOT 3
- Network paths don't work anymore with version 3.4.0 HOT 2
- "Merge to source" for macros that only need Phase 3 HOT 26
- Follow up on "spawn isolate from kernel blob" implementation
- Allow pattern `case` conditions in `while` statements. HOT 2
- Unable to call super method on an object. HOT 4
- Add syntactic sugar for package imports HOT 2
- Allow recursive extension type HOT 1
- Sub-package auto-export HOT 17
- Specification update failed after language repo commit HOT 3
- Augmenting external declarations, and external augmentations HOT 2
- Augmenting untyped values with initializers of different type. HOT 4
- Augmentations allowing static and instance members with the same name. HOT 7
- Strategy for launching augmentations HOT 3
- mixins with implicit call HOT 3
- Macros build restrictions HOT 1
- Macros file access HOT 5
- References to the initializing expression of an augmented declaration? HOT 1
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 language.