Skip to content

0.2 Release #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 42 commits into from
Sep 11, 2019
Merged

0.2 Release #16

merged 42 commits into from
Sep 11, 2019

Conversation

greenrobot
Copy link
Member

No description provided.

@greenrobot-team
Copy link
Member

Dumb question: the Flutter wiki (https://github.com/flutter/flutter/wiki/Desktop-shells) makes it sound like desktop support is, well, a dumpster fire. Why was the mobile app example replaced with a desktop example?

Copy link
Contributor

@vaind vaind left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is hard to review because everything shows as new.

Consider using git mv source target command in the future, if your IDE doesn't do it on your own (VSCode doesn't). It works with whole directories as well.

Please consider the package layout conventions I've posted and ping me for another review afterwards

3. Finally run `dart test/test.dart` to start the demo script.
Note that, as fairly recent language features are used, the minimal required Dart version is 2.2.2.
1. Install [objectbox-c](https://github.com/objectbox/objectbox-c) system-wide: `curl -s https://github.com/raw/objectbox/objectbox-c/master/download.sh > /tmp/download.sh && bash /tmp/download.sh 0.7 && rm /tmp/download.sh` (answer Y when it asks about installing to /usr/lib).
2. Back in this repository, run `pub get` in each of the following directories: `objectbox`, `objectbox_model_generator`, `objectbox_test`. If you just want to try out the tests, running it in `objectbox_test` is enough.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new branch doesn't follow conventions https://dart.dev/tools/pub/package-layout or rather it creates three packages.

What is the reason it must be split in such a way instead having a single package?

  • lib instead of objectbox
  • bin/binding-generator instead of objectbox_model_generator
  • test instead of objectbox_test

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this, I generally stuck to how Dart's json_serializable organizes its files. It uses source_gen as well (just like objectbox_model_generator), so it seemed like quite a good reference for some first orientation. Also, it subdivides the repository into three subprojects as well, each with its own pubspec.yaml: example (our objectbox_test), json_annotation (our objectbox) and json_serializable (our objectbox_model_generator).

Unfortunately, source_gen and build_runner are rather poorly documented for the use case of generating source code for annotations, so it's hard to find good resources on how to better organize the directory structure. Apart from that, I also think that the model generator needs to have its own Dart package in order for build.yaml to work properly.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Core packages are not always a best source of organization since they use to have long history, before most conventions even emerged.

The page I've linked (https://dart.dev/tools/pub/package-layout) is an official recommendation how a package should be structured and as such it would be strongly preferable to follow there are serious reasons we need to diverge. If you say building the generator is (I don't know enough of dart to help you there at the moment), then let's keep the generator as a separate project for now but at least leave the rest as a single one. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, I definitely agree; I'll also keep the generator as a separate package for now. Please check out my last commit, I reorganized the file structure similar to how you suggested.


@Entity(id: 1, uid: 1)
class Note {
@Id(id: 1, uid: 1001, type: Type.Long)
@Id(id: 1, uid: 1001) // automatically always 'int' in Dart code and 'Long' in ObjectBox
Copy link
Contributor

@vaind vaind Sep 10, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IDs should be uint64 (in objectbox), preferrable similar in the sample code as well

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean I should change the comment to "...and 'uint64' in ObjectBox"?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generated code should pass flags: unsigned & ID

Originally I also meant the entity class should use unsigned integer type but I've found out there's none in dart.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI: "int" in Dart is the closest type to ObjectBox IDs. The JS limitations are funny though, btw...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generated code should pass flags: unsigned & ID

PropertyFlags_ID (1) is enough; haven't seen PropertyFlags_UNSIGNED (8192) with IDs, better not try this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I haven't really seen PropertyFlags_UNSIGNED before either... Can this conversation be closed then?

""";

return ret;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe break this method up a little? I feel this getting too long.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to keep it like this for now; as the file is more or less linearly constructed, reading the code from top to bottom makes enough sense here. Of course this will need to change in upcoming versions of the binding, but currently, I'd say that splitting is not really necessary yet.

@greenrobot-team
Copy link
Member

Went through all commits (skipped dropped mobile example and the C library stuff I'm not familiar with), added comments. Great!

Looks like Ivan had a look as well. As I'm not around the rest of the week, I guess all follow-up questions go to him. 💃

@greenrobot
Copy link
Member Author

Why was the mobile app example replaced with a desktop example?

We don't have libs ready for mobile platforms yet (C API, not e.g. JNI)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants