📜 ⬆️ ⬇️

Great interview with Hannes Dorfman, creator of Mosby framework for Android

June 2 at the Moscow office of Yandex will be the next Droid Party. This time Hannes Dorfman will share his experience. To many of you, he is known as a developer of the Mosby framework for Android. Hannnes has spent a lot of time researching approaches to Android architecture.

In the run-up to the event, we asked Hannes to answer questions that we gathered from developers inside Yandex. The interview turned out great and interesting. We discussed the future of programming languages, got a lot of application tips and even remembered the already legendary Nokia models. Read more under the cut.


')
For those who can not get to the Droid Party, we traditionally organize the broadcast, which can be viewed here . You can also register for the event. And those who live in St. Petersburg will be able to participate in a teleconference in our St. Petersburg office.

As usual, you can ask your questions in the comments - we will pass them on to Hannes, and he will answer them at the Droid Party.

Interview in the original, for those who prefer to read in English (Russian version)
How did you start to code for Android?

I was always fascinated by mobile app development. I developed my first “app” app. I also had a pocket pc running Windows CE to hack around. Hence, I was excited when I’ve come out, but I can’t really say it. I am programmed for Android for the first time (Android 1.5 - cupcake) when I’ve been in college in the summer of 2009; findViewById () thing. I’ve seen it’s not been working anymore in late 2009. It was a hardware keyboard on my device. I couldn't imagine the long text on the screen. There were two options: Motorola Droid (Milestone) running Android 2.0 or Nokia N900 running Maemo. I’ve been using the Motorola Droid, I’m not really the most important thing on earth :) I had for Android 2.0 (for personal only).

Architectural solutions from JS?

There is a bottom line for developers. A greenfield. It is a world war jordan. It’s not worth it. like Android too. It is a way to reinvent the wheel. It has been shown that it has not been tampered with.

Does it have a different approach or another cross-platform approach?

Good question. I'm not sure. I’m not thinking about how to do it or not. Regarding React Native, I believe that I would like to be able to write it, even though Facebook did not need it. I couldn’t have to do it. However, I’m not sure where I’ve got it. Maybe tools like Xamarin could be helpful. At the company, I’m working on the network, I’m a javascript and javascript

What is your take on Kotlin in production? Kotlin, Java8, Swift?

Update 1.0.2 was a huge step forward. Unfortunately, I’ve been working intensively. It is a good language, but it’s not a problem. We cann’t find out how to do it when it comes to replacing Java and access API / SDK any time soon. Java 8 has some nice long awaited features. If you are using mixins. Unfortunately this is only available in API 23 and above.

Do you have Android Jack & Jill toolchain? What architecture pattern do you use in production? What is your thoughts on MVVM?

I’m not sure to have a java or even a java 9 for the android development. I love you and my java programming language for android development.

Basically I use MVP, Immutable data flow, immutability and pure functions. It's also worthwhile to say that MVP, MVVM etc. but not the architectural patterns from the underlying layers. Many people refer to Robert C. Martin’s Clean Architecture in this context, which is a great architecture. I do implement my apps according the Clean Architecture. But I don’t follow the books blindly.

Google offers us a data binding engine. MVVM. Data binding can be used for instance without MVVM to bind a ViewHolder in a RecyclerView. In general, I prefer MVPM over MVVM in combination with Google’s data guidelines. I strongly believe in: Immutability. Therefore, if you want to implement MVVM, I would recommend to use it using RxJava.
I’m not sure where to go. Actually, I’ve got an official statement from Google’s point of view. But Google has never made such an official statement. MVVM is better than MVC or MVP. Developers hate Google for that. But I think that Google’s architecture is a topic that evolves over time. It wouldn’t be necessary to implement every one of them. Declaring one pattern as the best solution quite often means stagnation.

How much time do you spend on writing unit tests? How do you ensure sufficient coverage?

As much time as they take. I practice TDD which says writing the code before you write the production code. Usually I stick to this rule. However, I only rarely write functional tests for UI, because it’s pretty stupid simple. There is no business logic to sort elements etc. in my UI layer. There can't go much wrong. Another problem I have with functional UI Tests (espresso) is that they take minutes to run. That destroys TDD. You can’t take TDD. Compared to backend development where TDD feedback loops is about 2-3 seconds more then 10 seconds is unacceptable for practicing TDD. So I, personally, tests. As already said, my UI layer is pretty simple. Therefore, testing if you click on the button In practice I found out that “visual bugs” occur more often, especially when working with a lot of xml layouts. If you’re u Therefore, I decided to do a visual regression facebook.imtqy.com/screenshot-tests-for-android .

