2
\$\begingroup\$

When using the component-based paradigm in game development with engines like Unity, is component-based design an architectural pattern, or a design pattern?

Can I even say that component-based design is my "main" architectural pattern for my game?

I see architectural patterns as being more high-level than design pattern. The component-based design in game development's context (like with Unity engine) seems to fit as an architectural pattern to me. However, on some sites, I read that component-based design is a behavioural pattern, much like other behavioural design patterns, and not so much like an architectural pattern like MVC.

\$\endgroup\$
  • 1
    \$\begingroup\$ If it's a way of arranging data and logic, but not enforcing a particular behaviour (i.e. not telling you what the components should do or what strategies should be used to achieve the goal), then it's gotta be an architectural pattern. \$\endgroup\$ – teodron Nov 18 '12 at 10:07
  • 1
    \$\begingroup\$ Could you provide sources for "some sites"? \$\endgroup\$ – Eric Nov 18 '12 at 13:59
1
\$\begingroup\$

Here's a great question (and answers) on the differences between Architectural Patterns and Design Patterns:

https://stackoverflow.com/questions/4243187/difference-between-design-pattern-and-architecture

According to this (and filtered through my understanding), the component based way of Unity is closer to a design pattern than an architectural pattern.

I believe that because as you say (and I think so too) architectural patterns are more high level than design patterns (i.e. architectural patterns are about the whole system, as viewed from a high level, while design patterns refer to more granular components). As such the architectural level of Unity deals with the fact that you have a game loop, and how that game loop is designed and acts on everything you have in there (entities, physics, collisions, etc). The design level of unity deals with a lower level and more specific part, namely how each of the elements which are just listed in the architectural design is more actually...well.. designed, entities included.

So I guess we can talk about Unity's architecture as being one "specific to"/"good for" a game engine (game loop and the classification of the elements it interacts with in various categories like game objects, physics, collisions, etc), and then we can talk about the design pattern for each of these elements (a game object supports this and that component, it can have behaviors attached to it, etc. In turn the design pattern for the behaviors is "each is an object of a certain class in a certain OO language).

|improve this answer|||||
\$\endgroup\$
1
\$\begingroup\$

An architectural pattern as the wiki states:

An architectural pattern is a general, reusable solution to a commonly occurring problem in software architecture within a given context.

A design pattern as the wiki states:

In software engineering, a software design pattern is a general, reusable solution to a commonly occurring problem within a given context in software design.

Those definitions look nearly identical, so what's the difference?

Point of Confusion

The problem lies in the naming. "Design Pattern" is an extremely broad name, but when we talk of design patterns we typically mean on a smaller scale than architectural.

The Difference

MVC is an architectural pattern because it's a pattern for the entire presentation layer. MVC states that you have a controller that will pass some model (which holds the data) to a view so that it may render. It's a very broad method, that view could be Razor, aspx, php, etc. That controller could do who knows what. It simply states that the architectural layout will be MVC.

On the other hand, the Strategy pattern (which we typically think of as a 'design pattern') usually applies to having multiple algorithms for one action (e.g. You might use the strategy pattern to determine how and/or where you will log information). This could be use with or without MVC as an architectural pattern.

Conclusion

So from my experience and interpretation of definitions, the only real difference is scope of the pattern. Meaning that realistically there is going to be overlap and with how wide-spread the use of the component pattern is in Unity it could easily be referred to as an architectural pattern, though it is traditionally a design pattern.

|improve this answer|||||
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for?Browse other questions tagged or ask your own question.