Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Building scalable applications inspired into Mi...

Building scalable applications inspired into Micro-service Architecture

The term "Microservice Architecture" has been used in recent years to describe a particular way of designing software applications as suites of independent services, allowing architectures to be refactored or replaced in smaller pieces as the business grows, instead to replace or refactor a complete application. We learn to encapsulate parts of an application in autonomous services that can be designed, developed, tested and implemented individually with little or no dependency on other components or services of an application.

Erik Jhordan Rey

October 20, 2018
Tweet

More Decks by Erik Jhordan Rey

Other Decks in Programming

Transcript

  1. Building scalable applications inspired into Micro-service Architecture¬ Erik Jhordan Rey

    Android Tech Lead at Schibsted [email protected] @ErikJhordan_Rey github.com/erikcaffrey
  2. / SCHIBSTED MEDIA GROUP Erik Jhordan Rey Passionate about write

    quality code, focused to improving the profession of software development. Android Tech Lead at Segundamano
  3. / SCHIBSTED MEDIA GROUP Presence in 30 Countries MÉXICO Colombia

    Chile Brasil República Dominicana LATINOAMÉRICA Noruega Suecia Finlandia Bélgica Francia ESCANDINAVIA / EUROPA Portugal Alemania Polonia España Italia Irlanda Suiza Austria Hungría Rumania Bielorrusia Reino Unido Marruecos ÁFRÍCA Túnez Malasia Indonesia Singapur Vietnam Tailandia Bangladés ASIA / OCEANÍA
  4. / SCHIBSTED MEDIA GROUP There are a lot of reasons

    why a software development project can fail but the most common reasons are:
  5. / SCHIBSTED MEDIA GROUP • All code in a single

    module • Coupled code • Hard to maintain • Hard to add new functionalities • Wrong dependency Injection implementation • Unreliable test or not tests • Demotivated Teams
  6. / SCHIBSTED MEDIA GROUP Architecture as a word we use

    when we want to talk about design but want to puff it up to make it sound important. #By Martin Fowler “In most successful software projects, the expert developers working on that project have a shared understanding of the design system design. This shared understanding is called ‘architecture.’ This understanding includes how the system is divided into components and how the components interact through interfaces. These components are usually composed of smaller components, but the architecture only includes the components and interfaces that are understood by all the developers.” #By Ralph Johnson
  7. / SCHIBSTED MEDIA GROUP Way of designing software applications as

    suites of independently deployable services.
  8. / SCHIBSTED MEDIA GROUP Microservice Principles • Componentization • Organized

    around Business Capabilities • Decentralized Governance • Decentralized Data Management • Evolutionary Design
  9. / SCHIBSTED MEDIA GROUP Modularized Library Architecture • Different android

    projects • Complicated navigation between libraries • Difficult upgrades (implies a new library release) • Hard to maintain multiple libraries / projects • Hard to handle library version • Transitive dependencies
  10. / SCHIBSTED MEDIA GROUP Modularized Feature Architecture • Different android

    modules inside an android project • Modules organized around business functionality • Coupled & cyclic feature modules • Hard to maintain cyclic dependencies • Hard to share resources (custom views, colors, strings)
  11. / SCHIBSTED MEDIA GROUP Modularized Layer Architecture • Different android

    modules inside an android project • Modules organized around layer functionality • Coupling Modules (strong dependencies) • Hard upgrades • Exposed to create a bunch of git conflicts
  12. / SCHIBSTED MEDIA GROUP Modularized Feature / Layer Architecture •

    Faster build time • Decoupled of DI library (not dagger in everywhere) • Better structure • Componentization • Decentralized Data • Maintainability • Let's to write reliable tests
  13. / SCHIBSTED MEDIA GROUP hiding Implementation details, you can use

    test doubles • Kotlin • Architecture Components ◦ ViewModel ◦ LiveData ◦ Room • RxJava / RxAndroid • Retrofit • OkHttp • Gson • dagger 2 (dagger-android) • JUnit • Mockito • Hamcrest • MockWebServer • Persistence Room Testing • Barista • Shot Testing
  14. / SCHIBSTED MEDIA GROUP class LoginViewModel : ViewModel() { var

    liveDataLoading = MutableLiveData<Any>() // Show progress bar var liveDataSession = MutableLiveData<Session>() // Show user session var liveDataError = MutableLiveData<SessionError>() // Show some error
  15. / SCHIBSTED MEDIA GROUP sealed class StateData { object Loading

    : StateData() data class Success(var data: Any) : StateData() { inline fun <reified T> responseTo() = data as T } object Complete : StateData() data class Error(val error: Throwable) : StateData() { inline fun <reified T> errorTo() = error as T } }
  16. / SCHIBSTED MEDIA GROUP class LoginViewModel : ViewModel() { var

    stateDataLogin = MutableLiveData<StateData>()
  17. / SCHIBSTED MEDIA GROUP class LoginFragment : Fragment() { private

    fun handleState(stateData: StateData?) { when (stateData) { is StateData.Loading -> { showProgress() } is StateData.Success -> { val session = stateData.responseTo<Session>() showUserSession(session) } is StateData.Error -> { handleError(stateData) } } }
  18. • Avoid over engineering • Maintain a clean code style

    • Write clean and Solid Code • If your code is coupled the Refactor is your friend • Write test is our responsibility • Understand the tools before used it • Automatize • Great teammate • Be Happy!! Advices
  19. 01 02 https://martinfowler.com/articles/microservices.html Microservices - Martin Fowler http://files.catwell.info/misc/mirror/2003-martin-fowler-who-needs-an-architect.pdf Who needs

    an architect - Martin Fowler 03 Further Reading http://worrydream.com/refs/Brooks-NoSilverBullet.pdf Essence and Accident in Software Engineering - Frederick P. Brooks, Jr. 04 Service Oriented Ambiguity - Martin Fowler https://martinfowler.com/bliki/ServiceOrientedAmbiguity.html