Development Models

MoSync supports several application development models. We call them the "classic procedural", "event driven, object oriented" and "full GUI-based". The model that you should choose when developing an application depends both on the type of application you are developing and your personal preference.

The Classic Procedural Model

Using the classic procedural approach means starting out with an empty main function and implementing your own main loop, including all the event handling. Examples...

Advantages Disadvantages When to use
  • Offers full control of the program flow
  • Provides ultimate flexibility in the design of the application
  • Supports programming in pure C, without C++
  • Resembles popular, procedural frameworks
  • All the burden of constructing well-behaved, resource efficient applications is on the programmer
  • Sometimes requires the programmer to reinvent the wheel
  • Might be unintuitive to people with a OOP background
  • Your application requires full control of the program flow and events
  • You want to implement your own higher-level layer on top
  • You prefer C over C++
  • You're porting existing code to MoSync

The Event-Driven, Object-Oriented Model

This approach is embodied in the use of the MAUtil::Moblet class. Inheriting it lets you implement functions such as keyPressEvent() instead of explicitly implementing an event loop yourself while providing TimerListeners and IdleListeners to facilitate execution of code outside of responding to events. Examples...

Advantages Disadvantages When to use
  • Takes care of boilerplate event handling correctly
  • Provides higher-level abstraction of program flow
  • Produces well-behaved, resource efficient programs by default
  • Resembles popular, event driven frameworks
  • Imposes a predefined application lifecycle model
  • Might be awkward for frame-based applications such as games
  • Requires use of C++
  • Most of the time when the GUI-based approach below is overkill

The Full GUI-Based Model

Using the MAUI library, you gain access to a variety of ready-made widgets such as labels, list boxes, text edit boxes, images, and layouts. You add logic by registering different types of listeners with the widgets, thus responding to higher-level events than with Moblets - things like selection and slider position changes. Examples...

Advantages Disadvantages When to use
  • Allows rapid development of GUI applications
  • Reduces program flow programming to responding to GUI events
  • Imposes a predefined UI model
  • Requries familiarity with the MAUI library
  • Requires use of C++
  • Whenever you're developing a reasonably traditional GUI application
  • When radically cutting development time outweighs full customizability


Share on Facebook