D&D 5E Classes, Subclasses, and Object Oriented Programming

GSHamster

Adventurer
The current design of classes and subclasses in D&D Next is very similar to some concepts in computer science. This is a look at that design using the terminology of computer science. As well, I hope to show that--if the analogy holds--this current design will have issues later on.

Goal of Subclasses

What WotC is aiming for with this design is the concept of polymorphism. Polymorphism is the ability for data of one type to be substituted for data of another type safely. Essentially, if a rule calls for a character of type Mage, you can give the rule a character of type Wizard, or type Warlock, or type Sorceror, and the rule will still work.

The advantage of polymorphism is that it allows future products to work together, even though they don't know about each other. For example, let's say class Fighter is defined in the Player's Handbook. A year later, Supplement A comes out with subclass Knight, and Supplement B comes out with a combat stunt system for Fighters. Thanks to polymorphism, if things are done correctly, Knights will be able to use the stunt system without issues, even if the two Supplements don't know about each other. Instead, they interact with each other through the definition of Fighter.

Implementation

The mechanism WotC is using is called inheritance. Some mechanics are defined in the base class, and the subclass "inherits" those mechanics. For example, let's say Sneak Attack is defined in the base Rogue class as "deal 1d6 extra damage if you are flanking". All Rogue subclasses will gain that ability by default. The subclasses can change Sneak Attack, but there is a default mechanic in place.

Subclasses can add new abilities, but rules that reference the Rogue cannot reference those new abilities, because those abilities are not part of the Rogue.

Issues

Inheritance is not the only mechanism that can be used to implement polymorphism. A second method is called interface composition. In this method, the top classes (called interfaces) are purely descriptive. All mechanics are contained within the subclass. For example, the Rogue interface would have an ability called Sneak Attack. However, each subclass would have to define Sneak Attack individually. They may all define it the same way, or some may change the ability up.

Now, it may seem like interface composition is less powerful than inheritance. But interface composition has some subtle advantages. First, sometimes mechanics can conflict, or rules that rely on the default implementation cease to work with a subclass that changes it up. For example, let's say the default Sneak Attack works in melee combat. Then an Archer subclass comes out that redefines Sneak Attack to work at range. If a third book comes out which assumes Sneak Attack is in melee, it can conflict with the Archer variant. These sort of small conflicts and assumptions end up being fairly common if the inheritance hierarchy gets very big. A purely descriptive interface tends to avoid these issues because all you have to rely on is the description and not the default implementation.

The second advantage is that it is a lot easier to make a subclass that can substitute for multiple classes. For example, let's say you want to make an Arcane Trickster, a mage/rogue hybrid. What base class do you start with? If it's a Mage, then rules that reference Rogues don't work. And vice versa. Mechanics like Base Attack Bonus can conflict, because both Mage and Rogue define the same mechanic differently.

Whereas in interface composition it would look something like this:

Mage
- casts Arcane spells

Rogue
- has Sneak Attack

Arcane Trickster is both Mage and Rogue
- defines its own BAB progression
- casts Arcane spells
- has Sneak Attack

It can easily substitute for both classes, and will work correctly with rules that reference Mages or Rogues.

The software development world is moving to the view that interface composition has more advantages than inheritance. It is considered to be more flexible. Each subclass is fully defined on its own, and does not reference back to a base class. In fact, Google's latest language, Go, does not have inheritance at all, relying fully on interface composition to provide polymorphism.

Conclusion

It should be noted that in my day job as a software developer, I am in the interface composition camp. I used to be a proponent of inheritance, but in practice inheritance has ended up causing me more headaches than it solved.

In my opinion, the same issues that plague inheritance in object-oriented programming will end up affecting class design in D&D Next. The base class mechanics will prove to be too rigid, and the promise of polymorphism will prove to be harder to achieve as more and more rules come out that rely on the base assumptions of the default class.

I expect that it will take an edition's worth of subclasses to fully see the issues. Perhaps in 6E we will be ready to move to purely descriptive base classes without mechanics.

A Note on Psionists

In my opinion, the issue with Psionists and Mages can be very clearly seen in a purely descriptive system. A description of Mage might be something like:

Mage
- casts arcane spells
- can wear robes
- has a familiar

A Psionist is going to violate that very first line in the description. Therefore a Psionist cannot be a Mage.

Where WotC is going wrong is that they want the Psionist to use some of mechanics defined in the base Mage class, and to be treated like a Mage by future rules. But in a system where there are no mechanics defined in the base Mage class, this is more obviously wrong.

Or the fix, that psionics is now a type of arcane magic, must be stated more bluntly.
 
Last edited:

log in or register to remove this ad

Connorsrpg

Adventurer
Wow, what an observation. I thought I lost you there for a while, but it makes sense now. I agree on the 'everything in the subclass too'. Kind of like 2E or was it 1E where they 'grouped' classes, but it was only for descriptive purposes?
 

GSHamster

Adventurer
I may have glossed over some points that I should have included. Here are some additional thoughts.

For subtype polymorphism to work correctly, a subclass cannot contradict the base class. This is called the Liskov Substitution Principle. If it does contradict, you will end up with situations where the subclass is an imperfect substitute, and may have conflicts.

For example, let's you define a base Cleric class that can wear heavy armor. You cannot then create a subclass Priest which cannot wear heavy armor, only robes. That would violate Liskov. You can go the other way around, and have Priest be the base class, and Cleric the subclass which can wear heavy armor in addition to robes.

Again, we go back to the Psionist. Psionist inheriting from Mage contradicts the Mage being able to cast arcane spells, and is a violation of Liskov.

If it was up to me, given the current class structure in Next, I would have Psionist inherit from Rogue instead. We could justify Sneak Attack by saying that all Psionists have a touch of precognition and telepathy that unconsciously aids them in combat. Sneak attack could either follow the basic rogue rules, or be tweaked to something like "gains Sneak Attack when fighting intelligent opponents", reinforcing the idea that the psionist is picking up some of her opponent's thoughts.
 
Last edited:

UngainlyTitan

Legend
Supporter
While there are conceptual similarities with object oriented design principles and class design in rpgs there are some fundamental differences. In particular in general rpgs are exception design based. In that there is a general task resolution system (or possibly a number of them with restricted areas of competence) and the the class provides exceptions to the general resolution system. Thus, in general one may batter down a locked door or ignore it but the rogue has the option to pick the locks.
Thus in sub classes one will never repeat the mechanics of the base class. They always operate, and the subclass provides other options.

As for the mage and psionicists, classes are not types and the human brain does not compile the rules of an rpg to run the game. Classification of class/subclass is more of an aide-memoire than a type in a programming language. Furthermore structures like the 4e role/powersource and the Next class/subclass structure seem to me to be more a method of putting discipline on designers than on players.

The base class communicates an archetype to the players and the sub class give mechanical weight to an implementation of that archetype.
 

1of3

Explorer
A Note on Psionists

In my opinion, the issue with Psionists and Mages can be very clearly seen in a purely descriptive system. A description of Mage might be something like:

Mage
- casts arcane spells
- can wear robes
- has a familiar

A Psionist is going to violate that very first line in the description. Therefore a Psionist cannot be a Mage.

Where WotC is going wrong is that they want the Psionist to use some of mechanics defined in the base Mage class, and to be treated like a Mage by future rules. But in a system where there are no mechanics defined in the base Mage class, this is more obviously wrong.

Or the fix, that psionics is now a type of arcane magic, must be stated more bluntly.

Or there is no arcane magic. If I'm not mistaken a divine /arcane split isn't referenced anywhere in the rules.

Also "arcane magic" is rather meaningless by itself. A "mage casts arcane spells" is a tautology. In what way are arcane spells different from other spells? As soon as we try to actually express what it means, I can see several ways to fit a psionicist in.

- Arcane magic is the changing of reality with one's own will. - Psionicist check.

- Arcane magic is understanding of the universe within quasi-technical framework and then manipulating it. - Psionicist check.
 

Warbringer

Explorer
[MENTION=48555]1of3[/MENTION]

While the designers seem too have been very careful not referring to "arcane" magic in the class description, it is in the Character Creation (most likely an oversight).

"The most common classes are cleric, fighter, rogue, and wizard. Clerics are champions endowed with magic from the gods, fighters are tough warriors and weapon specialists, rogues are experts in many areas of expertise and skullduggery, and mages are masters of arcane magic"

Re the definition of arcane magic, it is at the end of the day arbitrary, but once defined it, it is foundational. Hence "all mages cast arcane spells" is a statement of the class in the game mechanic (ie system rules), and is a tautology, in that it is a universal truth in the logic - a rule, which is [MENTION=20187]GSHamster[/MENTION]'s position (I believe), and so variation of that universal truth is a Liskov violation.

For some, that immediately creates an issue because they feel that psionics and invocations are not arcane and are not spells.

Now, I agree with your premise that the intent is "mages are supreme magic-users" (first line of class description) and that their magic is specifically untyped and is to be left to the sub-class to type, Mage->arcane, psionicist -> psionic (a truely grammatical tautology), warlocks -> invocation.

I suggest that is this is the design intent they need to correct the Character Creation packet and clearly type the magic on the sub-class description (preferably as a keyword)
 



Iosue

Legend
Re the definition of arcane magic, it is at the end of the day arbitrary, but once defined it, it is foundational. Hence "all mages cast arcane spells" is a statement of the class in the game mechanic (ie system rules), and is a tautology, in that it is a universal truth in the logic - a rule, which is @GSHamster's position (I believe), and so variation of that universal truth is a Liskov violation.

For some, that immediately creates an issue because they feel that psionics and invocations are not arcane and are not spells.
"Arcane" merely means "understood by a few, mysterious, secret", and its etymology means "hidden". Any psion who unlocks the secrets of the mind to affect reality could be said to be practicing an arcane art. Yea, even a kind of arcane magic.

If 5e used power sources and they said that psions used the Arcane power source, I could see the issue. As it is in 5e, the Mage class is made up of subclasses that use various methods (spells, invocations, psionics) to use powers little known nor understood by regular folks.
 

GSHamster

Adventurer
I did say that the fix was to explicitly note that psionics is a type of arcane magic.

Personally, I don't think that solution will make fans of psionics happy. It means that dispel magic, etc will affect psionics.

But that's sort of tangential to my main point that inheriting mechanics from the base class will inevitably cause issues. But like I noted above, it isn't an obvious problem, but a subtle one. An edition's worth of subclasses, and the inevitable jury-rigged hacks to fix things will make the problem more obvious.
 

Remove ads

Top