SlideShare a Scribd company logo
Architecture - Part I
Architecture
✦Up until now the UI was pure mockup, we’ll start
breaking it down into logical pieces by separating the
business from the UI
✦The first step is figuring out the different pieces
involved
✦The second step is integrating them into the code
✦Architecture is a process - we create an architecture
by need and refine it as we move forward
© Codename One 2017 all rights reserved
Menu
Order
Where do we Start?
✦I’ve discussed the Dish class the last time around so
lets start from that point…
© Codename One 2017 all rights reserved
Dish
Where do we get a Dish from?
✦A dish is a part of a menu which happens to match
out exact UI paradigm… But it’s also part of an order!
© Codename One 2017 all rights reserved
Dish
Menu Order
1 1
*
*
Where do we get a Dish from?
✦Where do we get those from? From the Restaurant…
© Codename One 2017 all rights reserved
Dish
Menu Order
Restaurant
1 1
*
*
1
1
1
1
public class Menu implements PropertyBusinessObject {
public final ListProperty<Dish, Menu> dishes = new ListProperty<>("dishes");
public final ListProperty<String, Menu> categories = new ListProperty<>("categories");
private final PropertyIndex idx = new PropertyIndex(this, "Menu",
dishes, categories);
@Override
public PropertyIndex getPropertyIndex() {
return idx;
}
}
Menu
public class Order implements PropertyBusinessObject {
public final Property<String, Order> id = new Property<>("id");
public final Property<Date, Order> date = new Property<>(“date”, Date.class);
public final BooleanProperty<Order> purchased = new BooleanProperty<>("purchased");
public final MapProperty<Dish, Integer, Order> dishesQuantity =
new MapProperty<>("dishesQuantity");
public final Property<String, Order> notes = new Property<>("notes");
private final PropertyIndex idx = new PropertyIndex(this, "Order",
id, date, purchased, dishesQuantity, notes);
@Override
public PropertyIndex getPropertyIndex() {
return idx;
}
}
Order
public class Restaurant implements PropertyBusinessObject {
public final Property<String, Restaurant> name = new Property<>("name");
public final Property<String, Restaurant> tagline = new Property<>("tagline");
public final Property<Image, Restaurant> logo = new Property<>("logo");
public final DoubleProperty<Restaurant> latitude = new DoubleProperty<>("latitude", 0.0);
public final DoubleProperty<Restaurant> longitude = new DoubleProperty<>("longitude", 0.0);
public final Property<String, Restaurant> navigationAddress =
new Property<>("navigationAddress");
public final Property<String, Restaurant> address = new Property<>("address");
public final Property<String, Restaurant> phone = new Property<>("phone");
public final Property<String, Restaurant> website = new Property<>("website");
public final Property<String, Restaurant> currency = new Property<>("currency");
public final Property<Menu, Restaurant> menu = new Property<>("menu", new Menu());
public final Property<Order, Restaurant> cart = new Property<>("order", new Order());
private final PropertyIndex idx = new PropertyIndex(this, "Restaurant",
name, tagline, logo, latitude, longitude, navigationAddress, address,
phone, website, currency, menu, cart);
@Override
public PropertyIndex getPropertyIndex() {
return idx;
}
Restaurant
private Restaurant(Properties p, Image img) {
name.set(p.getProperty(name.getName()));
tagline.set(p.getProperty(tagline.getName()));
latitude.set(Double.valueOf(p.getProperty(latitude.getName())));
longitude.set(Double.valueOf(p.getProperty(longitude.getName())));
navigationAddress.set(p.getProperty(navigationAddress.getName()));
address.set(p.getProperty(address.getName()));
phone.set(p.getProperty(phone.getName()));
website.set(p.getProperty(website.getName()));
currency.set(p.getProperty(currency.getName()));
logo.set(img);
// Default hardcoded values e.g. list of Dish's
menu.get().
categories.add("Entru00e9e").
categories.add("Mains").
categories.add("Deserts").
categories.add("Wines").
categories.add("Beverages");
Dish dsh = new Dish().name.set("My great dish").
description.set("Lorem ipsum dolor sit amet, consectetur adipiscing elit. "
+ "Maecenas pharetra leo quis sapien rutrum scelerisque. Aenean
Restaurant
private static Restaurant instance;
public static Restaurant getInstance() {
if(instance == null) {
try(InputStream io = Display.getInstance().
getResourceAsStream(Restaurant.class, "/settings.properties")) {
Properties p = new Properties();
p.load(io);
Image img = Image.createImage("/logo.png");
instance = new Restaurant(p, img);
} catch(IOException err) {
Log.e(err);
}
}
return instance;
}
public String formatCurrency(double value) {
return currency.get() + L10NManager.getInstance().format(value);
}
Restaurant

More Related Content

PDF
Architecture - Part 1 - Transcript.pdf
PDF
Smartwatch - something more than an additional screen for notifications?
PDF
Restaurant Server - Transcript.pdf
PDF
Restaurant Server.pdf
PDF
Architecture - Part 2 - Transcript.pdf
PDF
Building maintainable app #droidconzg
PDF
Angular2 workshop
PDF
React: JSX and Top Level API
Architecture - Part 1 - Transcript.pdf
Smartwatch - something more than an additional screen for notifications?
Restaurant Server - Transcript.pdf
Restaurant Server.pdf
Architecture - Part 2 - Transcript.pdf
Building maintainable app #droidconzg
Angular2 workshop
React: JSX and Top Level API

Similar to Architecture - Part 1.pdf (13)

PDF
Introduction toandroid
PDF
Miscellaneous Features - Part 1 - Transcript.pdf
PPT
Introduction to android
PDF
Finishing the App - Part 2.pdf
PDF
Building maintainable app
PDF
Acercándonos a la Programación Funcional a través de la Arquitectura Hexag...
PPTX
ProTips DroidCon Paris 2013
PPTX
Advanced REST API Scripting With AppDynamics
PDF
Firebase & SwiftUI Workshop
DOCX
Use of Classes and arrays#include iostreamusing namespace.docx
PDF
Android Design Patterns
PDF
XebiConFr 15 - Brace yourselves Angular 2 is coming
PPTX
Android dev toolbox
Introduction toandroid
Miscellaneous Features - Part 1 - Transcript.pdf
Introduction to android
Finishing the App - Part 2.pdf
Building maintainable app
Acercándonos a la Programación Funcional a través de la Arquitectura Hexag...
ProTips DroidCon Paris 2013
Advanced REST API Scripting With AppDynamics
Firebase & SwiftUI Workshop
Use of Classes and arrays#include iostreamusing namespace.docx
Android Design Patterns
XebiConFr 15 - Brace yourselves Angular 2 is coming
Android dev toolbox

More from ShaiAlmog1 (20)

PDF
The Duck Teaches Learn to debug from the masters. Local to production- kill ...
PDF
create-netflix-clone-06-client-ui.pdf
PDF
create-netflix-clone-01-introduction_transcript.pdf
PDF
create-netflix-clone-02-server_transcript.pdf
PDF
create-netflix-clone-04-server-continued_transcript.pdf
PDF
create-netflix-clone-01-introduction.pdf
PDF
create-netflix-clone-06-client-ui_transcript.pdf
PDF
create-netflix-clone-03-server.pdf
PDF
create-netflix-clone-04-server-continued.pdf
PDF
create-netflix-clone-05-client-model_transcript.pdf
PDF
create-netflix-clone-03-server_transcript.pdf
PDF
create-netflix-clone-02-server.pdf
PDF
create-netflix-clone-05-client-model.pdf
PDF
Creating a Whatsapp Clone - Part II.pdf
PDF
Creating a Whatsapp Clone - Part IX - Transcript.pdf
PDF
Creating a Whatsapp Clone - Part II - Transcript.pdf
PDF
Creating a Whatsapp Clone - Part V - Transcript.pdf
PDF
Creating a Whatsapp Clone - Part IV - Transcript.pdf
PDF
Creating a Whatsapp Clone - Part IV.pdf
PDF
Creating a Whatsapp Clone - Part I - Transcript.pdf
The Duck Teaches Learn to debug from the masters. Local to production- kill ...
create-netflix-clone-06-client-ui.pdf
create-netflix-clone-01-introduction_transcript.pdf
create-netflix-clone-02-server_transcript.pdf
create-netflix-clone-04-server-continued_transcript.pdf
create-netflix-clone-01-introduction.pdf
create-netflix-clone-06-client-ui_transcript.pdf
create-netflix-clone-03-server.pdf
create-netflix-clone-04-server-continued.pdf
create-netflix-clone-05-client-model_transcript.pdf
create-netflix-clone-03-server_transcript.pdf
create-netflix-clone-02-server.pdf
create-netflix-clone-05-client-model.pdf
Creating a Whatsapp Clone - Part II.pdf
Creating a Whatsapp Clone - Part IX - Transcript.pdf
Creating a Whatsapp Clone - Part II - Transcript.pdf
Creating a Whatsapp Clone - Part V - Transcript.pdf
Creating a Whatsapp Clone - Part IV - Transcript.pdf
Creating a Whatsapp Clone - Part IV.pdf
Creating a Whatsapp Clone - Part I - Transcript.pdf

Recently uploaded (20)

PDF
A comparative analysis of optical character recognition models for extracting...
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Machine learning based COVID-19 study performance prediction
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Approach and Philosophy of On baking technology
PPTX
Spectroscopy.pptx food analysis technology
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Network Security Unit 5.pdf for BCA BBA.
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Empathic Computing: Creating Shared Understanding
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
A Presentation on Artificial Intelligence
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
cuic standard and advanced reporting.pdf
PPT
Teaching material agriculture food technology
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
DOCX
The AUB Centre for AI in Media Proposal.docx
A comparative analysis of optical character recognition models for extracting...
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Machine learning based COVID-19 study performance prediction
Dropbox Q2 2025 Financial Results & Investor Presentation
Approach and Philosophy of On baking technology
Spectroscopy.pptx food analysis technology
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Network Security Unit 5.pdf for BCA BBA.
sap open course for s4hana steps from ECC to s4
Empathic Computing: Creating Shared Understanding
Unlocking AI with Model Context Protocol (MCP)
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Building Integrated photovoltaic BIPV_UPV.pdf
Reach Out and Touch Someone: Haptics and Empathic Computing
A Presentation on Artificial Intelligence
Assigned Numbers - 2025 - Bluetooth® Document
cuic standard and advanced reporting.pdf
Teaching material agriculture food technology
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
The AUB Centre for AI in Media Proposal.docx

Architecture - Part 1.pdf

  • 2. Architecture ✦Up until now the UI was pure mockup, we’ll start breaking it down into logical pieces by separating the business from the UI ✦The first step is figuring out the different pieces involved ✦The second step is integrating them into the code ✦Architecture is a process - we create an architecture by need and refine it as we move forward © Codename One 2017 all rights reserved
  • 3. Menu Order Where do we Start? ✦I’ve discussed the Dish class the last time around so lets start from that point… © Codename One 2017 all rights reserved Dish
  • 4. Where do we get a Dish from? ✦A dish is a part of a menu which happens to match out exact UI paradigm… But it’s also part of an order! © Codename One 2017 all rights reserved Dish Menu Order 1 1 * *
  • 5. Where do we get a Dish from? ✦Where do we get those from? From the Restaurant… © Codename One 2017 all rights reserved Dish Menu Order Restaurant 1 1 * * 1 1 1 1
  • 6. public class Menu implements PropertyBusinessObject { public final ListProperty<Dish, Menu> dishes = new ListProperty<>("dishes"); public final ListProperty<String, Menu> categories = new ListProperty<>("categories"); private final PropertyIndex idx = new PropertyIndex(this, "Menu", dishes, categories); @Override public PropertyIndex getPropertyIndex() { return idx; } } Menu
  • 7. public class Order implements PropertyBusinessObject { public final Property<String, Order> id = new Property<>("id"); public final Property<Date, Order> date = new Property<>(“date”, Date.class); public final BooleanProperty<Order> purchased = new BooleanProperty<>("purchased"); public final MapProperty<Dish, Integer, Order> dishesQuantity = new MapProperty<>("dishesQuantity"); public final Property<String, Order> notes = new Property<>("notes"); private final PropertyIndex idx = new PropertyIndex(this, "Order", id, date, purchased, dishesQuantity, notes); @Override public PropertyIndex getPropertyIndex() { return idx; } } Order
  • 8. public class Restaurant implements PropertyBusinessObject { public final Property<String, Restaurant> name = new Property<>("name"); public final Property<String, Restaurant> tagline = new Property<>("tagline"); public final Property<Image, Restaurant> logo = new Property<>("logo"); public final DoubleProperty<Restaurant> latitude = new DoubleProperty<>("latitude", 0.0); public final DoubleProperty<Restaurant> longitude = new DoubleProperty<>("longitude", 0.0); public final Property<String, Restaurant> navigationAddress = new Property<>("navigationAddress"); public final Property<String, Restaurant> address = new Property<>("address"); public final Property<String, Restaurant> phone = new Property<>("phone"); public final Property<String, Restaurant> website = new Property<>("website"); public final Property<String, Restaurant> currency = new Property<>("currency"); public final Property<Menu, Restaurant> menu = new Property<>("menu", new Menu()); public final Property<Order, Restaurant> cart = new Property<>("order", new Order()); private final PropertyIndex idx = new PropertyIndex(this, "Restaurant", name, tagline, logo, latitude, longitude, navigationAddress, address, phone, website, currency, menu, cart); @Override public PropertyIndex getPropertyIndex() { return idx; } Restaurant
  • 9. private Restaurant(Properties p, Image img) { name.set(p.getProperty(name.getName())); tagline.set(p.getProperty(tagline.getName())); latitude.set(Double.valueOf(p.getProperty(latitude.getName()))); longitude.set(Double.valueOf(p.getProperty(longitude.getName()))); navigationAddress.set(p.getProperty(navigationAddress.getName())); address.set(p.getProperty(address.getName())); phone.set(p.getProperty(phone.getName())); website.set(p.getProperty(website.getName())); currency.set(p.getProperty(currency.getName())); logo.set(img); // Default hardcoded values e.g. list of Dish's menu.get(). categories.add("Entru00e9e"). categories.add("Mains"). categories.add("Deserts"). categories.add("Wines"). categories.add("Beverages"); Dish dsh = new Dish().name.set("My great dish"). description.set("Lorem ipsum dolor sit amet, consectetur adipiscing elit. " + "Maecenas pharetra leo quis sapien rutrum scelerisque. Aenean Restaurant
  • 10. private static Restaurant instance; public static Restaurant getInstance() { if(instance == null) { try(InputStream io = Display.getInstance(). getResourceAsStream(Restaurant.class, "/settings.properties")) { Properties p = new Properties(); p.load(io); Image img = Image.createImage("/logo.png"); instance = new Restaurant(p, img); } catch(IOException err) { Log.e(err); } } return instance; } public String formatCurrency(double value) { return currency.get() + L10NManager.getInstance().format(value); } Restaurant