Last but not least, how do I ensure sufficient coverage? Well, developers are good in maths and statistics. Many developers use code coverage tools like JaCoCo. I’m not testing UI and I’m not yet testing POJO's ie getters and setters. So what if I have a coverage of 80%. What does 80% actually mean in this context? It can be understood that I can take a few steps. I ensure sufficient coverage by code review. This is the number one of duplicated

Do you prefer a mosque-conductor / mosby-flow?

Usually, I’m trying to get people complained about Fragments. The idea of ​​Fragments is a great idea. This is where the Conductor comes in. Conductor is a better implementation of Fragments. Is a navigation stack replacement. It misses the concept of controllers (Fragments) entirely and uses plain android.view.View. It is a very simple concept. Since the controllers are a serviceFactory, it is This is what mosby-flow does. This plugin provides a service for your view of life to life. At the end you can customize your MVP pattern with Flow. mosby-conductor offers the same for Conductor. At the moment I tend to prefer Conductor over Flow. I’ve got a lot of support for all the fragrances that I’ve been building. the prefered view layer container (Activity, Fragment, Conductor, Flow).

What do you think about using JVM? If you’re looking for Android’s

Bytecode patching with JVM. Therefore, you can debug the IDE's debugger. If you are honest, every piece of software has been adopted. If you’re a bug in my daily development? It is not working as expected. It’s been caused that it has been caused by the code. In contrast, if you can attach your IDE's debugger. Bytecode manipulating the library, then I’m thinking about it.

It seems to be a standard and for good reasons. Lately, we adopted concepts from functional programming languages. It is a timeless concept. That’s what I’ve meant to follow.

Fragment / activity. Do you think it's a good solution? In the big projects we often have a couple of them. What is the best solution in your opinion?

Yes, I think every view should. Subviews for each view. If you’re not really necessary, that is, another subview's presenter. No need to view the first subview directly.

These are the components that answer the lifecycle, routing and implementing dependencies. Do you think such a configuration contradicts SRP? How justified is your abstraction of Android classes in your opinion?

That's a good point. Infact Activity / Fragment is SRP heavily. Manages lifecycle, interacts with UI widgets and so on. In Mosby I decided to treat Activity / Fragment. However, it’s in MvpActivity / MvpFragment called getMvpView () you can override. This method returns the MVP View. This is the pattern that you’re introducing. It can be treated as lifecycle management component only. Sounds reasonable right, so why not doing that per default? It is where the overengineering comes in. If you think of your activity, you can use it. Fragment powered by Mosby usually they are only implementing the MVP View interface. In this case, it’s completely possible to complete the MVP. Overengineering

What changes are planned for the third version of Mosby?

I will add more support for your child. Another feature people ask me quite often is the MVP in RecyclerView / ViewHolders. I would like to add that. But things are tricky with RecyclerView (ViewHolders are recycled, Adapter's dataset changes at any time, screen orientation changes, etc.). I have to evaluate if I really want to add this. I’m afraid to get out of hand. Pandora's box.

What is the current development stage of mosby? Or just keep fixing bugs? Mosby-Conductor plugin now? There's a MPV library Moxy created supposedly because of some flaws in Mosby. Do you know any comparisons?

I'm working on Mosby 3.0 (snapshots are already available). Unfortunately, I do not have time to work. I tried my best to build it up. For example, Mosby's default Presenter doesn't have that methods. It’s a funky way to make it. You can use your whole app easily. I’m thinking of “software architecture evolves” previously. It is a way to get it. Who am I to judge about the work of others? Therefore, I will not compare Mosby and Moxy. I recommend you take your own mind. It can be a moxy, it can be something completely different.

Do you consider more than a concept? Millions of millions of users. Works for us. There has been a lot of talk over the interviews, because they asked for the data structure (like depth-first-search), data structure ("reverse linked list"), etc. What approach do you have to hiring people? How do you conduct interviews? Android developer, for example?

I'm not that much involved in our company. I do interviews only if the CTO / CEO is not available. At home. Basically he has a very simple Android app. Usually, he has 1 week to send us his solution. Then we take a look at a personal interview. In the case of your interviewer? I want to create a relaxed atmosphere for the candidate. Then I ask him some basic questions about his background. I think it is very important. It can be a little bit different. Ideally the candidate has already worked on an open source project. I’m giving you a little bit more information. data structure for some So indirectly we will talk about data structure. Data structures are also important for front end developers. But I don’t want a red-black tree. It is a good idea to have a map or a tree. He developed at home after his demo app. For me, it’s important that you need a java programming language, data structures, threading and synchronization and garbage collection. It is more important that it can be a good java developer. It is a matter of course for those who want to make a difference. It is a very important part of development: refining. I would like to ask you about your questions and concerns. Last but not least, I can learn. He brings a new one.

Android Development Program for Android (s) understanding of the HTTP protocol. But not a strong requirement.

It helps you to complete your projects with the help of the Gradle. Have you spent on compiling?

Compilation time is horrible. I can't even imagine how much money companies lose. It doesn’t matter if it’s possible. It was so much faster than the unified build system. My guess I guess. Buck is definitely a good alternative.

Real or Arsenal? :)
I love football, I really do. I can talk about football for hours. Be prepared, I'm Real Madrid and Bayern Munich supporter.


