What takes time in development?
What shouldn't take time with MWF?
A number of elements from the outset
But there were a couple obvious lapses
MWF 1.3 added APIs for both of these
<div class="message alert">Alert message</div>
<div class="message confirm">Confirm message</div>
<div class="message error">Error message</div>
<div class="message info">Info message</div>
<form action="#">
<h2>Example Form</h2>
<label>Label for Input</label>
<input name="t-1" type="text">
<label>Label for Checkbox Group</label>
<div class="option">
<label><input name="c-1" value="1" type="checkbox">One</label>
<label><input name="c-2" value="2" type="checkbox">Two</label>
</div>
<input value="Submit" class="primary" type="submit">
</form>
Why have classes like...
<div class="menu-full menu-padded menu-detailed">
New "lean CSS" style
<div class="menu detailed">
What about backwards compatibility?
<link rel="stylesheet" href="/assets/css.php?lean">
An object-oriented approach to UI elements
$decorator = Site_Decorator::menu();
$decorator->set_title('Menu Title');
$decorator->add_item('Item 1', '#1');
$decorator->add_item('Item 2', '#2');
echo $decorator->render();
<div class="menu">
<h1>Menu Title</h1>
<ul>
<li><a href="#1">Item 1</a></li>
<li><a href="#1">Item 2</a></li>
</ul>
</div>
MWF Core includes a set of PHP decorators
But what about outside of MWF Core?
A library to render a UI element
Object-oriented languages lend themselves to this
PHP decorators can be used as reference
$decorator = Site_Decorator::menu();
$decorator->set_title('Menu Title');
$decorator->add_item('Item 1', '#1');
$decorator->add_item('Item 2', '#2');
var menu = mwf.decorator.Menu('Menu Title');
menu.addMenuLinkItem('Item 1', '#1');
menu.addMenuLinkItem('Item 2', '#2');
A decorator may use multiple decorators
The line begins to blur... we're getting close to MVC views
Common paradigm in modern frameworks
Clear separation of application logic:
<?php
class Menu_Controller extends Application_Controller {
public function main(){
$view = new View('menu');
$view->title = 'Menu Title';
$view->items = Menu_Model::all();
}
}
<div class="menu">
<h1><?php echo $title; ?></h1>
<ul>
<?php foreach($items as $item){ ?>
<li><a href="<?php echo $item->url ?>"><?php echo $item->name ?></a></li>
<?php } ?>
</ul>
</div>
class MenuController < ApplicationController
def main
@title = "Menu Title"
@items = Menu.all
end
end
<div class="menu">
<h1><%= @title %></h1>
<ul>
<% @items.each do |item| %>
<li><a href="<%= item.url %>"><%= item.name %></a></li>
<% end %>
</ul>
</div>
First and foremost, good software engineering
For MWF, segregate views from business logic
Minimize effort to build mobile & desktop sites
Service Provider
Service Consumer
Service Definition
A number of benefits including:
Great for building multiple versions of an app
Business logic and data models in a service provider
MWF-based mobile application becomes a consumer
Allows for consumers in other media
A few considerations for MWF-based consumer:
<a href="example.php" class="button preload">Example</a>
if(mwf.classification.isStandard()){
$(document).ready(function(){
$('.preload').each(function(){
var page = $(this).attr('href');
getData(page);
});
});
$('.preload').click(function(e){
e.preventDefault();
displayData($(this).attr('href'));
});
}
MWF removed the need to make device-specific apps
Design patterns for deploying mobile & desktop apps
... but isn't that still a bit too much work?
Responsive design is the next frontier
But still some niches where MWF is needed