Skip to content

ukpagrace/CodeReviews.Console.HabitTracker

 
 

Repository files navigation

ConsoleHabitTracker

C# Console Application to Log Habits. Console based CRUD application to log Habits. Developed using C# and SQLite.

Given Requirements:

  • This is an application where you’ll register one habit.
  • This habit can't be tracked by time (ex. hours of sleep), only by quantity (ex. number of water glasses a day)
  • The application should store and retrieve data from a real database
  • When the application starts, it should create a sqlite database, if one isn’t present.
  • It should also create a table in the database, where the habit will be logged.
  • The app should show the user a menu of options.
  • The users should be able to insert, delete, update and view their logged habit.
  • You should handle all possible errors so that the application never crashes.
  • The application should only be terminated when the user inserts 0.
  • You can only interact with the database using raw SQL. You can’t use mappers such as Entity Framework.
  • Your project needs to contain a Read Me file where you'll explain how your app works. Here's a nice example:

Features

  • SQLite database connection

    • The program uses a SQLite db connection to store and read information.
    • If no database exists, or the correct table does not exist they will be created on program start.
  • A console based UI where users can navigate by key presses

    • image
  • CRUD DB functions

    • From the main menu users can Create, Read, Update or Delete entries for whichever date they want, entered in yyyy-MM-dd format.
    • Time and Dates inputted are checked to make sure they are in the correct and realistic format.
  • View All Habit Logs by pressing 1

    • image
  • To log new Habit press 2

    • First all the Habits are displayed so the users can enter a valid HabitId from the list
      • image
    • Next User will enter Unit Quantity and a Valid date in yyyy-MM-dd format.
      • image
  • To delete a Record press 3

    • Enter the Id from the list to delete the Habitlog.
      • image
  • To update a Record press 4

    • Enter the Id from the list to update the Habitlog, next enter new quantity and Date to update it.
      • image
  • To view all Habit press 5

    • image
  • To Enter a New Habit press 6

    • User will entered Habit Description and Unit
      • image
  • Basic Report for current Year

    • image

Challenges

  • Let the users create their own habits to track. That will require that you let them choose the unit of measurement of each habit.
  • Seed Data into the database automatically when the database gets created for the first time, generating a few habits and inserting a hundred records with randomly generated values. This is specially helpful during development so you don't have to reinsert data every time you create the database.
  • Create a report functionality where the users can view specific information (i.e. how many times the user ran in a year? how many kms?) SQL allows you to ask very interesting things from your database.

Areas to Improve

  • Need to move back to main menu
  • Still need to refactor the code to catch exceptions
  • Using Async to interact with database

About

Habit Tracker

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%