###### tags: `Guide To Contibuting`
# Object Oriented Programming
BYOND is an object oriented language and we fully take advantage of that (as we should) to reduce code copypasting where unneeded.
You can read Wikipedia for what object oriented means but this means that the game for the most part are held in objects which inherit from each other.
- Sometimes, some of the more black-magic-type coders might ignore this and copypaste a big section of code for performance reasons
- Do as they don't, not as they do. This is unnecessary 99.9% of the time.
- Inheritance
- Objects/datums/types can be defined to be aa subtype of another type and it will inherit the vars (variables) and procs/verbs (procedures) from its parent
- This goes all the way up the chain to `/datum`
- Inheritance is single inheritance. An object can only inherit from one other thing. There's no interfaces either (if you don't know what that is don't worry about it, it's a concept in a lot of other languages).
Examples:
```DM
/datum/my_parent
var/number = 3.5
var/string = "test_string"
/datum/my_parent/proc/print_test()
world.log << "This Is A Test"
/datum/my_parent/my_child
var/other = 143
var/global/datum/my_parent/test_parent = new
var/global/datum/my_parent/my_child/test_child = new
```
`world.log << test_parent.number` => `3.5`
`world.log << test_parent.string` => `"test_string"`
`test_parent.print_test()` => `"This Is A Test"`
`world.log << test_child.number` => `3.5`
`world.log << test_child.string` => `"test_string"`
`test_child.print_test()` => `"This Is A Test"`
- Inheritance, obviously, cannot go both ways.
`world.log << test_child.other` => `143`
`world.log << test_parent.other` => Compile error: `other` is not a defined variable in `test_parent`.
- Overriding
- Inherited fields (variables or procs) can be overridden by the child by redefining it without the var/declaration or /proc/ declaration for procs.
- Static variables can **not** be overridden properly. Only one copy exists for the parent and all its children. It's pointless to override it.
```DM
/datum/my_parent/my_child
number = 1000
string = "ayy"
/datum/my_parent/my_child/print_test()
world.log << "Other Test"
```
`world.log << test_child.number` => `1000`
`world.log << test_child.string` => `"ayy"`
`test_child.print_test()` => `"Other Test"`