Coder Social home page Coder Social logo

sanastosovellus's People

Contributors

riinaalisah avatar

sanastosovellus's Issues

Koodikatselmointi

Projekti ladattu 24.4 klo 20:22

Koodi oli helposti luettavaa ja luokat oli sijoitettu järkeviin pakkauksiin. Metodien nimet kuvasivat hyvin niiden toimintoja ja olivat toteutukseltaan hyviä. Jotta tästä palautteesta olisi jotain hyötyäkin, niin nappasin koodista pari kohtaa ylös:

FileWordPairDao

public class FileWordPairDao implements WordPairDao {
    public List<WordPair> wordpairs;
    private String file;
    /* loput */
}

Luokassa tuo tiedosto tallennetaan parametrina saatuna merkkijonona. Tämän jälkeen aina kun tiedostoa halutaan lukea, niin luodaa uusi instanssi File -luokasta. Pystyisikö tuon tiedoston tallentamaan suoraan File -tyyppisenä oliomuuttujana?

SanastosovellusUI

public void setPracticeScene(Stage primaryStage, int index, boolean defaultDirection) {
    /* muuttujat */

    answerButton.setOnAction(e->{
            /**
             * Direction word -> translation
             */
            if (defaultDirection) {
                if (answerInput.getText().equals(usersWordpairs.get(index).getTranslation())) {
                    practiceMessage.setText("Oikein! " + usersWordpairs.get(index).getWord() + " = " + usersWordpairs.get(index).getTranslation());
                    practiceMessage.setTextFill(Color.GREEN);

                    /**
                     * Next word if there are words left
                     */
                    if (index < usersWordpairs.size()-1) {
                        setPracticeScene(primaryStage, index + 1, true);
                        primaryStage.setScene(practiceScene);
                    }

                    /* loput */
}

Pystyisikö käyttöliittymästä siirtää tuota sovelluslogiikkaa esimerkiksi luokan AppService vastuulle? Esimerkiksi tuo harjoittelusuunta (defaultDirection) vaikuttaa käytännössä vain vastauksen tarkistukseen, joka voitaisiin hoitaa AppServicen puolella ja näin eliminoitaisiin tuon defaultDirectionin else {} -haara => myös toisteisuutta saadaan pienennettyä.

Sovellus

Testasin myös sovellusta ja kaikki toiminnot toimivat juuri niinkuin pitää. Hyvää työtä! Jos aikaa ja intoa riittää, niin IndexOutOfBoundsExceptionin voisi hoidella, mikäli yritetään harjoitella ilman sanoja.

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.