Fiction subclasses reality, overriding certain methods and implementing the interfaces of genres. I touched in a post yesterday on the boundaries of the fiction within a story, the fact that fictional introductions in storytelling help us to define what to suppose is different about the fiction, whether that is that Mr X is Prime Minister, that Ms Y lives at No.13 Newgate Road, or that fish can swim in the air.
In object oriented programming objects are defined by classes whose interfaces describe what they can do (the methods that can be called on them); if well designed the classes should encapsulate their responsibilities.
One of the powerful paradigms is inheritance, where a subclass can inherit everything from a class except those methods overridden by implementing differently – and new methods can be added. So fictional works “subclass” reality in the sense that most of reality will be inherited, but certain elements (events, characters, physical laws) will be overridden and implemented in a new way.
This concept can also take into account the relationship that exists between fictional works, since one work can subclass another (perhaps particularly, but not exclusively, within shared universes). And genre fiction could be seen as implementing interfaces: the genre defining methods which must be implemented which are the expectations of science or crime fiction, and the variables are the aliens, victims or suspects.
Sometimes authors follow design patterns which describe reusable solutions to common problems, and we recognise these as conventions or formulae, they are useful shortcuts to reference points for the reader.
So, for example…
public class AirFish extends Fish {
public void swim() {
this.swimIn = air;
super.swim();
}
(I like air fish. Air fish are cool.)