How did you start programming for Android?

I have always been attracted to the development of mobile applications. My first application, still a student, I wrote on Symbian using Qt and C ++. I also did a little J2ME. I also had a PDA on Windows CE for all sorts of programmers. When smartphones and iPhones began to appear, all this inspired me a lot, but I can’t say that the relationship between Android and me was warm from the first meeting. I started programming for Android (Android 1.5 Cupcake) in college in the summer of 2009, but then I was at the level of “where is my“ main () ”method, what is xml and what does this findViewById () eat with?”. As a result, I abandoned Android for almost six months, until my Nokia N95 ordered to live long and it was time to buy a smartphone. I never liked the iPhone, and besides, for me the important point was that the device had an analog keyboard. I could not imagine how I would enter a long text on the touchscreen. I had two options: either the original Motorola Droid (Milestone) with Android 2.0, or the Nokia N900 running Maemo . The Maemo platform also implied the ability to use C ++ and Qt, so I was close to choosing the N900, but in the end my choice fell on the Motorola Droid, and mainly because Maemo OS did not support MMS , which is understandably more important all over the world! :) And as soon as I got hold of the Motorola Droid, I started programming under Android 2.0 - true, purely for personal purposes.

What is your opinion on the application of architectural solutions from JS?

JavaScript developers have something in common with Android developers: their platform / SDK has practically no guidelines from an architectural point of view. This is a really tilled field. The world of JavaScript is still in search of its “architectural grail”, with the result that every three months we observe how new frameworks and approaches replace each other. At the same time, the design patterns of the Model-View-Intent type (cycle.js), Redux and Flux introduced a number of truly significant concepts that it really makes sense to try to implement in platforms like Android - we are talking about ideas that underlie patterns or development environments. Android programmers have a tendency to reinvent the wheel again and again, and this bike does not always have round wheels. Simply put, we should sometimes move away from generally accepted solutions and be interested in the development of other platforms in order to learn something new for ourselves, and most importantly - learn from other people's mistakes.

Do you think React Native and other cross-platform approaches have prospects?

Good question. To be honest, not sure. Generally speaking, I am not very enthusiastic about using React for web development, because I believe that there are more advanced tools and tools for developing web applications, for example, RxJS (similar to RxJava in JavaScript). As for React Native, I believe that the user interface code for both Android and iOS needs to be written for a specific platform, and this despite the fact that the guys from Facebook achieved excellent results using React Native. I am also not sure that I would like to create mobile applications on JS, if I had the opportunity to write them in the Kotlin or Swift language. At the same time, it seems to me that more and more mobile applications will use a common code base for implementing business logic, and this is especially true for Android and iOS applications. Perhaps we should pay attention to tools like Xamarin . In the company where I work, we found a solution based on GWT, annotation processing and J2ObjC, to reuse the code responsible for business logic in Android, iOs, server (JRuby) and web application (JS) implementing it first on Java, and then, broadcasting ObjectiveC or JavaScript, running on a specific platform.

What is your opinion on the use of the Kotlin language in application development? What do you think, what language will be used in the future for developing Android applications: Kotlin, Java8, Swift?

