3 ms·
Same reaction but different type of project and language. Immutable data with persistent data structures was a game changer for me. There is place for OO but it
by EastLondonCoder 8y ago
Same reaction but different type of project and language. Immutable data with persistent data structures was a game changer for me. There is place for OO but it does feel like the last 20 years our profession has been suffering from collective insanity.
- edwinyzh 8y agoTry code large a GUI project without OO.
- lallysingh 8y agoThe model is a data structure and the view is a series of functions on it. The rest is convenience and interface state (render cache, undo stack, etc). Have a look at functional reactive programming.
- ilovecaching 8y agoAs the other commenter already pointed out, functional reactive programming wiped the floor (React) of OO style approaches to GUI design. It turns out thinking about interfaces is made considerably easier with one way data flow.
- Const-me 8y agoIf you’ll open https://reactjs.org/ https://reactjs.org/ you’ll read right on their main page: > Build encapsulated components that manage their own state, then compose them to make complex UIs. Components managing their own state is a textbook definition of OOP. They even use inheritance in their example on the main page: > class HelloMessage extends React.Component
- rhinoceraptor 8y agoReact isn't really object-oriented. Components rarely pass messages to each other. Instead, the way that data flows is through function/constructor arguments. You can directly invoke a method on a component, but that's only really used as an escape hatch. It's inconvenient, and IMO, a code smell. For the React that I write, class components are used only when there's some trivial local state that I don't want to put into Redux (e.g. button hovering that can't be done in CSS), or when I need to use component lifecycle methods. And yes, class components do inherit from React.Component, but they specifically discourage creating your own component base classes.
- Const-me 8y ago> React isn't really object-oriented. I don't do web development but I've read react API docs and user guides. Objects calling other objects is optional for OOP, I never saw a definition that requires them to do. OOP is about code and data organization. Objects and methods are everywhere in react. Some are very complex. Just because it uses a few lambdas doesn't mean it's not OOP. For reference, here's now a non-OOP GUI library may look like: http://behindthepixels.io/IMGUI/ http://behindthepixels.io/IMGUI/ As you see not only it's hard to use, it doesn't scale. Like it or not, OOP is the only way to deal with complex state invented so far. Even in functional languages: https://medium.com/@gaperton/let-me-start-from-the-less-obvious-thing-7f49e87a45ca https://medium.com/@gaperton/let-me-start-from-the-less-obvi... And modern rich GUIs have very complex state.
- hcarvalhoalves 8y ago> Objects calling other objects is optional for OOP, I never saw a definition that requires them to do. OOP is about code and data organization. Smalltalk, which is the prototypical OO language, does the exact opposite of everything you said (all computations happen by message passing and all members are public).
- Const-me 8y ago> does the exact opposite of everything you said No it doesn’t. > all computations happen by message passing I did not say message passing is required to be not present, I said it’s optional. > and all members are public I did not say anything about encapsulation. I said OO is about organization of code and data. If you have classes with properties and methods, it’s OOP.
- edwinyzh 8y agoCalling a function of another component is a way of passing a message to another object, no matter what that message is, be it the data flows you mentioned, or anything else.
- miki123211 8y agoFacebook is written in React. React is (almost) without oo. There are web and mobile guis written in React. Native aren't, yet, but that's mostly because it's young and there are no libraries for that.
- edwinyzh 8y agoThis is a reply to @lallysingh (sorry I'm replying after your post is too old to get directly replied :) Re "The model is a data structure and the view is a series of functions on it." This is exactly how I see my OO-based GUI programs. The object I define is firstly a data structure. Then I want some operations/views on it? define methods on it.