Implementing standard software design patterns (focus on MVC) in R

后端 未结 1 645
南笙
南笙 2021-01-30 06:37

Currently, I\'m reading a lot about Software Engineering, Software Design, Design Patterns etc. Coming from a totally different background, that\'s all new fascinating stuff to

1条回答
  •  北恋
    北恋 (楼主)
    2021-01-30 07:11

    1. It looks quite good, but I'm not so sure why you have an Observer additional to your other classes (maybe you can tell me) Usually the Controller IS an Observer. It's a really good idea to do this in R because when I learned it in Java it was not so easy to understand (Java hides some of the good parts)

    2. Yes and No. There are many different interpretations of this pattern. I like to have the methods in the Object, I'd say it belongs to the model. A simple example would be a sudoku solver that shows the solving steps in a GUI. Let's split it into some parts that can be separated into M, V and C: the raw data (2D array maybe), the sudoku functions (calc next step, ...), the GUI, someone who tells the GUI that a new step was calculated I'd put it like this: M: raw data + sudoku functions, C: who tells the GUI about changes / the model about GUI inputs, V: GUI without any logic others put the sudoku function into the Controller, is also right and might work better for some problems

    3. It's possible to have a "one way" controller like you call it and the View is an Observer of the model It's also possible to let the Controller do everything and Model and View don't know each other (have a look at Model View Presenter, that's about that)

    0 讨论(0)
提交回复
热议问题