in a définition of a widget, what is a better practice, and why, use the widget himself or the type “higher”, example, it’s a better practice to do
1) Button myButton;
or
2) Hastext myButton; (and set a button later)
thanks for your answer.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The answer to that lies in the Model-View-Presenter pattern, that was introduced in last years Google IO presentation by Ray Ryan. There’s also an official tutorial/docs – part 1 and part 2. There are also a number of questions here on SO that cover that topic 🙂
And a quick answer to your question (that will make more sense once you get familiar with MVP): use interfaces in the Presenter and their implementations in the View 🙂 That way your Presenter stays oblivious to the underlying implementation/Widget you actually used (was it a
Button? Or aLabel? It doesn’t matter, they both implementHasText).