Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Game of Developer Life... Deconstructed
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Mariusz Gil
April 03, 2017
Programming
200
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Game of Developer Life... Deconstructed
Mariusz Gil
April 03, 2017
More Decks by Mariusz Gil
See All by Mariusz Gil
Aspect Oriented Programming
mariuszgil
1
340
Designing and implementing GraphQL API
mariuszgil
1
110
Discovering unknown with EventStorming ConFoo
mariuszgil
0
320
Back to forgotten roots
mariuszgil
1
430
Go micro with microservices
mariuszgil
5
710
Machine Learning for the rescue
mariuszgil
0
450
Discovering graph structures
mariuszgil
3
560
Introduction to Aerospike with PHP
mariuszgil
8
870
Processing events at scale
mariuszgil
2
390
Other Decks in Programming
See All in Programming
並列実装の現場、2ヶ月間実務でAIを使い倒したAIもPCも私も限界が近い
ming_ayami
0
130
メソッドのジェネリクスでGoの夢は広がるか? / Kyoto.go #65
utgwkk
3
760
Mujeres en SEO Summit 2026 - Greatest Disaster Hits en Web Performance
guaca
0
180
DynamoDBには集計系のクエリがないけどなんとかしたい
musan
1
140
RTSPクライアントを自作してみた話
simotin13
0
600
ECSアプリログをFireLensでコスト削減しようとしたけど諦めた話 in Fargate×Node.js
akihisaikeda
2
4.2k
A2UI という光を覗いてみる
satohjohn
1
130
Hunting Vulnerabilities in Symfony with LLMs
vinceamstoutz
0
540
TSKaigi Night Talks 2026_TypeScriptでサプライチェーンの整合性を型に閉じ込める
geekplus_tech
0
350
Java × distroless で 軽量なコンテナイメージを / Java on Distroless
contour_gara
0
540
net-httpのHTTP/2対応について
naruse
0
480
LLMによるContent Moderationの本番運用の裏側と品質担保への挑戦
suikabar
2
640
Featured
See All Featured
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
49
10k
How to Ace a Technical Interview
jacobian
281
24k
Building the Perfect Custom Keyboard
takai
2
790
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
2
570
So, you think you're a good person
axbom
PRO
2
2.1k
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
160
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
3.4k
Scaling GitHub
holman
464
140k
jQuery: Nuts, Bolts and Bling
dougneiner
66
8.5k
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
440
The Mindset for Success: Future Career Progression
greggifford
PRO
0
360
XXLCSS - How to scale CSS and keep your sanity
sugarenia
250
1.3M
Transcript
Deconstructed Game of Life @MariuszGil
None
None
Back to 1970
None
None
None
None
Why game oF...
What How Why When
object oriented
None
None
private function calculateNewCellState($cell, $cellPosition) { $aliveCount = 0; $currentNeighbour =
0; $isFirstColumn = $cellPosition % $this->columns === 0; $isLastColumn = $cellPosition % $this->columns === $this->columns - 1; for ($i = 0; $i < 8; $i++) { $currentNeighbour = $cellPosition + $this->neighbourCoordinates[$i]; if ($currentNeighbour > 0 && ($currentNeighbour < $this->boardLength) && $this->currentGeneration[$currentNeighbour]->getState()) { if (($isFirstColumn && !in_array($i, [0, 3, 5])) || ($isLastColumn && !in_array($i, [2, 4, 7])) || !($isFirstColumn || $isLastColumn)) { $aliveCount++; } } } if ($cell->getState() && ($aliveCount < 2 || $aliveCount > 3)) { return false; } else if (!$cell->getState() && $aliveCount === 3) { return true; } else { return $cell->getState(); } }
protected function setCellDead(int $posN, int $posM) { $this->grid ->getCell($posN, $posM)
->setDead(); } private function onePlay() { $cellsToUpdate = []; for ($n = 0; $n < $this->grid->getSizeN(); $n++) { for ($m = 0; $m < $this->grid->getSizeM(); $m++) { $neighboursCount = $this->grid->getCellNeighboursCount($n, $m); $cellsToUpdate[] = ['n' => $n, 'm' => $m, 'neighbours' => $neighboursCount]; } } foreach ($cellsToUpdate as $cellStruct) { $this->rules->applyForCell($this->grid->getCell($cellStruct['n'], $cellStruct['m']), $cellStruct['neighbours']); } }
public function compute() { $computedGrid = []; foreach ($this->matrix as
$row => $cellArr) { foreach ($cellArr as $col => $cell) { $ns = $this->checkLifeNeighbours($row, $col); $newCell = ($cell === null) ? $this->checkIfAwake($ns) : $this->setCellStatus($cell, $ns); $computedGrid[$row][$col] = $newCell; } } $this->matrix = $computedGrid; } private function setCellStatus(Cell $cell, int $lifeNeighbours) { $newCell = clone($cell); if ($cell->getIsAlive() && ($lifeNeighbours < 2 || $lifeNeighbours > 3)) { $newCell->setIsAlive(false); } elseif (!$cell->getIsAlive() && 3 == $lifeNeighbours) { $newCell->setIsAlive(true); } return $newCell; }
TDD FTW!
Objects identification
Objects ResponsibilitieS
Objects desigN
cell Universe Game Rule Populator Renderer
Patterns and principles object oriented
Domain driven design object oriented Patterns and principles
Functional programming object oriented Patterns and principles Domain driven design
None
apply(state, rules) =
None
None
wrong AssumptionS
Future changeS
2 3
None
4 6
None
private function checkIfAwake($lifeNeighbours) { return (3 == $lifeNeighbours) ? new
Cell(true) : null; } private function checkLifeNeighbours(int $row, int $col) { $life = 0; for ($rowMatrix = $row-1; $rowMatrix <= $row+1; $rowMatrix++) { for ($colMatrix = $col-1; $colMatrix <= $col+1; $colMatrix++) { if ($colMatrix == $col && $rowMatrix == $row) continue; if (isset($this->matrix[$rowMatrix][$colMatrix]) && $this->matrix[$rowMatrix][$colMatrix]->getIsAlive()) { $life++; } } } return $life; }
None
So what?
stability / instability
None
Cancer cell cell Universe Game Rule Populator cli Renderer 2D
Coordinates stronger cell Always alive cell 3D Coordinates Svg Renderer
19 95
to remember
questions? @MariuszGil
None