Learn English The Hard Way

原著阅读 - Android Programming The B

2017-09-26  本文已影响27人  几千里也

Page 213 - Tuesday, 26 September 2017

Benefits of MVC

An application can accumulate features until it is too complicated to understand. Separating code into classes helps you design and understand the application as a whole; you can think in terms of classes instead of individual variables and methods.

Similarly, separating classes into model, view, and controller layers helps you design and understand an application; you can think in terms of layers instead of individual classes.

MVC also makes classes easier to reuse. A class with restricted responsibilities is more reusable than one with its fingers in every pie.

Notice that you use the escape sequence ' in the last value to get an apostrophe in your string. You can use all the usual escape sequences in your string resources, such as \n for a new line.

Take a moment to put this code into a private method instead, as shown in Listing 2.9.

Now that you have the questions behaving appropriately, it is time to turn to the answers. At the moment, GeoQuiz thinks that the answer to every question is “true.” Let’s rectify that. Here again, you will implement a private method to encapsulate code rather than writing similar code in two places.

上一篇 下一篇

猜你喜欢

热点阅读