Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REFACTOR] Optimize DeviceRepository Using Lamda expression #46

Open
AbdalrhmanHemida opened this issue Dec 16, 2022 · 0 comments · May be fixed by #48
Open

[REFACTOR] Optimize DeviceRepository Using Lamda expression #46

AbdalrhmanHemida opened this issue Dec 16, 2022 · 0 comments · May be fixed by #48
Assignees
Labels
1h An hour

Comments

@AbdalrhmanHemida
Copy link
Collaborator

AbdalrhmanHemida commented Dec 16, 2022

Use the lambda Expression for DeviceRepository methods to optimize the code.

Why use the lambda expression?

  • Makes our code more readable and shorter. Instead of instantiation of an anonymous inner class that implements the abstract method run() on the interface Runnable, we use the lambda expression to do that.

For example

instead of writing

UserDatabase.databaseWriteExecutor.execute(new Runnable() {
            @Override
            public void run() {
                detoxPeriodDao.insert(detoxPeriod);
            }
        });

we write:

UserDatabase.databaseWriteExecutor.execute(
                () -> detoxPeriodDao.insert(detoxPeriod)
        );

Source: link

@AbdalrhmanHemida AbdalrhmanHemida added the 1h An hour label Dec 16, 2022
@AbdalrhmanHemida AbdalrhmanHemida self-assigned this Dec 16, 2022
@AbdalrhmanHemida AbdalrhmanHemida linked a pull request Dec 16, 2022 that will close this issue
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1h An hour
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant