Lime seems to support a
-noconstructor flag, but I don’t see it documented.
Is this a Flag a Haxe thing or just and OpenFL/Lime concept?
I ask because I am trying to create my Haxe/OpenFL best practices list. From my AS3 days I prefer having NO constructors if possible in my code. I can achieve this is the ‘-noconstructor’ flag; however, MUnit complains about not having constructors in tests and I have not found a way to have it ignore the issue. So, it’s looking like I need to have empty constructors in all my classes and test for them to be consistent.
Does this style guide rule seem correct?
I don’t understand why you’d want to avoid constructors. Do you just want to avoid typing it out in the case of an empty constructor?
There are three reason I tend avoided constructors.
- In AS3 constructors performed poorly because the code was never compile to machine code by the JIT compiler. So it was always better to put your code in public methods like init().
- For mobile apps and embedded systems where object creating is costly it’s good to avoid any CPU spikes when creating objects.
- Have no logic in a constructor can make classes easier to put classes under test.
I have never heard of
-noconstructor, is this an undocumented Haxe feature?
Ugg. I can’t reproduce this at all, I must have had a false positive. Sorry for the confusion.
I did a test and Haxe does not seem to support that flag, and I tried to repro my claim that the flag worked with Lime, but it does not work. I wonder how I tricked myself into thinking it worked.
Deleting this thread might be best.