D
D
devunion2018-05-20 19:27:01
Dart
devunion, 2018-05-20 19:27:01

How to properly package in Dart?

Good afternoon, I'm slowly learning Dart. I have experience in developing in Java, so I try to do it by analogy, but something confuses me. In general, the task is to make a DAO layer. I took this as a basis: www.oracle.com/technetwork/java/dataaccessobject-1...
I got the following package structure and required classes:
db/
+ sqlite
| +- SqLiteDaoFactory
+- AbstractDaoFactory AbstractDaoFactory
has a static method that returns the requested factory implementation:

static DaoFactory getDAOFactory(StorageType type) {
    switch (type) {
      case StorageType.SQLITE:
        return new SqliteDaoFactory();

      default:
        return null;
    }
  }

This gives us a circular dependency between the db/ and db/sqlite packages . Because SqliteDaoFactory inherits from AbstractDaoFactory . Something I don't really like. How to do it correctly in Dart? Putting everything in one package somehow does not really want to.
A couple of additions. An abstraction layer is needed because I plan to test different databases. Perhaps even use different implementations for different tasks. Well, I don’t like the code that I saw in Flutter articles. There, in general, all work with the database is dumped into one class.
Flutter is already somehow damn confusing compared to the same Swing, so I don’t want to get crap out of nowhere when working with the database.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question