Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can you explain why BetterBehaviour is deprecated? #88

Closed
TheLouisHong opened this issue Apr 23, 2016 · 10 comments
Closed

Can you explain why BetterBehaviour is deprecated? #88

TheLouisHong opened this issue Apr 23, 2016 · 10 comments

Comments

@TheLouisHong
Copy link

I've been using VFW for a while and it's been my favourite asset. Recently, in my new project I updated to the current version and found out that BetterBehaviour is deprecated along with all the serialization.

Quote

"Please use BaseBehaviour instead. Custom serialization hacks in Unity is fundamentally broken and leads to numerous headaches."

I read through the readme and there has been no updates regarding this deprecation, or why it has been deprecated. Can I get an explaination? I love the asset.

@vexe
Copy link
Owner

vexe commented Apr 24, 2016

I've talked a lot about this.

http://forum.unity3d.com/threads/open-source-vfw-135-drawers-save-system-and-full-exposure.266165/page-10#post-2540908

#84

The runtime/serialization portion of my framework was a very, very bad idea. I had no idea at the time of writing that it is. When I first wrote the serialization part of the framework to support OOP features like polymorphic serialization, generics, interfaces, properties, etc I thought it was 'cool', and useful (in theory).

But as I used it in practice it turned out to be a complete fucking utter disaster. A lot of us came to Unity/game programming from pure business/.NET programming backgrounds (like me) and we found that Unity doesn't support all their languages features, so we start to look for alternatives/hacks/plugins to compensate for the missing features, that's how VFW was born, and how most people came across it. It supported almost every aspect of OOP, not knowing how bad and destructive object-oriented programming is.

My intention of releasing the plugin for free is to help people out. It bothers me to hell and back that it's actually doing the EXACT opposite to them, without them knowing it. As of VFW 1.3.5, I have officially deprecated the entire runtime/serialziation portion of the framework, leaving only the stuff that proved to be useful: the editor/drawers stuff.

The story in short is:

  • Serialization is a fundamentally broken thing in Unity, you do not want to even deal with it let alone hack systems around it. At work, i developed a custom data format where we don't even have a single serializable field or class, we never rely on Unity's .scene file to save our data. We use the editor as a window to our data, not as a tool to create data.
  • If you do try to hack around it and implement custom serialization, it's going to be SUPER slow, unreliable (cause it's based on top of a broken foundation) and very sketchy.
  • Object oriented stuff is bad, super bad. Especially in games where you want everything to be as simple as possible. With a OOP philosophy/mindset you end up with super highly over-engineered code with abstractions created just for the sake of abstractions, objects just for the sake of objects, decoupled systems that didn't need to be decoupled, indirect communications that should have been direct, general-purpose solutions that should have been a lot more concrete and specific, a code flow that's extremely hard to follow and understand, data structures and complexity that is split horizontally across the code base which makes it super hard to reason about the cost of changing things, it's a complete cluster-fuck, it's like when you combine "suck" with "suck" to get a poop sauce. The only thing OOP is good at is sounding like it's a good thing and giving users broken promises.
  • VFW serialization gave the user the ability to go all crazy, you could have an array of lists of interfaces nested in a dictionary and it would serialize! Think about that for a minute, yes it sounds "cool". But in reality, you want your core data structures to be as simple as possible. Having the ability to do that craziness + the fact that users using this are object-oriented people = complicated poop sauce recipe of doom turd. If you're serious about game programming, I would highly recommend you that you get object-oriented programming out of your head, cause trust me, it's nothing but a waste of time. Eventually most programmers quit it, it's just a matter of how many years of your life you'll waste to realize it's a bad idea.

This was my 2 cents on the situation, take it with a grain of salt if you wish, but that was my experience and a lot of fellow developers I know. When I see others doing the same kind of programming I used to do, it makes me sad, and if they were my users, it makes me angry cause I helped participate and facilitate them doing those things. Then I try to talk to them and hopefully correct things, cause I was a victim of OOP lies too.

@vexe
Copy link
Owner

vexe commented Apr 24, 2016

A lot of programmers have recently woken up thanks to Casey's Handmade Hero movement (which I highly recommend) - One of them is Brian Will who made a couple of controversial videos about the subject which I quite liked (https://www.youtube.com/watch?v=QM1iUe6IofM).

I've been programming in a procedural style ever since. You could do it in C# too, via partial classes to get fake a global scope. Very simple programming, data (classes/structs with no methods) and functions that manipulates the data.

@TheLouisHong
Copy link
Author

TheLouisHong commented Apr 24, 2016

Thank you for the long, thoughtful response. Yes, I came from a business development background also, and that's when I used to use VFW. Now I'm a big fan of ECS design, I guess maybe I should change the way I develop. I suggest adding this response to the readme file of this project.

@vexe
Copy link
Owner

vexe commented Apr 24, 2016

Done.

@vexe vexe closed this as completed Apr 24, 2016
@TheLouisHong
Copy link
Author

TheLouisHong commented Apr 24, 2016

Again, thanks for your intentions and I agree on how amazing data driven design is.

Currently, one of my existing projects is based on your asset (BetterBehaviour). Is your depreciation purely because of the code design aspect, or is there something that will break on me?

@vexe
Copy link
Owner

vexe commented Apr 24, 2016

You should be able to use 1.3.4 just fine, which was a relatively solid and mostly bug-free version. But remember you will get those performance hits when you Instantiate BetterBehaviours due to the custom serialization that happens there. Just profile and make sure it doesn't harm your game.

@dcodery
Copy link

dcodery commented Jan 11, 2017

At work, i developed a custom data format where we don't even have a single serializable field or class, we never rely on Unity's .scene file to save our data.

You never rely on Unity .scene file to save any data?
Never use any serializable fileld values in your Monobehaviour component?
Never save any references to GameObjects in a scene? You build/save/reload the GameObject hierarchy in your scene by yourself?

I cannot imagine how your solution looks like. Maybe I misunderstood what you mean.

@philiptolk
Copy link

I am also interested to know what you think about dependency injection and specifically
https://github.com/mlp1802/PowerInjectUnity

as well as what you think about reactive extensions
https://github.com/neuecc/UniRx

@lgarczyn
Copy link

lgarczyn commented Mar 8, 2017

I spent a long time looking for ways to serialize all those crazy data structures, and it never occurred to me that it could be a terrible idea. Thanks for your work and that life lesson.

@StephenWebb
Copy link

I love OOP, there's really nothing wrong with it - I use MVC pattern all the time so people who use my editors to create and modify data can use that data with either monobehaviours or DOTS. I haven't done anything with this system yet and I might stay away after some of the things I've read here. It is a nice idea, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants