Code Monkey home page Code Monkey logo

kristiania-demo's Introduction

Demo applikasjon for Høyskolen Kristiania

Dette er en demo applikasjon for å vise hvordan man kan bruke dependency injection for å bygge Android applikasjoner. Dette kan gjøre koden enklere å teste, refaktorere kode og bytte enkelte lag av applikasjonen.

Litt bakgrunn om dependency injection

Dependency injection er en programmeringsteknikk der man overlater oppgaven med å opprette objekter man avhenger av til noen andre. I stedet får man objektet man bruker for eksempel som argument i konstruktøren.

Eksempel uten dependency injection

public class MailService {
    private final Mailklient mailklient;

    public MailService() {
        mailklient = new Mailklient("https://api.selskap.no/mail");
    }

    public sendMail(
        String mottaker,
        String tekst
    ) {
        mailklient.sendEpost(mottaker, tekst);
    }
}

Eksempel med constructor injection

public class MailService {
    private final Mailklient mailklient;

    public MailService(Mailklient mailklient) {
        this.mailklient = mailklient;
    }

    public sendMail(
        String mottaker,
        String tekst
    ) {
        mailklient.sendEpost(mottaker, tekst);
    }
}

Eksempel med setter injection

public class MailService {
    private Mailklient mailklient;

    public setMailklient(Mailklient mailklient) {
        this.mailklient = mailklient;
    }

    public sendMail(
        String mottaker,
        String tekst
    ) {
        mailklient.sendEpost(mottaker, tekst);
    }
}

Demo applikasjon

Enkel Android applikasjon der brukeren kan taste inn et github brukernavn og få listet ut repositoriene til brukeren.

Dependency graf

Dependency graph

Biblioteker som er brukt

kristiania-demo's People

Contributors

martin-woolstenhulme avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.