Skip to content

Commit e0cdf33

Browse files
committed
docs(asteroids): credit Erik Assum with GitHub handle
Update article to properly credit Erik Assum with his GitHub handle (@slipset) for his valuable feedback on the swap! atom usage issue. Changed 'Erik provided excellent feedback' to link to his GitHub profile: https://github.com/slipset This gives proper attribution for his suggestion to use a single atomic swap! instead of multiple swap! calls in the hyperspace! function, which improved code quality and prevented race conditions.
1 parent 4683b6f commit e0cdf33

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/scittle/games/asteroids_article.clj

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,11 +297,12 @@
297297

298298
;; #### Code Review Improvement
299299

300-
;; After sharing this code on Slack, Erik provided excellent feedback:
300+
;; After sharing this code on Slack, [Erik Assum](https://github.com/slipset) provided excellent feedback:
301301

302302
;; > "Very cool! Looking at the code, in the `hyperspace!` you have multiple swap!s on your gamestate atom. Probs doesn't make a difference here, but it does defeat the purpose of an atom, because you're now susceptible to races (at least in a multi-threaded env), and if you have listeners to the atom state, they'll get more updates than what they bargained for."
303303

304304
;; **The Problem:** Multiple `swap!` calls meant:
305+
;;
305306
;; - Multiple state updates (5-7 separate modifications)
306307
;; - Race condition risk in multi-threaded environments
307308
;; - Multiple Reagent re-renders instead of one
@@ -343,6 +344,7 @@
343344
;; ```
344345

345346
;; **Benefits of the improved version:**
347+
;;
346348
;; - Single atomic state update
347349
;; - No race conditions
348350
;; - One Reagent re-render per hyperspace jump
@@ -790,13 +792,15 @@
790792
;; ### Impact of Performance Fixes
791793

792794
;; **Before fixes:**
795+
;;
793796
;; - Rapid firing → 100+ asteroids in seconds
794797
;; - 1000+ particles causing visual chaos
795798
;; - Frame rate drops from 60 FPS to < 10 FPS
796799
;; - Game becomes unplayable, browser may freeze
797800
;; - Mobile devices especially affected
798801

799802
;; **After fixes:**
803+
;;
800804
;; - Maximum 50 asteroids (smooth on all devices)
801805
;; - Maximum 200 particles (clean visual effects)
802806
;; - Consistent 60 FPS on desktop and mobile

0 commit comments

Comments
 (0)