3 ms·
I have only seen Dart code in Flutter code bases, and my comment here might be the result of incomplete knowledge. However, from what I can see, Dart seems to r
by hannofcart 6y ago
I have only seen Dart code in Flutter code bases, and my comment here might be the result of incomplete knowledge. However, from what I can see, Dart seems to resemble the Java way of doing things a lot. Specifically, the over-use of is-a inheritance.
Just scrolling through the list of examples in the Flutter samples directory illustrates this point.
https://github.com/flutter/samples https://github.com/flutter/samples
Use of inheritance seems to be the canonical way of doing things in Flutter and it seems to permeate the code base, both in the use of core Flutter APIs as well as associated library ecosystem. I find them rather hard to read and reason about. It's easy to be a bit confused on encountering a function in an object that inherited the function from a superclass 3 levels up in the hierarchy.
To be clear, I completely recognize that it's unfair of me to attribute to Dart (the language) issues/patterns I see with a library/framework ecosystem (Flutter). But this is mitigated by the fact that Flutter is by far what the lion's share of Dart code is written for today. Please correct me if I'm wrong.
- jonathanaird 6y agoThe canonical way of doing things in Flutter is composition NOT inheritance. This is the whole point of Widgets. Inheritance is used in ways that generally make sense and don’t result in huge complex inheritance trees.
- hajile 6y agoDart has top-level, first-class functions that don't require wrapping everything in a class. It then proceeds to waste this by wrapping everything up into classes and hoping nobody will use inheritance.
- jonathanaird 6y agoWidgets are essentially data classes, simple wrappers for configuration information. They need to be classes because of the way the internals of the framework works. And no one is hoping you don’t use inheritance. The recommended style is very clear. You’re free to do things however you want but you have to take responsibility for doing things in a weird way.