SlideShare une entreprise Scribd logo
1  sur  16
Cross-Platform 
Software Design 
Michael Henson 
Professor 
College of Engineering and Information Sciences 
mhenson@devry.edu 
/arachnojava 
@arachnojava 
+MichaelHenson /michaeljhenson 
Arachnojava mhframework.blogspot.com
The Problems 
• Professional developers need to: 
– Reach the maximum number of customers. 
– Keep current with new computing devices. 
• Students need to: 
– Quickly adapt to the technologies that will grab 
the attention of potential employers. 
– Increase the probability that a potential employer 
will be able to evaluate their work. 
• Wouldn’t it be nice if we could develop 
just one product and make it available 
for a variety of computing devices? 
– PC, tablet, smart phone, game console, etc.
One Possible Solution 
1. Identify parts that are same across platforms. 
– We’ll call this the core functionality. 
2. Encapsulate the parts that differ. 
– We’ll call this the platform layer. 
3. Create an interface to the platform layer that can 
be repeated for all supported platforms. 
4. Make sure the core only talks to the platform 
layer interface and not the actual platform. 
– Then we can swap platforms and the core never 
needs to know!
A Bird’s-Eye 
View of the 
Idea
Proof of Concept: Snow vs. Man 
• Very early prototype built with 
MHFramework game engine which 
implements this design. 
• Play it on my laptop, tablet, or phone. 
• Objective: Prevent the evil snowmen 
from extinguishing your campfire. 
• How to Play: Click (tap) on open spaces 
to place defensive turrets.
Systems That Can 
(or Will) Run My Game 
Android 
Phone 
Android 
Tablet 
OUYA Game 
Console 
M.O.J.O. Game 
Console 
Linux 
Mac OS 
Windows
So…How Does It Work? 
1. The main program runs in a platform-specific 
context. 
– For instance, an Activity on Android or a JFrame 
on Windows. 
2. The program requests the appropriate 
platform layer depending on the context. 
3. All calls to the platform go through a 
common interface that handles 
communication with whatever platform lies 
beneath.
Main Program Code 
Notice the major similarities (and minor differences) between 
the PC and Android launchers for Snow vs. Man. 
PC Version 
public static void main(String[] args) 
{ 
// Create the game's start screen. 
MHScreen startingScreen = new SVMMainMenuScreen(); 
// Configure video settings. 
MHVideoSettings displaySettings = new MHVideoSettings(); 
displaySettings.windowCaption = "Snow Vs. Man"; 
displaySettings.displayWidth = 800; 
displaySettings.displayHeight = 480; 
// Launch the game. 
MHPCPlatform.run(new JFrame(), 
startingScreen, displaySettings); 
} 
Android Version 
protected void onCreate(Bundle savedInstanceState) 
{ 
// Initialize the Android activity. 
super.onCreate(savedInstanceState); 
// Create the game's start screen. 
MHScreen startingScreen = new SVMMainMenuScreen(); 
// Configure video settings. 
MHVideoSettings displaySettings = new MHVideoSettings(); 
displaySettings.windowCaption = "Snow Vs. Man"; 
displaySettings.displayWidth = 800; 
displaySettings.displayHeight = 480; 
// Launch the game. 
MHAndroidPlatform.run(this, 
startingScreen, displaySettings); 
}
A Common Interface For All 
Platforms 
Since every platform interface will have these same 
functions, the game can call them without caring which 
platform is performing the tasks behind the scenes. 
public interface MHPlatformFactory 
{ 
public MHBitmapImage createImage(int width, int height); 
public MHBitmapImage createImage(String filename); 
public MHColor createColor(int r, int g, int b, int a); 
public MHSoundManager getSoundManager(); 
public MHFont createFont(String fontName); 
public MHKeyCodes getKeyCodes(); 
public String getAssetsDirectory(); 
public MHTextFile openTextFile(String filename, Mode mode); 
}
The Technical Stuff 
for Nerds
The Guiding Object-Oriented 
Design Principles 
• Separate the aspects that vary from the aspects that stay 
the same. 
– The platform varies while the game code stays the same. 
• Strive for loosely coupled designs between objects that 
interact. 
– The common interface makes it easy to swap one platform for 
another without affecting the game code. 
• The Principle of Least Knowledge: “Talk only to your 
immediate friends.” 
– Minimizes places where game depends on platform. 
• The Hollywood Principle: “Don’t call us, we’ll call you.” 
– The platform serves the game, never vice versa.
The Design Patterns That 
Make This Possible 
• Façade Pattern 
– Makes the platform easier to use by hiding its complexity. 
• Strategy Pattern 
– The game engine only supports elements of the platform 
on which it is running. Few wasted resources, no 
extraneous conditional logic. 
• Singleton Pattern 
– Ensures single platform layer and provides access to it. 
• Template Method Pattern 
– Allows for the possibility that some functions may be the 
same across platforms while others may differ.
• Adapter Pattern 
– Each platform may have different ways of handling 
graphics, input, audio, etc. Adapter makes them all 
look the same from the game’s point of view. 
• Observer Pattern 
– Allows input handlers to use a generic set of events 
independent of those generated by the platforms. 
• Abstract Factory Pattern 
– Handles the details of creating the correct objects 
(graphics, sounds, etc.) for each platform.
Drawbacks To This Approach 
• Platform-specific advantages may be lost. 
– Example: A mouse cannot multi-touch, while touch 
screens cannot right-click. 
• The extra level of abstraction may degrade 
runtime performance. 
• The platform layer adds unavoidable 
complexity to the software architecture. 
Software development involves trade-offs at every step. We 
must always consider the pros and cons of any solution.
References 
Freeman, E. (2004). Head First design patterns. Sebastopol, CA: 
O'Reilly. 
Gamma, E. (1995). Design patterns: elements of reusable object-oriented 
software. Reading, Mass.: Addison-Wesley. 
Gregory, J. (2009). Game engine architecture. Wellesley, Mass.: A K 
Peters. 
Henson, M. (2013, July 24). Class structure of the platform layer. 
Retrieved June 20, 2014, from 
http://mhframework.blogspot.com/2013/07/class-structure-of-platform- 
layer.html 
Pressman, R. S. (2010). Software engineering: a practitioner's 
approach (7th ed.). Boston, Mass.: McGraw-Hill.

Contenu connexe

Tendances

BHyVeってなんや
BHyVeってなんやBHyVeってなんや
BHyVeってなんや
Takuya ASADA
 

Tendances (20)

Pub/Sub Temelleri, RabbitMQ ve Apache Kafka
Pub/Sub Temelleri, RabbitMQ ve Apache KafkaPub/Sub Temelleri, RabbitMQ ve Apache Kafka
Pub/Sub Temelleri, RabbitMQ ve Apache Kafka
 
BHyVeってなんや
BHyVeってなんやBHyVeってなんや
BHyVeってなんや
 
Gstreamer Basics
Gstreamer BasicsGstreamer Basics
Gstreamer Basics
 
Linux Kernel Init Process
Linux Kernel Init ProcessLinux Kernel Init Process
Linux Kernel Init Process
 
業務系SEの今後について
業務系SEの今後について業務系SEの今後について
業務系SEの今後について
 
Réseaux sociaux et destination touristique
Réseaux sociaux et destination touristiqueRéseaux sociaux et destination touristique
Réseaux sociaux et destination touristique
 
Introduction to Embedded System
Introduction to Embedded SystemIntroduction to Embedded System
Introduction to Embedded System
 
Gstreamer internals
Gstreamer internalsGstreamer internals
Gstreamer internals
 
DPDK QoS
DPDK QoSDPDK QoS
DPDK QoS
 
Introduction to Apache Kafka
Introduction to Apache KafkaIntroduction to Apache Kafka
Introduction to Apache Kafka
 
Matching the Scale at Tinder with Kafka
Matching the Scale at Tinder with Kafka Matching the Scale at Tinder with Kafka
Matching the Scale at Tinder with Kafka
 
NAT64 and DNS64 in 30 minutes
NAT64 and DNS64 in 30 minutesNAT64 and DNS64 in 30 minutes
NAT64 and DNS64 in 30 minutes
 
Adaptative streaming : enjeux, panorama, principes et difficultés
Adaptative streaming : enjeux, panorama, principes et difficultésAdaptative streaming : enjeux, panorama, principes et difficultés
Adaptative streaming : enjeux, panorama, principes et difficultés
 
Co créativité
Co créativitéCo créativité
Co créativité
 
CNTUG x SDN Meetup #33 Talk 1: 從 Cilium 認識 cgroup ebpf - Ruian
CNTUG x SDN Meetup #33  Talk 1: 從 Cilium 認識 cgroup ebpf - RuianCNTUG x SDN Meetup #33  Talk 1: 從 Cilium 認識 cgroup ebpf - Ruian
CNTUG x SDN Meetup #33 Talk 1: 從 Cilium 認識 cgroup ebpf - Ruian
 
jqで極めるシェル芸の話
jqで極めるシェル芸の話jqで極めるシェル芸の話
jqで極めるシェル芸の話
 
Kpi et outils de tracking + Best Practices Landing Pages
Kpi et outils de tracking + Best Practices Landing PagesKpi et outils de tracking + Best Practices Landing Pages
Kpi et outils de tracking + Best Practices Landing Pages
 
Running Kafka as a Native Binary Using GraalVM with Ozan Günalp
Running Kafka as a Native Binary Using GraalVM with Ozan GünalpRunning Kafka as a Native Binary Using GraalVM with Ozan Günalp
Running Kafka as a Native Binary Using GraalVM with Ozan Günalp
 
Kafka tiered-storage-meetup-2022-final-presented
Kafka tiered-storage-meetup-2022-final-presentedKafka tiered-storage-meetup-2022-final-presented
Kafka tiered-storage-meetup-2022-final-presented
 
DPDK In Depth
DPDK In DepthDPDK In Depth
DPDK In Depth
 

En vedette

Climate change
Climate changeClimate change
Climate change
figgie11
 

En vedette (10)

Kerala-God's Own Country
Kerala-God's Own CountryKerala-God's Own Country
Kerala-God's Own Country
 
Urban Health and Resilience in the Lagos Metropolis ( A Presentation By Ebele...
Urban Health and Resilience in the Lagos Metropolis ( A Presentation By Ebele...Urban Health and Resilience in the Lagos Metropolis ( A Presentation By Ebele...
Urban Health and Resilience in the Lagos Metropolis ( A Presentation By Ebele...
 
Pengenalan dbase IV
Pengenalan dbase IVPengenalan dbase IV
Pengenalan dbase IV
 
DEVNET-1129 WAN Automation Engine - Develop Traffic Aware Applications Using ...
DEVNET-1129	WAN Automation Engine - Develop Traffic Aware Applications Using ...DEVNET-1129	WAN Automation Engine - Develop Traffic Aware Applications Using ...
DEVNET-1129 WAN Automation Engine - Develop Traffic Aware Applications Using ...
 
Climate change
Climate changeClimate change
Climate change
 
Fullah sugah collection aw 2015 bags
Fullah sugah collection aw 2015 bagsFullah sugah collection aw 2015 bags
Fullah sugah collection aw 2015 bags
 
DEVNET-1164 Using OpenDaylight for Notification Driven Workflows
DEVNET-1164	Using OpenDaylight for Notification Driven WorkflowsDEVNET-1164	Using OpenDaylight for Notification Driven Workflows
DEVNET-1164 Using OpenDaylight for Notification Driven Workflows
 
Perangkat Lunak
Perangkat LunakPerangkat Lunak
Perangkat Lunak
 
DEVNET-1147 Energizing Your Career with Cloud Technologies
DEVNET-1147	Energizing Your Career with Cloud TechnologiesDEVNET-1147	Energizing Your Career with Cloud Technologies
DEVNET-1147 Energizing Your Career with Cloud Technologies
 
Creating and managing a non-profit ( A Presentation By Ebele Mogo, DrPH)
Creating and managing a non-profit ( A Presentation By Ebele Mogo, DrPH)Creating and managing a non-profit ( A Presentation By Ebele Mogo, DrPH)
Creating and managing a non-profit ( A Presentation By Ebele Mogo, DrPH)
 

Similaire à Cross-Platform Software Design

Game programming workshop
Game programming workshopGame programming workshop
Game programming workshop
narigadu
 
Mdc2010 Casual Game Dev
Mdc2010 Casual Game DevMdc2010 Casual Game Dev
Mdc2010 Casual Game Dev
momobangalore
 
Btec assignment-brief unit-20 assignment 2
Btec assignment-brief unit-20 assignment 2Btec assignment-brief unit-20 assignment 2
Btec assignment-brief unit-20 assignment 2
thomasmcd6
 
Assignment instructions
Assignment instructionsAssignment instructions
Assignment instructions
wallinplanet
 
Distributed load testing (Local vs Cloud)
Distributed load testing (Local vs Cloud)Distributed load testing (Local vs Cloud)
Distributed load testing (Local vs Cloud)
TestCampRO
 
Project Report Tron Legacy
Project Report Tron LegacyProject Report Tron Legacy
Project Report Tron Legacy
Manpreet Singh
 

Similaire à Cross-Platform Software Design (20)

Introduction to Game Engine: Concepts & Components
Introduction to Game Engine: Concepts & ComponentsIntroduction to Game Engine: Concepts & Components
Introduction to Game Engine: Concepts & Components
 
Delta Engine @ CeBit 2011
Delta Engine @ CeBit 2011Delta Engine @ CeBit 2011
Delta Engine @ CeBit 2011
 
Operating Systems
Operating SystemsOperating Systems
Operating Systems
 
Creating Casual Games for Windows 8
Creating Casual Games for Windows 8Creating Casual Games for Windows 8
Creating Casual Games for Windows 8
 
Game programming workshop
Game programming workshopGame programming workshop
Game programming workshop
 
Mdc2010 Casual Game Dev
Mdc2010 Casual Game DevMdc2010 Casual Game Dev
Mdc2010 Casual Game Dev
 
Creating Multiscreen Apps using Adobe Flash Platform
Creating Multiscreen Apps using Adobe Flash PlatformCreating Multiscreen Apps using Adobe Flash Platform
Creating Multiscreen Apps using Adobe Flash Platform
 
Btec assignment-brief unit-20 assignment 2
Btec assignment-brief unit-20 assignment 2Btec assignment-brief unit-20 assignment 2
Btec assignment-brief unit-20 assignment 2
 
Introduction to html5 game programming with impact js
Introduction to html5 game programming with impact jsIntroduction to html5 game programming with impact js
Introduction to html5 game programming with impact js
 
Presentación Unity
Presentación UnityPresentación Unity
Presentación Unity
 
Assignment instructions
Assignment instructionsAssignment instructions
Assignment instructions
 
Distributed load testing (Local vs Cloud)
Distributed load testing (Local vs Cloud)Distributed load testing (Local vs Cloud)
Distributed load testing (Local vs Cloud)
 
1-Introduction (Game Design and Development)
1-Introduction (Game Design and Development)1-Introduction (Game Design and Development)
1-Introduction (Game Design and Development)
 
Casual Engines 2009
Casual Engines 2009Casual Engines 2009
Casual Engines 2009
 
HTML5 Game Development frameworks overview
HTML5 Game Development frameworks overviewHTML5 Game Development frameworks overview
HTML5 Game Development frameworks overview
 
Cross Platform Game Programming with Cocos2d-js
Cross Platform Game Programming with Cocos2d-jsCross Platform Game Programming with Cocos2d-js
Cross Platform Game Programming with Cocos2d-js
 
Week Four - Operating Systems
Week Four - Operating SystemsWeek Four - Operating Systems
Week Four - Operating Systems
 
Game design & development
Game design & developmentGame design & development
Game design & development
 
Less code More fun
Less code More funLess code More fun
Less code More fun
 
Project Report Tron Legacy
Project Report Tron LegacyProject Report Tron Legacy
Project Report Tron Legacy
 

Dernier

AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
VishalKumarJha10
 

Dernier (20)

Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 

Cross-Platform Software Design

  • 1. Cross-Platform Software Design Michael Henson Professor College of Engineering and Information Sciences mhenson@devry.edu /arachnojava @arachnojava +MichaelHenson /michaeljhenson Arachnojava mhframework.blogspot.com
  • 2. The Problems • Professional developers need to: – Reach the maximum number of customers. – Keep current with new computing devices. • Students need to: – Quickly adapt to the technologies that will grab the attention of potential employers. – Increase the probability that a potential employer will be able to evaluate their work. • Wouldn’t it be nice if we could develop just one product and make it available for a variety of computing devices? – PC, tablet, smart phone, game console, etc.
  • 3. One Possible Solution 1. Identify parts that are same across platforms. – We’ll call this the core functionality. 2. Encapsulate the parts that differ. – We’ll call this the platform layer. 3. Create an interface to the platform layer that can be repeated for all supported platforms. 4. Make sure the core only talks to the platform layer interface and not the actual platform. – Then we can swap platforms and the core never needs to know!
  • 4. A Bird’s-Eye View of the Idea
  • 5. Proof of Concept: Snow vs. Man • Very early prototype built with MHFramework game engine which implements this design. • Play it on my laptop, tablet, or phone. • Objective: Prevent the evil snowmen from extinguishing your campfire. • How to Play: Click (tap) on open spaces to place defensive turrets.
  • 6. Systems That Can (or Will) Run My Game Android Phone Android Tablet OUYA Game Console M.O.J.O. Game Console Linux Mac OS Windows
  • 7. So…How Does It Work? 1. The main program runs in a platform-specific context. – For instance, an Activity on Android or a JFrame on Windows. 2. The program requests the appropriate platform layer depending on the context. 3. All calls to the platform go through a common interface that handles communication with whatever platform lies beneath.
  • 8. Main Program Code Notice the major similarities (and minor differences) between the PC and Android launchers for Snow vs. Man. PC Version public static void main(String[] args) { // Create the game's start screen. MHScreen startingScreen = new SVMMainMenuScreen(); // Configure video settings. MHVideoSettings displaySettings = new MHVideoSettings(); displaySettings.windowCaption = "Snow Vs. Man"; displaySettings.displayWidth = 800; displaySettings.displayHeight = 480; // Launch the game. MHPCPlatform.run(new JFrame(), startingScreen, displaySettings); } Android Version protected void onCreate(Bundle savedInstanceState) { // Initialize the Android activity. super.onCreate(savedInstanceState); // Create the game's start screen. MHScreen startingScreen = new SVMMainMenuScreen(); // Configure video settings. MHVideoSettings displaySettings = new MHVideoSettings(); displaySettings.windowCaption = "Snow Vs. Man"; displaySettings.displayWidth = 800; displaySettings.displayHeight = 480; // Launch the game. MHAndroidPlatform.run(this, startingScreen, displaySettings); }
  • 9. A Common Interface For All Platforms Since every platform interface will have these same functions, the game can call them without caring which platform is performing the tasks behind the scenes. public interface MHPlatformFactory { public MHBitmapImage createImage(int width, int height); public MHBitmapImage createImage(String filename); public MHColor createColor(int r, int g, int b, int a); public MHSoundManager getSoundManager(); public MHFont createFont(String fontName); public MHKeyCodes getKeyCodes(); public String getAssetsDirectory(); public MHTextFile openTextFile(String filename, Mode mode); }
  • 10.
  • 11. The Technical Stuff for Nerds
  • 12. The Guiding Object-Oriented Design Principles • Separate the aspects that vary from the aspects that stay the same. – The platform varies while the game code stays the same. • Strive for loosely coupled designs between objects that interact. – The common interface makes it easy to swap one platform for another without affecting the game code. • The Principle of Least Knowledge: “Talk only to your immediate friends.” – Minimizes places where game depends on platform. • The Hollywood Principle: “Don’t call us, we’ll call you.” – The platform serves the game, never vice versa.
  • 13. The Design Patterns That Make This Possible • Façade Pattern – Makes the platform easier to use by hiding its complexity. • Strategy Pattern – The game engine only supports elements of the platform on which it is running. Few wasted resources, no extraneous conditional logic. • Singleton Pattern – Ensures single platform layer and provides access to it. • Template Method Pattern – Allows for the possibility that some functions may be the same across platforms while others may differ.
  • 14. • Adapter Pattern – Each platform may have different ways of handling graphics, input, audio, etc. Adapter makes them all look the same from the game’s point of view. • Observer Pattern – Allows input handlers to use a generic set of events independent of those generated by the platforms. • Abstract Factory Pattern – Handles the details of creating the correct objects (graphics, sounds, etc.) for each platform.
  • 15. Drawbacks To This Approach • Platform-specific advantages may be lost. – Example: A mouse cannot multi-touch, while touch screens cannot right-click. • The extra level of abstraction may degrade runtime performance. • The platform layer adds unavoidable complexity to the software architecture. Software development involves trade-offs at every step. We must always consider the pros and cons of any solution.
  • 16. References Freeman, E. (2004). Head First design patterns. Sebastopol, CA: O'Reilly. Gamma, E. (1995). Design patterns: elements of reusable object-oriented software. Reading, Mass.: Addison-Wesley. Gregory, J. (2009). Game engine architecture. Wellesley, Mass.: A K Peters. Henson, M. (2013, July 24). Class structure of the platform layer. Retrieved June 20, 2014, from http://mhframework.blogspot.com/2013/07/class-structure-of-platform- layer.html Pressman, R. S. (2010). Software engineering: a practitioner's approach (7th ed.). Boston, Mass.: McGraw-Hill.

Notes de l'éditeur

  1. Consider recreating a cleaner and less physical draft of this diagram. Show that the game code plugs into the MHFramework class. Add colored annotations to point out design patterns in use. Façade – MHPlatform Strategy – MHPlatform Singleton – MHPlatform Template Method – MHGameApplication Abstract Factory – MHPlatformFactory Adapter – MHBitmapImage, MHGraphicsCanvas Observer – MHInputEventHandler
  2. Remove the “Continued” note when printing for poster.