Visit He Honghui: Talk about the design pattern in Android source code

Source: Internet
Author: User

Recent Android 6.0 version of the source code is open to download, just analyze the Android source technology book "Android source design mode analysis and actual combat" listing, we invited its author He Honghui, to talk about the Android source design patterns, And some of the hot topics in recent Android development.

Invited guests to introduce:

He Honghui (@MrSimp1e), former friends of the Android engineer, active in the domestic major technical communities, love Open source, love technology, love to share. Android Open Source Library Androideventbus, colorful author, development technology front-line webmaster, "Android source design mode analysis and actual combat" author.

InfoQ: Congratulations on the publication of your new book, I see a project on GitHub with the same title, what is the content production model of this book?

He Honghui: In fact, I have planned this book very early, the idea was born before I joined the work, because there is really no such works in the country. It was just a lack of ability and seniority, so I buried it in my heart.

April 2014 I began to publish in the blog "Android Source Analysis design mode" series of articles, slowly set up the embryonic form of the book. Active in the open source community at the end of 2014, it occurred to the February 2015 that it was possible to create a project on GitHub that would allow more people to participate in the form of open source, share their insights into the model, or put the software design to the attention of all.

In order to reduce my personal number of articles in the project, I recommend the analysis of the material to other participating students, let them to write, so as to enhance the enthusiasm of everyone. At the same time, I as the entire series of reviewers to grasp the quality of the article. After one months of efforts, Android source design mode analysis of the GitHub project officially released, once released by the industry's wide acclaim. I was encouraged by this, so the idea of publishing came to me again.

Because the first book published, the seniority is still shallow, specially invited Guan teacher and I wrote this book. In the book we rewrite all the chapters, and in depth and difficulty are significantly higher than the open source articles on GitHub. As a result, there is a big gap between the articles on GitHub and the content in the book.

InfoQ: There are a lot of classic books about Java design patterns, why do you want to write the design mode of Android source code?

He Honghui: Books in Java design patterns are often only used in the Java language to explain design patterns, not into a system to dissect design patterns. This kind of books is to teach the reader what is the design pattern, and our books in addition to teach the reader what is the design pattern, but also in-depth analysis of the Android source design patterns in the application, so that the reader from the specific code to understand the use of design patterns, the role of real understanding of the beauty of software design.

InfoQ: How do you read and analyze Android source code, and what are the useful tools?

He Honghui: Because I analyze the source code is only the analysis of specific parts, so there is no high demand for tools, easy to search and jump. So just by Sublime Text 2, install the plugin can easily read the code, Atom is also a good choice.

InfoQ: Recent Android 6.0 source is open to the outside, what are you interested in this update?

He Honghui: For 6.0 I have no focus on, after all, for Android application development, the user device system updates are not as timely as iOS. But the new features of app Permissions, Android pay, and app links in 6.0 are noteworthy, and these new features are relatively relevant for application development. What I really care about is that the entire ecosystem of Android is growing, and there's a lot of progress in smart cars, smart watches and IoT platforms, which is the best news for people who work with Android.

InfoQ: Which design patterns are most common in Android development? Which design patterns have been misunderstood most?

He Honghui: Gof's "Design model: The basis of reusable object-oriented software" summarizes 23 design patterns, but in the development of the more commonly used is the singleton, Builder, adapter, observer, abstract factory, appearance, template method, strategy of the design patterns. Learning anything is not mechanically, and design patterns are more so. It is the original intention to put forward the design pattern to solve the problem by using the design pattern summarized by predecessors in the suitable scene.

When it comes to the most misunderstood design patterns, there are two patterns of factory methods and abstract factories, both of which are commonly used design patterns and are relatively simple. The reason for the misunderstanding is that the two patterns are confusing, for example, there are two questions: what are their roles and what are their differences? If you don't have a definitive answer, you should go back to the book.

InfoQ: What do you think of the responsive programming model when you have more research on Rxjava in Android development recently?

He Honghui: Responsive programming is a great way to simplify code and improve the readability and stability of your code. The Development technology front also translated several high-quality articles about Rxjava. But the problem with Rxjava is that the library is too large, and the size of over 700KB makes me a bit unacceptable. Therefore, if you want to use responsive programming to simplify some of the code, you can refer to the article "Notrxjava Lazy Man's Guide" to create a simple Rx library. This allows for more in-depth understanding of responsive programming, as well as realizing the principle of implementing responsive programming and improving your technical capabilities.

What are some of the classic architectures in the Infoq:android source code, and what are their benefits?

He Honghui: The most intuitive layered architecture and microservices architecture in Android. The Android architecture we see most often is a typical layered architecture, which is divided into application layer, framework layer, native layer and kernel layer. The upper layer is the lower end of the call, the lower layer to provide services, each level represents a function of the application, each layer of responsibility is relatively single, so that the system is more modular and testability.

Another obvious architectural pattern is the microservices architecture. The micro-service architecture is embodied in the design of the system service and the framework layer. The Android system will start Activitymanagerservice, Packagemanagerservice, Windowmanagerservice and other system services, when the user performs the operation, Requests are made to the corresponding service through the framework layer, and the specific service responds after the instruction is received. In this way, the framework and these system services form a microservices architecture that communicates through binders, decoupling and increasing flexibility and scalability.

There are a lot of classic architecture patterns in large applications like Android, and you can find examples of these good applications based on clues from the source of the Android system.

InfoQ: Can you talk about the pros and cons of the MVP/MVVM architecture in Android development? What is its usage scenario?

He Honghui: MVP and MVVM are better application architectures in Android, with the advantage of being able to reduce coupling, improve application module testability, and to some extent avoid overly complex fragment, activity types, making the entire software architecture easier Clear. Their shortcomings are mainly the responsibility of a relatively thin, so there will inevitably be many types. For example, an activity, need to have model, view, presenter three elements, these three elements are also sub-interface, implementation class, the page more than a variety of model, view, presenter type of miscellaneous up. Of course, through reasonable subcontracting can also alleviate the negative impact of this problem to a certain extent. As a result, MVP, MVVM is a great choice if you want to make your application architecture more flexible, scalable, and easy to test.

InfoQ: What are your learning or writing plans?

He Honghui: After the completion of the "Android source design mode analysis and actual combat" I immediately began to write another book, "Android Development advanced-from small to expert." The book is positioned as a second book to learn about Android development, which begins with an in-depth look at the core knowledge points of Android development, including view and animation, networking, multithreading, and database, and then introduces key points of knowledge such as unit testing, code specification, versioning, refactoring, architecture, etc. So that the reader in-depth technology at the same time broaden their horizons, can be more professional design of application software, complete from only the function of "code farmers" to software engineers, designers transition. "Android Development advanced-from small to expert" is expected to be listed before December 31, 2015, we hope you will support.

These two books are the two years I want to write all the content, after the completion of these two books, I can also calm down for further study. Constantly add knowledge, update knowledge, in order to keep pace with the industry, the heart can also be satisfied. Finally, I hope that we have a lot of feedback to my suggestions, a lot of exchanges and common progress.

Visit He Honghui: Talk about the design pattern in Android source code

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.