Do you use design patterns?

后端 未结 15 2088
盖世英雄少女心
盖世英雄少女心 2020-12-23 09:56

What\'s the penetration of design patterns in the real world? Do you use them in your day to day job - discussing how and where to apply them with your coworkers - or do the

15条回答
  •  独厮守ぢ
    2020-12-23 10:46

    Yes. Design patterns can be wonderful when used appropriately. As you mentioned, I am now using Model-View-Controller (MVC) for all of my web projects. It is a very common pattern in the web space which makes server-side code much cleaner and well-organized.

    Beyond that, here are some other patterns that may be useful:

    • MVVM (Model-View-ViewModel): a similar pattern to MVC; used for WPF and Silverlight applications.

    • Composition: Great for when you need to use a hierarchy of objects.

    • Singleton: More elegant than using globals for storing items that truly need a single instance. As you mentioned, a simple pattern but it does have its uses.

    It is worth noting a design pattern can also highlight a lack of language features and/or deficiencies in a language. For example, iterators are now built in as part of newer languages.

    In general design patterns are quite useful but you should not use them everywhere; just where they are a good fit for your needs.

提交回复
热议问题