Jordan Schilling

Logo

View my SDLC journey. github.com/jschilling12

30 December 2025

Refactoring Time Tracking Functionality

by Jordan Schilling

Devlog — 2025-12-30

Overview

This refactor focuses on improving the structure and portability of the time tracking system. The logic was encapsulated into a dedicated timeTracker class, and the persistence layer was simplified by removing the SQLite database in favor of a CSV-based approach.

The original database-backed design proved unnecessary for the scope of the application and introduced extra complexity—especially considering plans to package the project into a distributable application. A CSV handler offered a cleaner, more portable solution.

Key Refactoring Decisions

1. Encapsulation with timeTracker Class

2. Abandoning SQLite for CSV

3. Improved CSV Export Handling

Initially, CSV rows were manually constructed by iterating over dictionary values and appending lists. This approach was replaced with a more robust and scalable solution using csv.DictWriter.

Before

for key, value in time_tracking.items():
    t = time.gmtime(value)
    values = time.strftime("%H:%M:%S", t)
    rows.append([today, key, values])

After

with open(file, 'w') as csvfile:
    fields = ['Run Time', 'Application Path', 'Time']
    csvwriter = csv.DictWriter(csvfile, fieldnames=fields)
    csvwriter.writeheader()
    csvwriter.writerow({'Run Time': today})

    for key, value in time_tracking.items():
        csvwriter.writerow({
            "Run Time": today,
            "Application Path": key,
            "Time": time.strftime("%H:%M:%S", time.gmtime(value))
        })

return True
tags: