Skip to content

Commit

Permalink
Create Habit Model interfaces
Browse files Browse the repository at this point in the history
Our project will follow a Model-View-ViewModel architecture as it
completely decouples the View from the Model, making our code more
testable (we'll have to do that later, and it would be painful if we
follow MVC).

This commit adds an interface for `Habit` which we'll implement as an
Entity in an SQLite database for now, but will also be implemented for
Firebase.

It also adds a `HabitRepository` class for interacting with the data
store (SQLite or Firebase). For now, it only has functions
`getAllHabits` and `insert` because this is what's relevant for
adding habits (#1).
  • Loading branch information
cbebe committed Oct 18, 2021
1 parent b4162fb commit f919d09
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.github.cmput301f21t44.hellohabits.model;

import java.time.Instant;

public interface Habit {
String getId();
String getTitle();
String getReason();
Instant getDateStarted();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.github.cmput301f21t44.hellohabits.model;

import androidx.lifecycle.LiveData;

import java.time.Instant;
import java.util.List;

public interface HabitRepository<T extends Habit>{
LiveData<List<T>> getAllHabits();
void insert(String title, String reason, Instant dateStarted);
}

0 comments on commit f919d09

Please sign in to comment.