Object-oriented programming is an extremely bad idea that could only arise in California.
- Edsger Vibe Dijkstra
Perhaps these are just my feelings, but
object-oriented programming seems to be the standard, most common software design paradigm. It is usually taught to students, explained in online tutorials and, for some reason, used spontaneously even when they were not going to do it.
I know how attractive she is, and how wonderful this idea appears on the surface. It took me many years to destroy her charms, and now I understand how terrible she is, and why. Thanks to this point of view, I have a clear conviction that people must realize the fallacy of the PLO and know the solutions that can be used instead.
')
Many people have previously discussed the problems of OOP, and at the end of this post I will give a list of my favorite articles and videos. But first I want to share my own opinion.
Data is more important than code
. , .
, :
-> ->
. ! , , : , . . , , .
, ,
, . , .
Customer
?
class Customer
. ?
class RenderingContext
.
«» , , , . . .
, .
, .
FizzBuzz Enterprise Edition — , .
, — . . - , .
, . .
class Customer
class Order
, .
class OrderManager
Order
,
Customer
. , , .
, , , .
- , - , , , .
Context
, - , , - Enterprise.
, . :
class Player
hits()
class Monster
, ?
hp
Monster
attackPower
Player
;
xp
Player
Monster
Monster
.
Player.hits(Monster m)
Monster.isHitBy(Player p)
?
class Weapon
?
isHitBy
Player
currentWeapon()
?
. , , — . , , Enterprise.
:
— , , . .
, , ( ). : , , , , , . : , .
— ,
ADT, . , , , .
, , , API .. «»/«»/«». , (Java/Scala) / . , , , , , .
-
: , — (). .
, , , , , , . , .
- . , , , . .
, , . .
?
, « », , .
. , , , . , : ( , ) ..
, . ,
DataStore
API, . ADT/PoD, ID (, uuid ). :
Vec
HashMap
Index ID, «», , . , LRU .
DataStore
. . : stdin, , trust manager, .. «» , .. «»
DataStore
.
:
DataStore
, .
: , , , , ,
Customer
. :
Customer
—
DataStore
, «-» .
, — . , / . , :