Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Octo_jale · Jun 21, 2018 at 12:34 PM · architecture

Clean architecture or ECS Architecture or both ?

Hello,

I use unity to realize AR/VR projects and I wonder how to make code maintainable and unit testable. I'm learning about the clean architecture (uncle bob, software craftmanship, ...) and the ECS (entity-component-system) architecture.

Is one of them more suited to unity? What are the differences between the two? both are compatible ?

Are there other similar architecture?

Thanks for answer ! =)

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by JVene · Jul 19, 2018 at 10:15 PM

Unity's own component oriented design already says "Entity Component System", which I'd say is a hint.

Clean architecture appears to me to be an architectural version of the same philosophical and practical motivations behind object oriented programming, and the subject overlaps in my view. The idea of objects is exactly that of avoiding coupling, to separate functionality into testable units, and more.

I'm not convinced that the "Clean Architecture" paradigm is as of yet fully fleshed out. The earliest references are only a few years old, though in this industry even 7 years is nearly ancient to some minds. Industrial notions, like operating systems, platforms and frameworks, change rapidly. More thoughtful, scholarly paradigms, like object oriented programming itself, takes much longer because it is a more academic and logical exercise, requiring time to collect empirical data and prove the results. Since I view "Clean Architecture" as an architectural level version of object oriented programming (which works all the way down to very small expressions of code), I'm not convinced it is actually anything new.

That said, one of the very tenets is violated at first look: Unity requires that you use its framework. That defines a dependency. Much of the beginning of any code you write in Unity begins by deriving from MonoBehaviour, which is a very deep kind of dependency. I prefer such classes be small and limited; consumers of classes external to Unity's framework for anything more than simple behavioral modifications of GameObjects. This is as much and object oriented design notion as it is an architectural notion.

I find most posting questions here are beginning their study of Unity and learn C# from that perspective as they work, so their viewpoint is entirely the opposite of your question. Indeed, many seem to think that the script is a central programming concept, without acknowledging that it is actually the class they're describing.

To think in terms of application development, of architecture and design patterns is far more appropriate when the target is ambitious, but then many of these projects are FPS, platform or other typical game designs, so they only have interest in controlling the camera, player movement, object behavior and appearance, or special effects. Most depend upon Unity's architecture and framework, seeking only to extend functionality as tutored by modifying Update, Start or creating co-routines.

With respect to unit testing, you have to consider that if the classes we're writing are derived from Unity's framework (MonoBehaviour), they can't be isolated. For unit testing to really work you should be able to build a stand alone application that incorporates the class or classes to be tested, driven by a small main program that runs the test. This shows the classes are not dependent on anything (or at least what they are dependent upon, like the STL for example), and that they work under all tested modes of operation. You can't do that with MonoBehaviour derived objects in a stand alone console application, so you have to build a Unity game for that. However, when classes comprise some service, system or complex feature (like AI, audio processing, specialized memory managers, etc), they can be written entirely independent of the Unity framework, tested, then consumed from a Unity application by incorporating the tested source.

This, too, is very much in line with the original tenets of object oriented programming. Unless you have quite an ambitious target in mind, but are making something typical of a Unity based game, the architecture is all but defined by Unity already. If, however, you consider Unity merely the rendering component of a far more ambitious application, you'd design and build the application from that viewpoint, defining specific points of attachment to the Unity design and framework, built, subsequently, as a Unity solution. In that mode you'd have a choice of architectures.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

86 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

mac app store build architecture... intel only? 1 Answer

Is it a good idea to use static classes? 0 Answers

Game Won't Build In x86 0 Answers

Any Asset for building floor plan + 3D in runtime? 1 Answer

Why does scripting backend slow down android app? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges