class Number { //or extend the Integer class and add your methods
int num = 0;
inc() {
this.num +=1
}
}
class Tracker {
Number trackingId;
}
class Building {
Number height;
}
t = Tracker()
t.height.inc()
b = Building()
b.height.inc()
All OOP does is really give you a way to group state and methods, how you use it is up to you. There is a reason almost all big software is written this way and not in Lisp.
Do you see the problem? What you wrote is the problem with oop. Gotta tear your whole program apart and rewrite it. You had to create new things and rewrite your methods.
With functional you don’t rewrite. You recompose what you already have.
It means oop is not modular. You didn’t create modules that can be reused. Nothing could be reused so you had to reconfigure everything.
Class Number {
}import static Number.inc
Class Tracker {
}class Tracker extends Numbers {
}Or
interface Number {
}class Tracker implements Numbers {
}Or my pick
class Number { //or extend the Integer class and add your methods
}class Tracker { Number trackingId; }
class Building { Number height; }
t = Tracker()
t.height.inc()
b = Building()
b.height.inc()
All OOP does is really give you a way to group state and methods, how you use it is up to you. There is a reason almost all big software is written this way and not in Lisp.