getter

<h:dataTable value=#{myBean.xxx}>: getXxx() get called so many times, why?

馋奶兔 提交于 2019-12-18 18:10:10
问题 Simple piece of code about dataTable . CentralFeed is SessionScoped Bean, and PostComment is RequestScoped Bean <h:form id="table"> <h:dataTable value="#{CentralFeed.profileComments}" var="item"> <h:column> <h:outputText value="#{item.comment}"/><br/> <h:inputTextarea value="#{item.newComment}" rows="2"/><br/> <h:commandButton value="Post" action="#{PostComment.postReply(item)}" /> </h:column> </h:dataTable> </h:form> inside CentralFeed.java private List<NewsFeed> profileComments = null;

Rhino Mocks AssertWasCalled (multiple times) on property getter using AAA

走远了吗. 提交于 2019-12-18 12:43:18
问题 I have a mocked object that is passed as a constructor argument to another object. How can I test that a mocked object's property has been called? This is code I am using currently: INewContactAttributes newContact = MockRepository.GenerateMock<INewContactAttributes>(); newContact.Stub(x => x.Forenames).Return("One Two Three"); someobject.ConsumeContact(newContact); newContact.AssertWasCalled(x => { var dummy = x.Forenames; }); This works except when within the "someobject" the getter on

Encapsulation and Getters

♀尐吖头ヾ 提交于 2019-12-18 07:08:23
问题 I was reading this article on why getter and setters are evil. The article doesn't say not to use them ever, but, it's telling you to think in a way that limits the use of those methods, or to quote the article: Don't ask for the information you need to do the work; ask the object that has the information to do the work for you. what happens when you need to display data in a GUI, but don't have getter methods? The article covers this briefly, but not fully. It mentions passing a JComponent

How to define dynamic setter and getter using reflection?

旧时模样 提交于 2019-12-18 03:18:19
问题 I've a list of strings, field names, of a class in a loop from resource bundle. I create an object and then using loop i want to set values for that object. For example, for object Foo f = new Foo(); with parameter param1, I have string "param1" and I somehow want to concate "set" with it like "set"+"param1" and then apply it on f instance as: f.setparam1("value"); and same for getter. I know reflection will help but I couldn't manage to do it. Please help. Thanks! 回答1: You can do something

What should a C++ getter return

£可爱£侵袭症+ 提交于 2019-12-17 22:13:13
问题 What is the best practice for a C++ getter method which is supposed to return a non trivial type, but a member which is of type class, or struct. Return by value, such as: MyType MyClass::getMyType() { return mMyType; } Return by const reference: const MyType& MyClass::getMyType() { return mMyType; } Return by address: MyType* MyClass::getMyType() { return &mMyType; } where class MyType { /* ... */ }; class MyClass { private: MyType mMyType; } I specifically worry about the following usages

Getter and setter, pointers or references, and good syntax to use in c++?

佐手、 提交于 2019-12-17 15:42:18
问题 I would like to know a good syntax for C++ getters and setters. private: YourClass *pMember; the setter is easy I guess: void Member(YourClass *value){ this->pMember = value; // forget about deleting etc } and the getter? should I use references or const pointers? example: YourClass &Member(){ return *this->pMember; } or YourClass *Member() const{ return this->member; } whats the difference between them? Thanks, Joe EDIT: sorry, I will edit my question... I know about references and pointers,

When to use JavaFX properties setter and getter, instead of using the property directly

 ̄綄美尐妖づ 提交于 2019-12-17 12:30:11
问题 I am familiar with Java, but just starting to learn JavaFX, and specifically learn about JavaFX properties. I understand the basic design pattern as shown in the following example from Oracle: package propertydemo; import javafx.beans.property.DoubleProperty; import javafx.beans.property.SimpleDoubleProperty; class Bill { // Define a variable to store the property private DoubleProperty amountDue = new SimpleDoubleProperty(); // Define a getter for the property's value public final double

Conventions for accessor methods (getters and setters) in C++

和自甴很熟 提交于 2019-12-17 07:09:56
问题 Several questions about accessor methods in C++ have been asked on SO, but none was able satisfy my curiosity on the issue. I try to avoid accessors whenever possible, because, like Stroustrup and other famous programmers, I consider a class with many of them a sign of bad OO. In C++, I can in most cases add more responsibility to a class or use the friend keyword to avoid them. Yet in some cases, you really need access to specific class members. There are several possibilities: 1. Don't use

Allen Holub wrote “You should never use get/set functions”, is he correct? [duplicate]

半城伤御伤魂 提交于 2019-12-17 05:40:21
问题 This question already has answers here : Why use getters and setters/accessors? (38 answers) Closed 4 years ago . Allen Holub wrote the following, You can't have a program without some coupling. Nonetheless, you can minimize coupling considerably by slavishly following OO (object-oriented) precepts (the most important is that the implementation of an object should be completely hidden from the objects that use it). For example, an object's instance variables (member fields that aren't

Allen Holub wrote “You should never use get/set functions”, is he correct? [duplicate]

南笙酒味 提交于 2019-12-17 05:40:18
问题 This question already has answers here : Why use getters and setters/accessors? (38 answers) Closed 4 years ago . Allen Holub wrote the following, You can't have a program without some coupling. Nonetheless, you can minimize coupling considerably by slavishly following OO (object-oriented) precepts (the most important is that the implementation of an object should be completely hidden from the objects that use it). For example, an object's instance variables (member fields that aren't