Come out and Play
Come out and Play
Webanwendungen schreiben mit Scala, Scala.js, Akka und dem Play Framework.
Über das Buch
Mit diesem Buch erfolgt ein praxisorientierter Einstieg in die Entwicklung größerer Webanwendungen mit dem Play Framwork, Scala, Akka und Scala.js.
Es wird vermittelt, wie man Webanwendungen mit dem Play Framework schreibt, Datenbankzugriffe via Slick implementiert, Aufgaben asynchron mit Futures und Aktoren umsetzt sowie geteilten und clientseitigen Code via Scala.js generiert. Für Authorisierung und Authentifizierung wird das Silhoutte Framework genutzt. Websockets, die aus den meisten Anwendungen nicht mehr wegzudenken sind, kommen ebenfalls zum Einsatz.
Das Buch vermittelt, wie man SBT zur Verwaltung und Organisation von Projekten nutzt. Kenntnisse von Scala werden nicht vorausgesetzt, es erfolgt eine kurze Einführung in die Programmiersprache und die funktionale Programmierung mit Scala.
Für wen ist dieses Buch geeignet?
Das Buch richtet sich an alle, die sich für die Webentwicklung mit Scala und Play interessieren. Es sollte grundlegende Erfahrung in einer beliebigen Programmiersprache sowie Kenntnis von Webtechnologien vorhanden sein.
Welche Versionen werden genutzt?
Der Quelltext nutzt Scala 2.12, Play 2.6, Silhouette 5.0, Scala.js 0.6 sowie Cats 1.x. Ansonsten wird soweit möglich die jeweils aktuellste Version verwendeter Bibiliotheken genutzt.
Wo liegt der Code?
Das Repository mit dem Code zum Buch liegt in einem öffentlichen Repository bei GitLab: https://gitlab.com/comeoutandplay/code
Sonstiges
Wir haben ein Diskussionsforum zum Buch, das direkt bei Leanpub liegt: https://community.leanpub.com/c/comeoutandplay
Table of Contents
-
-
Vorwort
- Einleitung
-
Aufbau des Buches
- Konventionen für den Quelltext
- Schutzmarken und Copyrights
- Logos und Bilder
- Quelltext zum Buch
-
Vorwort
-
Einrichtung der Werkzeuge und Einführung in Scala
-
1 Werkzeuge
- 1.1 Java
-
1.2 SBT
- 1.2.1 Installation
- 1.2.2 Nützliches für SBT
- 1.3 Entwicklungsumgebung
-
2 Programmierung in Scala
- 2.1 Interaktive Programmierung via REPL
- 2.2 Hinweise zu Datenstrukturen (var, val)
-
2.3 Schnelleinstieg in die funktionale Programmierung
- 2.3.1 Auswertungsstrategien (evaluation strategies)
- 2.3.2 Scopes und Blöcke
- 2.3.3 Semikolons und Infix-Operatoren
- 2.3.4 Tail-Rekursion
- 2.3.5 Funktionen höherer Ordnung (Higher Order Functions)
- 2.3.6 Currying
- 2.3.7 Polymorphismus
- 2.3.8 Pattern-Matching
- 2.3.9 Implizite Parameter
- 2.4 Hilfsmittel zur Unterstützung
- 2.5 Reduzierung von “Boilerplate” Code
-
1 Werkzeuge
-
Einführung und Grundlagen zu den verwendeten Technologien
-
3 Play Framework
-
3.1 Erstellen einer Play Anwendung
- 3.1.1 Play Anwendung über Schablonen erstellen
- 3.1.2 Play Anwendung von Hand erstellen
-
3.2 Projektstruktur
- 3.2.1 Verzeichnisse, SBT-Einstellungen und Abhängigkeiten
- 3.2.2 Unterprojekte
-
3.3 Requests, Routing und Controller
- 3.3.1 Requests
- 3.3.2 Routing
- 3.3.3 Controller
-
3.4 Templates (Twirl)
- 3.4.1 Wiederverwendung von Templates
-
3.5 Mehrsprachigkeit (Internationalisierung)
- 3.5.1 Messages Objekt
-
3.6 Formulare
- 3.6.1 Formdefinition
- 3.6.2 Form-Objekte und ihre Typen
- 3.6.3 Beispiele für Formulare
- 3.6.4 Verarbeitung von Formularen
- 3.6.5 Formulardarstellung in Template View
- 3.6.6 Beispiel mit sich wiederholenden Elementen
-
3.7 Datenbankkonfiguration
- 3.7.1 Konfiguration von Slick für Play
- 3.8 Datenbankzugriff
-
3.9 Asynchrone Programmierung mit Play
- 3.9.1 Websockets
- 3.10 Webservices
-
3.11 Migration von Play 2.5 auf 2.6
- 3.11.1 Was hat sich geändert
- 3.11.2 SBT 0.13.15 erforderlich
-
3.11.3
Guice
undOpenId
Unterstützung ausgelagert -
3.11.4 Bereitstellung neuer
Controller
Klassen - 3.11.5 Assets
- 3.11.6 Play WS
-
3.11.7 Anpassungen bei
i18n
- 3.11.8 Cache
-
3.11.9 Veränderungen an der
Scala Configuration API
- 3.11.10 Entfernung diverser APIs und Bibliotheken
-
3.11.11
play.api.libs.concurrent.Execution
ist nun veraltet -
3.11.12 Neue
Standardfilter
- 3.12 Konfiguration von Ehcache
- 3.13 Ausführen mit IntelliJ IDEA und Debuggen
-
3.1 Erstellen einer Play Anwendung
-
4 Akka
- 4.1 Einrichten einer Akka Anwendung
-
4.2 Akka Grundlagen
- 4.2.1 Aktorsystem und Aktoren
- 4.2.2 Supervision
- 4.2.3 Aktorreferenzen
- 4.2.4 Nachrichten und deren Auslieferung
- 4.2.5 Konfiguration
-
4.3 Aktoren
- 4.3.1 DeathWatch
- 4.3.2 Nachrichten
- 4.3.3 Aktoren beenden
- 4.3.4 FSM
- 4.3.5 Persistenz
- 4.3.6 Tests
-
4.4 Aktorenhilfsmittel
- 4.4.1 Event-Bus
- 4.4.2 Logging
- 4.4.3 Scheduler
- 4.4.4 Zeitdauer (Duration)
- 4.4.5 Unterbrecher (Circuit Breaker)
- 4.5 Streams
-
5 Scala.js
- 5.1 Erstellen einer Scala.js Anwendung
- 5.2 Abhängigkeiten
- 5.3 Module exportieren
- 5.4 Cross-Compile
- 5.5 Testen
-
3 Play Framework
-
Anwendungsszenario
- 6 Das Frontend
- 7 Das Online-Spiel
-
Das Frontend
- 8 Erstellung und Konfiguration einer Basis-Play-Anwendung
- 9 Einbindung von Silhouette als Authentifikations-Framework
-
10 Anmeldung der Nutzer am System
- 10.1 Konfiguration des Backend Store (PostgreSQL)
- 10.2 Definition des Nutzermodells
- 10.3 Erstellen einer Datenbank-Evolution
- 10.4 Tabellendefinition innerhalb der Anwendung
- 10.5 DAOs für den Zugriff auf die Nutzerdaten
- 10.6 Silhouette Konfiguration auf eigene DAOs umstellen
- 10.7 Konfiguration der Social-Provider
- 10.8 Funktionalität für das Löschen eines Accounts
-
11 Suchen und Verwalten von Freunden
- 11.1 Erweiterung des Nutzermodells um einen Nutzernamen
- 11.2 Registrierung der Nutzer mit Nutzernamen und E-Mail
- 11.3 Evolution und Tabellendefinitionen für Freundeslisten
- 11.4 Funktionalitäten für Freundeslisten in einem DAO
-
11.5 Erstellen von WebSockets zur dynamischen Interaktion
- 11.5.1 Erstellen des WebSocket auf Basis eines Actors
- 11.5.2 Controller als Endpunkt für das WebSocket
- 11.5.3 Verbinden der Action innerhalb des Routing
- 11.5.4 Erstellen von Funktionen innerhalb des Javascript, welche mit dem WebSocket zusammen arbeiten
- 11.6 Erweiterung des CSR für WebSockets
- 11.7 Visualisierung der Freundeslisten
- 11.8 Erweiterung der Views zur Übergabe von Skripten und CSS
-
12 Migration auf Play 2.6 und Silhouette 5
- 12.1 Upgrade der benötigten Abhängigkeiten
- 12.2 Anpassungen für das Upgrade von Silhouette
- 12.3 Änderungen im CustomPostgresDriver
- 12.4 Neue Controller-Klassen
- 12.5 Von WebJarAssets zu AssetsFinder
- 12.6 Anpassungen für die Änderungen in i18n
- 12.7 Impliziter ExecutionContext
- 12.8 Refactoring (Compiler-Warnungen)
-
Das Spiel
- 13 Regeln und Spielverlauf
-
14 Umsetzung
- 14.1 Grundlegende Datentypen
- 14.2 Operationen auf einem Spielstand
- 14.3 Operationen auf einem Spielfeld
- 14.4 Nutzung von Eq (Cats)
- 14.5 Datenbank (Repository)
- 14.6 Zeichnen von Spielfeldern im Client
-
14.7 Hilfsfunktionen
- 14.7.1 Websocket-URL berechnen
- 14.7.2 Feldgröße zum Zeichnen berechnen
- 14.7.3 Berechnen der Klickposition in einem Spielfeld
- 14.7.4 Logging
-
14.8 Spielvorbereitung (
Preparation
)- 14.8.1 Globale Variablen
- 14.8.2 Struktur der HTML-Datei
- 14.8.3 Funktionen
- 14.8.4 Websocket
- 14.8.5 Aufruf und Initialisierung
-
14.9 Spielablauf (
Game
)- 14.9.1 Globale Variablen
- 14.9.2 Struktur der HTML-Datei
- 14.9.3 Funktionen
- 14.9.4 Websocket
- 14.9.5 Aufruf und Initialisierung
-
15 Integration ins Frontend
-
15.1 Verzeichnisstruktur
- 15.1.1 Aktoren, Controller, DAO und Modelle
- 15.1.2 View-Templates
- 15.2 Datenbankschicht (Repository) als DAO
-
15.3 Websocket
- 15.3.1 Eine Websocket-Algebra
- 15.3.2 Komposition zum fertigen Websocket
-
15.4 Controller und Routing
- 15.4.1 Übersichtsseite
- 15.4.2 Spielerstellung
- 15.4.3 Löschen eines Spielstandes
- 15.4.4 Dem Spiel beitreten
- 15.4.5 Das Spiel
- 15.4.6 Spielvorbereitung
- 15.4.7 Websocket
- 15.5 Views
-
15.1 Verzeichnisstruktur
-
Deployment (Auslieferung)
- 16 Konfiguration für den Produktivbetrieb
- 17 Erstellen eines Artefakts mit allen Abhängigkeiten
-
18 Erstellen von Paketen für Debian
- 18.1 Systemstart-Skripte
-
19 Auslieferung zu einem Cloud Service
- 19.1 Deployment via Remote Repository
- 19.2 Deployment mittels des Plugins sbt-heroku
- 19.3 Datenbankzugriff bei Heroku
-
Erkenntnisse
-
20 Silhouette
- 20.1 Abhängigkeiten von anderen Bibliotheken
- 20.2 Aufwand durch inkompatible Änderungen
-
21 Circe
-
21.1 Erstellung von Codecs
- 21.1.1 Vollautomatische Ableitung
- 21.1.2 Halbautomatische Ableitung
- 21.1.3 Manuelle Implementierung
- 21.2 Geschwindigkeit des Compilers
- 21.3 Fehlerhäufigkeit
-
21.1 Erstellung von Codecs
-
WTFM - Write that fucking manual!
- Vorteile für bereits involvierte Entwickler
- Vorteile für neue Entwickler
- Danke
-
20 Silhouette
- Anmerkungen
Authors have earned$10,085,459writing, publishing and selling on Leanpub, earning 80% royalties while saving up to 25 million pounds of CO2 and up to 46,000 trees.
Erfahren Sie mehr über das Schreiben mit Leanpub
Die bedingungslose Leanpub, Kein Risiko, 100% zufrieden Garantie
Innerhalb von 45 Tagen ab Kauf kannst du dein Geld zu 100% zurückverlangen, bei jedem Leanpub-Kauf, in nur zwei Klicks. Wir bearbeiten die Erstattungen manuell, daher dauert es ein paar Tage, bis der Betrag ankommt.
Lese die kompletten Bedingungen.
Free Updates. DRM Free.
If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).
Most Leanpub books are available in PDF (for computers), EPUB (for phones and tablets) and MOBI (for Kindle). The formats that a book includes are shown at the top right corner of this page.
Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.
Learn more about Leanpub's ebook formats and where to read them
Top Books
C++20
Rainer GrimmC++20 is the next big C++ standard after C++11. As C++11 did it, C++20 changes the way we program modern C++. This change is, in particular, due to the big four of C++20: ranges, coroutines, concepts, and modules.
The book is almost daily updated. These incremental updates ease my interaction with the proofreaders.
C++ Best Practices
Jason TurnerLevel up your C++, get the tools working for you, eliminate common problems, and move on to more exciting things!
Atomic Kotlin
Bruce Eckel and Svetlana IsakovaFor both beginning and experienced programmers! From the author of the multi-award-winning Thinking in C++ and Thinking in Java together with a member of the Kotlin language team comes a book that breaks the concepts into small, easy-to-digest "atoms," along with exercises supported by hints and solutions directly inside IntelliJ IDEA!
Sockets and Pipes
Type ClassesSockets and Pipes is not an introduction to Haskell; it is an introduction to writing software in Haskell. Using a handful of everyday Haskell libraries, this book walks through reading the HTTP specification and implementing it to create a web server.
Introducing EventStorming
Alberto BrandoliniThe deepest tutorial and explanation about EventStorming, straight from the inventor.
Composing Software
Eric ElliottAll software design is composition: the act of breaking complex problems down into smaller problems and composing those solutions. Most developers have a limited understanding of compositional techniques. It's time for that to change.
Cloud Strategy
Gregor Hohpe“Strategy is the difference between making a wish and making it come true.” A successful migration to the cloud can transform your organization, but it shouldn’t be driven by wishes. This book tells you how to develop a sound strategy guided by frameworks and decision models without being overly abstract nor getting lost in product details.
node-opcua by example
Etienne RossignonGet the best out of node-opcua through a set of documented examples by the author himself that will allow you to create stunning OPCUA Servers or Clients.
Functional Design and Architecture
Alexander GraninSoftware Design in Functional Programming, Design Patterns and Practices, Methodologies and Application Architectures. How to build real software in Haskell with less efforts and low risks. The first complete source of knowledge.
Ansible for DevOps
Jeff GeerlingAnsible is a simple, but powerful, server and configuration management tool. Learn to use Ansible effectively, whether you manage one server—or thousands.
Top Bundles
- #1
Software Architecture for Developers: Volumes 1 & 2 - Technical leadership and communication
2 Books
"Software Architecture for Developers" is a practical and pragmatic guide to modern, lightweight software architecture, specifically aimed at developers. You'll learn:The essence of software architecture.Why the software architecture role should include coding, coaching and collaboration.The things that you really need to think about before... - #2
Django for Beginners/APIs/Professionals
3 Books
- #3
PowerShell
3 Books
Buy every PowerShell book from Adam Bertram at a 20% discount! - #4
CCIE Service Provider Ultimate Study Bundle
2 Books
Piotr Jablonski, Lukasz Bromirski, and Nick Russo have joined forces to deliver the only CCIE Service Provider training resource you'll ever need. This bundle contains a detailed and challenging collection of workbook labs, plus an extensively detailed technical reference guide. All of us have earned the CCIE Service Provider certification... - #5
Cisco CCNA 200-301 Complet
4 Books
Ce lot comprend les quatre volumes du guide préparation à l'examen de certification Cisco CCNA 200-301. - #6
All the Books of The Medical Futurist
6 Books
We put together the most popular books from The Medical Futurist to provide a clear picture about the major trends shaping the future of medicine and healthcare. Digital health technologies, artificial intelligence, the future of 20 medical specialties, big pharma, data privacy, digital health investments and how technology giants such as Amazon... - #7
Linux Administration Complet
4 Books
Ce lot comprend les quatre volumes du Guide Linux Administration :Linux Administration, Volume 1, Administration fondamentale : Guide pratique de préparation aux examens de certification LPIC 1, Linux Essentials, RHCSA et LFCS. Administration fondamentale. Introduction à Linux. Le Shell. Traitement du texte. Arborescence de fichiers. Sécurité... - #8
Software Architecture and Beautiful APIs
2 Books
There is no better way to learn how to design good APIs than to look at many existing examples, complementing the Software Architecture theory on API design. - #9
Learn Git, Bash, and Terraform the Hard Way
3 Books
Learn Git, Bash and Terraform using the Hard Way method.These technologies are essential tools in the DevOps armoury. These books walk you through their features and subtleties in a simple, gradual way that reinforces learning rather than baffling you with theory. - #10
9 Books-Bundle: Shut Up and Code!
9 Books
"Shut up and code." Laughter in the audience. The hacker had just plugged in his notebook and started sharing his screen to present his super-smart Python script. "Shut up and code" The letters written in a white literal coding font on black background was the hackers' home screen background mantra. At the time, I was a first-year computer...