Angband.oook.cz
Angband.oook.cz
AboutVariantsLadderForumCompetitionComicScreenshotsFunniesLinks

Go Back   Angband Forums > Angband > Development

Reply
 
Thread Tools Display Modes
Old December 15, 2014, 21:19   #11
Derakon
Prophet
 
Derakon's Avatar
 
Join Date: Dec 2009
Posts: 8,467
Derakon is on a distinguished road
The general guiding principle for making modular code is that any given bit of code A should only know the bare minimum about how other bits B, C, D operate. Whenever reasonably possible, A should delegate operations that require detailed knowledge to those other components. So for example, if you cast Scare Monster at a monster, the spell effect code could manually examine the target monster's struct for fear resistance, roll the monster's saving throw, and on failure set the monster's AI mode to frightened and print a special message. Or you could say "hey monster, you just got hit by a fear bolt of strength X" and let it do the rest itself. Because really, the spell effect code shouldn't need to know about how fear resistance works or what the specific effects of being frightened are.

In practice, it's usually not really feasible to have complete separation at every point in the code, but it's a goal to strive for. The more interdependencies you have in the code, the more "ripple effects" there are -- you change something in A, and suddenly B, C, and D all need to be modified because they have implicit dependencies on the old behavior.
Derakon is offline   Reply With Quote
Old December 15, 2014, 21:38   #12
debo
Veteran
 
debo's Avatar
 
Join Date: Oct 2011
Location: Toronto, Canada
Posts: 2,344
debo is on a distinguished road
The secondary definition of "modular code" is "code the way I would have written it, not this other dumb schmuck and that's why I can't find anything it's their fault"
__________________
Glaurung, Father of the Dragons says, 'You cannot avoid the ballyhack.'
debo is offline   Reply With Quote
Old December 15, 2014, 21:56   #13
Nick
Vanilla maintainer
 
Nick's Avatar
 
Join Date: Apr 2007
Location: Canberra, Australia
Age: 53
Posts: 7,173
Donated: $60
Nick is on a distinguished road
Quote:
Originally Posted by debo View Post
The secondary definition of "modular code" is "code the way I would have written it, not this other dumb schmuck and that's why I can't find anything it's their fault"
Cool, someone understands why I wanted to restructure
__________________
One for the Dark Lord on his dark throne
In the Land of Mordor where the Shadows lie.
Nick is offline   Reply With Quote
Old December 15, 2014, 22:07   #14
Derakon
Prophet
 
Derakon's Avatar
 
Join Date: Dec 2009
Posts: 8,467
Derakon is on a distinguished road
Quote:
Originally Posted by debo View Post
The secondary definition of "modular code" is "code the way I would have written it, not this other dumb schmuck and that's why I can't find anything it's their fault"
The worst bit is when you go digging into the commit history to figure out who that dumb schmuck was, and find out it was yourself.
Derakon is offline   Reply With Quote
Old December 16, 2014, 03:14   #15
fizzix
Prophet
 
Join Date: Aug 2009
Location: Madison, Wisconsin, US
Posts: 3,001
fizzix is on a distinguished road
Quote:
Originally Posted by Derakon View Post
The worst bit is when you go digging into the commit history to figure out who that dumb schmuck was, and find out it was yourself.
I've discovered that the most inept coder in the world, in my opinion, always turns out to fizzix-of-the-past.
fizzix is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:48.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2018, vBulletin Solutions Inc.