Menu
News
All News
Dungeons & Dragons
Level Up: Advanced 5th Edition
Pathfinder
Starfinder
Warhammer
2d20 System
Year Zero Engine
Industry News
Reviews
Dragon Reflections
White Dwarf Reflections
Columns
Weekly Digests
Weekly News Digest
Freebies, Sales & Bundles
RPG Print News
RPG Crowdfunding News
Game Content
ENterplanetary DimENsions
Mythological Figures
Opinion
Worlds of Design
Peregrine's Nest
RPG Evolution
Other Columns
From the Freelancing Frontline
Monster ENcyclopedia
WotC/TSR Alumni Look Back
4 Hours w/RSD (Ryan Dancey)
The Road to 3E (Jonathan Tweet)
Greenwood's Realms (Ed Greenwood)
Drawmij's TSR (Jim Ward)
Community
Forums & Topics
Forum List
Latest Posts
Forum list
*Dungeons & Dragons
Level Up: Advanced 5th Edition
D&D Older Editions
*TTRPGs General
*Pathfinder & Starfinder
EN Publishing
*Geek Talk & Media
Search forums
Chat/Discord
Resources
Wiki
Pages
Latest activity
Media
New media
New comments
Search media
Downloads
Latest reviews
Search resources
EN Publishing
Store
EN5ider
Adventures in ZEITGEIST
Awfully Cheerful Engine
What's OLD is NEW
Judge Dredd & The Worlds Of 2000AD
War of the Burning Sky
Level Up: Advanced 5E
Events & Releases
Upcoming Events
Private Events
Featured Events
Socials!
EN Publishing
Twitter
BlueSky
Facebook
Instagram
EN World
BlueSky
YouTube
Facebook
Twitter
Twitch
Podcast
Features
Top 5 RPGs Compiled Charts 2004-Present
Adventure Game Industry Market Research Summary (RPGs) V1.0
Ryan Dancey: Acquiring TSR
Q&A With Gary Gygax
D&D Rules FAQs
TSR, WotC, & Paizo: A Comparative History
D&D Pronunciation Guide
Million Dollar TTRPG Kickstarters
Tabletop RPG Podcast Hall of Fame
Eric Noah's Unofficial D&D 3rd Edition News
D&D in the Mainstream
D&D & RPG History
About Morrus
Log in
Register
What's new
Search
Search
Search titles only
By:
Forums & Topics
Forum List
Latest Posts
Forum list
*Dungeons & Dragons
Level Up: Advanced 5th Edition
D&D Older Editions
*TTRPGs General
*Pathfinder & Starfinder
EN Publishing
*Geek Talk & Media
Search forums
Chat/Discord
Menu
Log in
Register
Install the app
Install
Community
General Tabletop Discussion
*Geek Talk & Media
Character Generation [technical/theoretical]
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Archimedes" data-source="post: 342480" data-attributes="member: 5281"><p>I’d be happy to.</p><p></p><p>I don’t know what languages you’re familiar with, so I’ll keep it general.</p><p></p><p>Start with two classes named something like Observer and Observed.</p><p></p><p>Give the Observer class a method that’s traditionally named Update. Pass a reference to an Observed as an argument since the Observer may be watching more than one Observed and it’ll need to get at the data anyway.</p><p></p><p>Give the Observed class a list with type Observer and two methods, Add & Delete, that accept a reference to Observer as arguments. These methods add and remove the given Observers from the list. Most importantly give the Observed a method that’s traditionally named Notify. This method loops through the Observer list calling Update on each Observer reference.</p><p></p><p>These classes are usually used as Mix-Ins in languages that support multiple inheritance. In something like Java you can use Interfaces or Delegation. In the class that inherits from Observer you’ll want to override the Update method according to purpose and use the Observed’s Add method to register with said Observed. The later is often done in the Observer’s constructor.</p><p></p><p>In the class that inherits from Observed you’ll want to add the Notify method to the end of whatever method is used to modify the Observed.</p><p></p><p>Setting up this pattern is trivial in languages like Python, Ruby, or even LISP(Someone did mention Paul Graham). It’s also fairly simple in C++, but a little harder than it needs to be in Java.</p><p></p><p>You can make your objects both Observer and Observed, with the Observer notifying it’s own Observers when updated. That’s how you can avoid writing those logic tables of cascades yourself.</p><p></p><p>You can get fancier with the Observer if you want, using different Notify method that call variant Update methods or even using a vector instead of a list and registering a callback to replace Update when calling the Add method.</p><p></p><p>Maybe that’s enough for you to start looking. You should be able to find examples written in your language of choice out there somewhere. <img src="https://cdn.jsdelivr.net/joypixels/assets/8.0/png/unicode/64/1f642.png" class="smilie smilie--emoji" loading="lazy" width="64" height="64" alt=":)" title="Smile :)" data-smilie="1"data-shortname=":)" /></p><p></p><p>Sam</p></blockquote><p></p>
[QUOTE="Archimedes, post: 342480, member: 5281"] I’d be happy to. I don’t know what languages you’re familiar with, so I’ll keep it general. Start with two classes named something like Observer and Observed. Give the Observer class a method that’s traditionally named Update. Pass a reference to an Observed as an argument since the Observer may be watching more than one Observed and it’ll need to get at the data anyway. Give the Observed class a list with type Observer and two methods, Add & Delete, that accept a reference to Observer as arguments. These methods add and remove the given Observers from the list. Most importantly give the Observed a method that’s traditionally named Notify. This method loops through the Observer list calling Update on each Observer reference. These classes are usually used as Mix-Ins in languages that support multiple inheritance. In something like Java you can use Interfaces or Delegation. In the class that inherits from Observer you’ll want to override the Update method according to purpose and use the Observed’s Add method to register with said Observed. The later is often done in the Observer’s constructor. In the class that inherits from Observed you’ll want to add the Notify method to the end of whatever method is used to modify the Observed. Setting up this pattern is trivial in languages like Python, Ruby, or even LISP(Someone did mention Paul Graham). It’s also fairly simple in C++, but a little harder than it needs to be in Java. You can make your objects both Observer and Observed, with the Observer notifying it’s own Observers when updated. That’s how you can avoid writing those logic tables of cascades yourself. You can get fancier with the Observer if you want, using different Notify method that call variant Update methods or even using a vector instead of a list and registering a callback to replace Update when calling the Add method. Maybe that’s enough for you to start looking. You should be able to find examples written in your language of choice out there somewhere. :) Sam [/QUOTE]
Insert quotes…
Verification
Post reply
Community
General Tabletop Discussion
*Geek Talk & Media
Character Generation [technical/theoretical]
Top