Always when I see Java code and "best practices", I always wonder how people can still use such a verbose and limited language (and paradigm). Let's express your example in Haskell:
{-# LANGUAGE ConstraintKind #-}classCanSwimawheredoSwim::a->IO()classCanGreetawheredoGreet::a->IO()instanceCanSwimDogRobotwheredoSwim=dogSwiminstanceCanSwimSharkRobotwheredoSwim=sharkSwim-- ...typeRobot=(CanSwima,CanGreeta,CanFlya,CanWalka)
No need for complex class hierarchies, you simply have a few functions following an interface (type class). A robot then is just the composition of the type classes.
No, Java is limited as a language. OO is verbose and leads to unnecessary abstractions (read: convoluted class hierachies).
E.g. your example:
In haskell: A bunch of functions that follow an interface (1 level)
OO: Robot class, subclass, Behavior interface, behavior implementation (4 levels)
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Always when I see Java code and "best practices", I always wonder how people can still use such a verbose and limited language (and paradigm). Let's express your example in Haskell:
No need for complex class hierarchies, you simply have a few functions following an interface (type class). A robot then is just the composition of the type classes.
Object oriented programming is a limited paradigm to express certain behaviors?
No, Java is limited as a language. OO is verbose and leads to unnecessary abstractions (read: convoluted class hierachies).
E.g. your example:
In haskell: A bunch of functions that follow an interface (1 level)
OO: Robot class, subclass, Behavior interface, behavior implementation (4 levels)