presenter

Model View Presenter - Passive View - Who loads the Model?

帅比萌擦擦* 提交于 2020-01-04 01:55:13
问题 I'm curious in using the MVP Pattern to improve testability. I have experience with MVC but MVP seems different. I'm having an application that operates on a 'project' file which is in fact an compressed archive of several files and folders. This project should be my model. Where will I put the code that loads the model? I'm also thinking about another abstraction layer: Some kind of BackEndConnection. It will be able to read a project file. It can be an FileBackEndConnection or an

How does Rails populate the “model_type” field for polymorphic associations?

扶醉桌前 提交于 2019-12-23 12:09:37
问题 I have an Activity model. It belongs_to :parent, :polymorphic => true . Does Rails use parent.class.name , parent.model_name or something else to populate the parent_type field? I want a Presenter to behave like the parent object it wraps, and I need to override the right method. Thanks. 回答1: I'm working with Rails 3.0.7 right now, and the polymorphic type is being defined in active_record-3.0.7/lib/active_record/association.rb , line 1773. def create_belongs_to_reflection(association_id,

uninitialized constant for HomePresenter

僤鯓⒐⒋嵵緔 提交于 2019-12-22 10:45:20
问题 I'm trying to implement a HomePresenter to be used inside the home action of my Pages controller: # app/controllers/pages_controller.rb class PagesController < ApplicationController def home @presenter = Pages::HomePresenter.new(current_user) end ... end # app/presenters/pages/home_presenter.rb module Pages class HomePresenter def initialize(user) @user = user end ... end end My presenter specs pass without errors, but when I run the server and access the home page in Chrome, I get this:

How many presenters should be used in Model View Presenter with Winforms with tabs?

女生的网名这么多〃 提交于 2019-12-22 08:54:47
问题 I have a form with tabs related to a business entity - e.g. a Person has biographical data, address data, etc. Each tab handles input/editing of a category of Person data, and each tab can be saved independently. Should one presenter be used for all tabs, or one presenter per tab? There may also be a main tab, which can navigate to the other tabs (based on category of data selected). 回答1: I create one presenter per view. If each tab is a separate view, then each tab would have it's own

Ruby on Rails patterns - decorator vs presenter

杀马特。学长 韩版系。学妹 提交于 2019-12-17 21:26:33
问题 There is all sorts of talk lately in the Ruby on Rails community about decorators and presenters. What is the essential difference between the two? If there is, what are the clues that tell me which one to use over the other? Or perhaps to use the two in conjunction? 回答1: A decorator is more of a "let's add some functionality to this entity". A presenter is more of a "let's build a bridge between the model/backend and view". The presenter pattern has several interpretations. Decorators are

WPF ViewModel not active presenter

北城以北 提交于 2019-12-11 20:43:19
问题 There is a ViewModel that consists of some related object (nodes and lines( , How it can be possible to display (synchronize) these VM in View and keep object connections. I use some DataTemplate to map model to view but each object would be synchronized (with powerful binding) to its related object but how can i link (and synchronize) this DataTemplate generated UI element together. I describe problem from another viewpoint here: Sunchronizing view model and view 回答1: To keep your view

Cannot resolve current top activity while showing viewmodel using mvvmcross

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-11 08:48:00
问题 I'm implementing a custom presenter in my Mvvmcross application. What I wanted to accomplish is: regular navigation and fragment navigation. In my main activity, I managed to embed several fragment views based on this example: https://github.com/i486dx400/MultiRegionPresenter while the fragments are working, I also wanted to show regular activities, that aren't hosted as a fragment. Therefor I extended this presenter as shown in this snippet: https://gist.github.com/JelleDamen/7003702 The

Name conflict between controller name and presenter namespace

坚强是说给别人听的谎言 提交于 2019-12-10 11:41:44
问题 I am using the presenter pattern and am seemingly running into inconsistent class naming conflicts. I have a pages controller with a homepage method and I'd like to have that method use the Pages::HomepagePresenter class, but end up with the error: uninitialized constant ActionController::Caching::Pages::HomepagePresenter # ./app/controllers/pages_controller.rb:3:in `homepage' # ./spec/requests/pages_spec.rb:14:in `block (5 levels) in <top (required)>' Assuming the problem is with the Pages

《android-MVP模式的困惑》

两盒软妹~` 提交于 2019-12-06 06:48:03
什么是MVP模式呢?我的理解就是老的MVC架构模式的一种延伸,能体现一种面向接口编程的思想。之所以会有MVP,是因为MVC中,C即Controllor对应于Activity或者Fragment。他们负责的东西太多了。比如:控件的初始化,网络请求,数据绑定,事件传递等。这显得我们的Controllor太过于臃肿(即又当C又当V)。而为了给Controllor减轻负担,于是就有了Presenter这个一个中间层,让Presenter负责完成View于Model间的交互。这有点像Web开发中的Service,什么业务逻辑都放在这里来处理,然后再与Action交互。 在网上也看到了很多图形来解释MVP与MVC的区别,如下: 这是mvc: 这是MVP: 主要区别是这样的: 还有就是真个项目的结构图: 通过上面的几个图我们不难发现,MVP模式中Presenter在这整个模式中显得很重要,那么问题来了(这也是我没用想明白的事情): 1、Presenter通过接口的方式提高了代码的复用性,降低了耦合度,但是如果业务非常复杂的时候Presenter层会不会也会像MVC模式中的Activity一样显得很臃肿。 2、Presenter既然负责完成View于Model间的交互,那么它的生命周期怎么去控制。 3、Presenter层的出现,虽然降低了耦合度,但是相对于MVC来说代码量会增加部分

Using rails presenters - memoizable getting deprecated in 3.1 - use ||= instead?

ぃ、小莉子 提交于 2019-12-04 22:56:58
问题 Issue: To avoid creating multiple objects or multiple queries when possible. I am using Presenters with rails as a Best Practice. I am following advice that says that it would be good to use "extend ActiveSupport.Memoizable" (and then memoize :method(s) to use them) over setting up items with @the_record = record ||= @record style because of a couple of issues - false or nil not getting stored so the query gets called again and also that memoizable uses the cache better (i.e. uses it!).