Polymer Dart Strong Mode and Mixins is forcing weird code designs -


we started use dart's strong mode our polymer dart code , looks terrible. looks terrible need second opinion on matter. cant ugly looking, cant.

so creating bunch of polymerdart views using mix ins generic code. generic code reused everywhere hence why made mixin.

our old design:

abstract class mymodel{ ... } class submodel extends mymodel jsproxy{ ... }   @behavior abstract class mybehavior implements polymerbase {   @property(notify:true)   mymodel model = null;   // .... }  @polymerregister("my-component") class myviewmodel extends polymerelement mybehavior {   @property(notify:true)   submodel model = null; // ... } 

the purpose have generic model represent information , leverage in behavior. since submodel extends it, can slot anywhere , behavior work. colleague says huge no , confused why. said polymer issue, when leave polymer able done sort of.

he pushed through code base refactor works.

@polymerregister("my-component") class myviewmodel extends polymerelement mybehavior {   @property(notify:true)   mymodel model = null;  // <-- changed parent type behavior    //example reference   void test(){     int id = (model submodel).id;  // <-- using explain is.   } } 

now put everywhere, updated references of model.id (model submodel).id. think ugly , plain wrong. (granted feeling polymerdart).

is how kind of thing done when dealing mixins? since mixin has definition, shouldn't need in myviewmodel code either.

can explain me why right thing according strong mode? why must change occur? while trust in colleague, seem off , deeper understanding. believe, correct maybe because entirely due polymer dart, maybe there way circumventing property renames, , using (.. whatever) everywhere.

analysis_options.yaml:

analyzer:   strong-mode: true 

edit: reasoning since model defined property in behavior, non-mutable. cant override type in myviewmodel class. since submodel extends mymodel, should allowed exist.


Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -