2019-09-03 20:50:48 +02:00
|
|
|
|
---
|
|
|
|
|
layout: pattern
|
|
|
|
|
title: Bytecode
|
|
|
|
|
folder: bytecode
|
|
|
|
|
permalink: /patterns/bytecode/
|
|
|
|
|
categories: Behavioral
|
|
|
|
|
tags:
|
|
|
|
|
- Java
|
|
|
|
|
- Difficulty-Beginner
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
## Intent
|
|
|
|
|
Allows to encode behaviour as instructions for virtual machine.
|
|
|
|
|
|
2019-12-07 20:01:13 +02:00
|
|
|
|
## Class diagram
|
|
|
|
|

|
|
|
|
|
|
2019-09-03 20:50:48 +02:00
|
|
|
|
## Applicability
|
|
|
|
|
Use the Bytecode pattern when you have a lot of behavior you need to define and your
|
|
|
|
|
game’s implementation language isn’t a good fit because:
|
|
|
|
|
|
|
|
|
|
* it’s too low-level, making it tedious or error-prone to program in.
|
|
|
|
|
* iterating on it takes too long due to slow compile times or other tooling issues.
|
|
|
|
|
* it has too much trust. If you want to ensure the behavior being defined can’t break the game, you need to sandbox it from the rest of the codebase.
|
|
|
|
|
|
|
|
|
|
## Credits
|
|
|
|
|
|
|
|
|
|
* [Game programming patterns](http://gameprogrammingpatterns.com/bytecode.html)
|