• 1 Post
  • 1 Comment
Joined 1Y ago
cake
Cake day: Jun 17, 2023

help-circle
rss
Help needed in structuring code following design Principles.
Hi everyone, In a project involving Firebase and object types like Tickets, Schedules, and Timers, I want to structure my classes such that switching databases (potentially to MySQL) wouldn’t require a complete rewrite. Approach 1: * A DatabaseProxy interface with generic methods (e.g., createTicket, createTimer, etc.) * A FirebaseProxy class implementing the interface, with methods for each object type (e.g., createTicket, createTimer, etc.) * Manager classes for Tickets, Schedules, and Timers, that primarily use the FirebaseProxy for operations. This provides flexibility for processing input/output, but most of the time the manager classes will just be calling methods on the Proxy directly. Approach 2: * A DatabaseProxy interface with the most basic CRUD methods (create, read, update, delete). * A FirebaseProxy class implementing the interface. * Manager classes for Tickets, Schedules, and Timers, calling FirebaseProxy with parameters like update(collection, ticket) and implementing createTimer, createTicket, etc. I like the second approach in theory, but what I’m worried about is whether the separation is too low level. What happens if the database I switch to changes schema such that taking in an object and a collection name isn’t good enough anymore? For example, will there be concerns if I switch between Vector, NoSQL, and SQL? Any opinions are appreciated!
fedilink

Yes and no. If your goal is to learn how to code manually, then you are “cheating” in that you may not learn as much.

If your goal is to learn how to utilize AI to assist you in daily tasks, I would say you’re not.

If your goal is to provide value for others through how much you can produce in a given amount of time, then you’re definitely not.