Photo by Claudio Schwarz | @purzlbaum on Unsplash

Originally posted on Hacker Noon.

With how volatile the crypto market is, in order to achieve success it’s vital to find projects that are positioned for long-term success. Given how useful 1inch is to the DeFi community and its potential, the goal of this is to understand the governance around minting new tokens, and not as a “gotcha”.

After a user on Reddit called out that there is a function in the smart contract allowing the team to create unlimited tokens, I became interested in looking at the max token supply of 1inch.

My interest increased when a moderator on…


This is exciting as it means triple yields with swap fees, liquidity mining, and now AAVE! 👏🏻👏🏻👏🏻

Will users be able to configure AAVE on/off for their staked liquidity pools?


Photo by Zach Reiner on Unsplash

Local unit testing using JUnit 5 and MockK

You’ve spent too much time testing if you have had to reconfigure a feature’s code to make it testable or have debugged the ordering of actions/events and the resulting test output. Using the Model-View-Intent pattern (MVI) provides the ability to test built-in to the pattern following the best practice of Test Driven Development (TDD).

If you’re not familiar with MVI, the pattern structures how information is shared and how views are created and updated. MVI defines a clear contract between the view and business logic with an interface that is a one-way, immutable, unidirectional data flow (UDF) pattern. …


Photo by Zach Reiner on Unsplash

Update from Unidirectional Data Flow with LiveData

You may think of ‘magic mushrooms’ when you hear ‘fungi network’. However, just like the Model-View-Intent (MVI) pattern, the forest’s organized fungi network of a connected info sharing system, like Model-View-Intent’s pattern, is indeed not magic.

The Unidirectional Data Flow (UDF) pattern does a great job to ensure information is sent in one direction from the view to the business logic, is retrieved, and processed in order to build the view. UDF alone does not organize how the data processed. The Model-View-Intent pattern structures the design of how information is shared and views are created. MVI defines a clear contract…


Photo by Irina Iriser on Unsplash

The network, database, and view states

One of the many great things about the Unidirectional Data Flow (UDF) to organize an app’s logic is that it works with any reactive programming pattern, whether it be Kotlin coroutines Flow (Flow), ReactiveX (Rx) based RxJava/Kotlin, or LiveData. Kotlin coroutines version 1.0 was released at the end of 2018 and anecdotally has quickly been gaining adoption, alongside functionality. However, a large portion of apps have been built pre-late 2018 and rely on Rx. This makes both Flow and Rx important tools to be equipped with when working on a diverse set of codebases.

Spoiler — Kotlin Flow requires less…


Photo by Lenny Kuhne on Unsplash

Initialization, passing arguments, and saved state

The Lifecycle 2.2.0 update including simplified initialization with by viewModels(), by activityViewModels(), and by navGraphViewModels(...) syntax for the ViewModel (VM) component is great for quickly creating VMs. What about re-using the VM instance throughout fragments, passing arguments/parameters into the VM while also enabling saved state? With a bit of customization, the above can be achieved as I recently shipped in the latest version of the Coinverse app.

Sample Code

Setup

Initializing the ViewModel for Reusability

How to pass Arguments/Parameters to ViewModels

Enabling SavedState with Arguments/Parameters

Resources

Setup

To take advantage of the latest VM component, declare the most recent Lifecycle dependencies in the…


MockK, JUnit 5, and AssertJ

Photo by Jeremy Bishop on Unsplash

When I started building the Unidirectional Data Flow (UDF) with LiveData pattern, I did not have testing experience. Working on a small/fast moving startup team, Close5, owned by eBay, and building Coinverse from scratch, I had not been required, nor did I allocate the time to develop tests. One of the touted advantages of UDF is optimizing the architecture for testing. This made for a great opportunity to develop testing fundamentals explored in the Coinverse code below.

JUnit 5 Testing: Android Unidirectional Data Flow with LiveData (DroidCon San Francisco 2019). See slides.

Previous:

Sample code:

Strategy — UDF + JUnit 5


Improving State Models + Coroutines Flow

Photo by Jeremy Bishop on Unsplash

Based on amazing feedback from the Android community and taking advantage of Kotlin’s natural language features, the Android Unidirectional Data Flow (UDF) with LiveData 2.0 improves and simplifies upon the original pattern. Version 1.0 improved the efficiency of Coinverse’s newsfeed, removed adjacent native ads, and made audiocast loading faster.

Previous:

Sample:

Recap

The first 13 min. of my DroidCon San Francisco talk cover the UDF 2.0 pattern. See slides 10–25.

JUnit 5 Testing: Android Unidirectional Data Flow with LiveData (DroidCon San Francisco 2019)

UDF Strengths 💪

  • Linear flow of app logic
  • Control UI & async events
  • Pre-defined test structure
  • Faster debugging

Structure

  • View state —…

6 Easy-ish Steps

Some mountain top, Emigrant Wilderness Trail, Yosemite, CA (2018)

If you‘d like to explore the Android code for Coinverse’s open app check out the GitHub page. Without the set up below, you can browse, listen on-the-go, and watch the newsfeed of audiocast and video content.

GitHub:

For access to features requiring authentication such as saving and dismissing content, you’ll need to implement the 6 steps to set up a Firebase project outlined below. If that’s too much work you can download the latest release on Google Play.

Google Play:


Using LiveData in Coinverse

pc — Ned Scher, Waterfall at Yosemite National Park (2015)

Code in the wild is always better to learn from than slide samples. Here I’ll be sharing code from Coinverse’s Open App to showcase a live Unidirectional Data Flow (UDF) pattern which makes the app more readable, easier to develop for, and debug.

Open source code:

About UDF + LiveData:

The previous post outlines the strategy for loading a newsfeed and removing adjacent ads using UDF. This post shares both a basic live example, and a more complex structure to return multiple processes in one method using MediatorLiveData.

By downloading the GitHub project, you can run the code to explore…

Adam Hurwitz

Creator of Coinverse - The 1st Crypto News Audiocast App @ bit.ly/play-coin

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store