Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Haxe NME UI: Best practices for MVC application design

yesterday I stumbled across the Haxe NME project, which is a very promising idea. However, it is still not possible to build sophisticated UIs with this framework. In my opinion it seems to be a intimidating task to build a UI framework that targets so many different platforms, hence I think that this isn't a viable approach, because even old and mature UI frameworks like Qt and wxWidgets don't support so many platforms.

However, it could make sense to build a platform specific UI with help of some pretty UI designer tool and then connect the UI code to the UI agnostic code that has been written in Haxe. I don't know if this could work, because I couldn't find any example, but maybe someone who has already written some MVC Haxe code, that could be successfully connected to different platform specific UIs, would like to share his experiences. Thanks.

like image 210
user1812379 Avatar asked Dec 16 '22 09:12

user1812379


1 Answers

You say:

However, it is still not possible to build sophisticated UIs

Just because you haven't yet figured out how to do it doesn't mean it's not possible ;)

The reason it is possible is that in the Haxe ecosystem, the language and compiler is extremely consistent cross platform, NME/OpenFL provides a fairly strong cross platform rendering environment (HTML 5 has some quirks, but the others seem fairly strong) and so anything you build on top of these is going to cover a lot of platforms out-of-the-box. It's about being fairly high level - letting the compiler and the libraries take care of the platform quirks.

In MVC, the UI stuff is usually the "View". For View / UI frameworks, check out these libraries:

  1. Stablex UI
    NME/OpenFL, Cross Platform. Draws components using NME API. This is the only one I've played with, but the demo works consistently on android, flash, html5, native linux. Pretty impressive.

  2. HaxeUI
    NME, Cross Platform. Again, draws components on the stage.

  3. Prime
    Drawn using Flash API. Not sure if it has been ported cross platform yet.
    See also Talk/Video from WWX conference and Slides

  4. Guise
    A really innovative way of being able to either draw the UI, or use native if available. Check out the blog post.

  5. Basis
    Another attempt at wrapping native components - has iOS and Android libraries so far. Pretty cool, but I haven't played with it yet.

For MVC, there are lots of options:

  1. PrimeVC, mentioned above.
  2. MMVC, based on the RobotLegs framework, but tailored for Haxe.
  3. Lots of small options BBMVC PureMVC etc

The advantage of the MVC frameworks is that they separate your views from your application data (model) and logic (controller). Try to spend some time familiarising yourself with one of the MVC frameworks, and you'll see how you can write your apps in a way where you could use one of these, and then any of the various view engines - either native or NME-rendered. It can be a fairly steep learning curve, but this is how you build apps that are easily portable between different UI frameworks, and easily testable so you know they will scale as the app grows in complexity.

like image 85
Jason O'Neil Avatar answered Jan 15 '23 09:01

Jason O'Neil