lundi 18 septembre 2023

Head First Design Patterns in p.543, What is The last question's answer? -> Design pattern to separate Model and View perfectly [closed]

I am reading chapter 12 "Compound patterns (MVC)" in Head First Design patterns second edition. On p.543, there is a Q&A, the last question of which is

Q: The view is not supposed to manipulate the model; however, I noticed in your implementation that the view has full access to the methods that change the model's state. Is this dangerous?"

the author writes

You are correct; we gave the view full access to the model's set of methods. We did this to keep things simple, but there may be circumstances where you want to give the view access to only part of your model's API. There's a great design pattern that allows you to adapt an interface to provide only a subset. Can you think of it?

I can't think of that design pattern. Can anyone tell me what it is?

Given the structure of this document, it should always be one of the following patterns. Observer Decorator Factory Singleton Command Adapter and Facade Template Method Iterator and Composite State Proxy

Huu... Adapter pattern?

Aucun commentaire:

Enregistrer un commentaire