Kotlin is a great language, and the latest update 1.0.2 is a real breakthrough. Unfortunately, in our company we still use Kotlin only for a few unit tests, and not as a language for development. However, in my personal projects I use Kotlin very actively. Swift is also an interesting language, but I cannot agree with the rumors circulating on the Internet, and I don’t think that Swift will be used to develop Android applications. We could consider it as an alternative to C / C ++ for use with JNI, but I don’t think we’ll see Swift as a Java replacement for working with the Android API / SDK any time soon. Java 8 has a number of interesting features that everyone has been waiting for. Lambda expressions are one of the most popular among them, but for me personally, I like the default default methods of interfaces, which allow using mixins. Unfortunately, this feature is only available in API 23 and higher.

What do you expect from the new toolkit Android Jack and Jill? What architectural model do you use in development? What do you think about MVVM? , Google .

, Jack Jill , Java Java 9 Android. , Jack Jill Java Android. MVP, — , unidirectional data flow, immutability, pure functions. , MVP, MVVM .. , View . , Clean Architecture . . « ». , , . , Google (data-binding). , MVVM. Data-binding MVVM, ViewHolder RecyclerView. MVP MVVM , , : (immutable). , MVVM, RxJava.

, Google - , , MVVM . , , Google , Android . Google . Google , MVVM , MVC MVP. Google . , Google , , — , . , - . - , .

? ?

, . (TDD), , . . , . -, .. . , . , , UI- (Espresso), , . TDD. , . , TDD 2–3 , , 10 , TDD-. . , UI- . , , , , . , « » , xml-. , , , . facebook.imtqy.com/screenshot-tests-for-android

— , . . JaCoCo. , , UI. POJO, .. get set. , , , , 80%? 80% ? , , , , . , -. - -, - . , - - .

View, mosby-conductor/mosby-flow?

, , , . , , , . Conductor. , Conductor — . Flow, , . (), android.view.View. , , . , Flow ServiceFactory, View Flow View. C mosby-flow : ServiceFactory, Presenter View, . API Mosby ( ) MVP Flow. Mosby-conductor Conductor'a. Conductor, Flow. , Mosby , Conductor, View. Presenters , View (Activity, Fragment, Conductor, Flow).

JVM (bytecode patching) ? « » Android , ?

JVM , . , IDE. , , , . : , ? , , - , . , , , , , , . , , IDE-. , : , Square, . « », -, , . , , Kotlin Swift, , . « » , , , , , - , . , « », ».

Mosby (Presenter) (View) /. , ? — , . , ?

, . , . ( , , , ), data flow, ( Presenter), , , . .

Mosby / , , . , SRP? Android, ?

Great question. Activity/Fragment SRP. , , .. Activity/Fragment Mosby. Mosby , MvpActivity/MvpFragment getMvpView(), . MVP-, Presenter. Activity/Fragment, MVP- . MVP View Activity . . ? , , , , . , Activity/Fragment SRP, MVP View (: ), Activity/Fragment, Mosby, MVP View. , SRP , , , Activity/Fragment MVP View. .

Mosby?

«» , ViewGroups , Flow. , , MVP RecyclerView/ViewHolders. , , . RecyclerView (ViewHolders , , ..). , . , , , - . .

Mosby ? - , ? MVP View Fragments, , Mosby-Conductor? MVP Moxy — , - , Mosby. - ?

Mosby 3.0 ( ). , Mosby, . , Mosby , , MVP. , , Presenter , Mosby . , , Presenter , Presenter . Mosby , Presenter . , Moxy — , , . , - Mosby, , . , ? Mosby Moxy . . , : Moxy, Mosby, Nucleus - .

Mosby ?

Mosby , , . , .

, , (, ), ( ) .. ? ? Android- ?

. , . . , Android. , . . , . . . . , : , ( ), ( ). , , . ( , ), , — , , , .. . . - . , , , . , , . Java- Java, , , . , Android-, Android , , Java-, . « ?», , , , . , , , , : . , , : , , , . , : , , - . , , . Android- Java, Android, Activity Services; XML, SQL HTTP. , .

, Gradle ? - , ?

. , - . , , javac, Jack Jill aapt , . - Buck Facebook, , . Buck, , , . Buck, , .

«» «»? :)

, . , , Android Droid Party , . , «» «».

Source: https://habr.com/ru/post/301858/


All Articles