To organize and maintain a clean, scalable codebase for the Amora Book Keeping MVP app, following well-defined script organization and code conventions.
Each sheet, class, and business logic will have its own script file for better organization. Here’s the current structure:
- GLOBAL.gs – Centralized global constants and references.
- UTILITIES.gs – Helper methods, reusable utilities.
- TRIGGERS.gs – Management of time-based triggers and other triggers across sheets.
- MENU_CLASS.gs – Handles main menu navigation and logic.
- WIDGETS_CLASS.gs – Miscellaneous functions (weather, exchange rates, time, etc.).
- DATABASE_SHEET.gs – Acts like a 'MongoDB' for storing JSON-like data for various tables/sheets.
- EXPENSES_CLASS.gs – Business logic specific to the "Despesas" (Expenses) sheet.
- EXPENSES_THEME.gs – Manages the layout and theme of the "Despesas" (Expenses) sheet.
- EXPENSES_LAYOUT.gs – Handles the layout (content position mapping) for the "Despesas" sheet.
- Each sheet will have its own class, containing the business logic and layout.
- JSON-like storage will be centralized in the DATA_BASE_SHEET, where keys will map data for specific months.
- Reusable functions will reside in UTILITIES.gs.
- WIDGETS_CLASS.gs will handle shared "widget-like" functions that can be applied across sheets (e.g., weather, time, currency exchange rates).
- First column: Holds the key (e.g.,
fixed_bills,sales_log). - Subsequent columns: Hold the JSON data for each respective month (e.g.,
Oct-2024,Nov-2024).
Example Layout:
| Key | Oct-2024 | Nov-2024 |
|---|---|---|
| fixed_bills | {"data": "..."} | {"data": "..."} |
| sales_log | {"data": "..."} | {"data": "..."} |
- Each sheet will have its own class.
- Global Methods: Defined at the sheet level within the file.
- Private Methods: Methods that should only be called internally will use camelCase (e.g.,
calculateExpenses()). - Global Properties and Methods: Use SNAKE_CASE for constants and methods that need to be accessible globally (e.g.,
UPDATE_EXPENSES).
- Classes: Use capitalized SNAKE_CASE for class names (e.g.,
EXPENSES_CLASS). - Global Methods and Constants: Also use capitalized SNAKE_CASE (e.g.,
LOAD_SHEET_REFERENCES). - Private Methods: Use camelCase (e.g.,
updateExpensesData).
- GLOBAL.gs: For storing references to sheets and any constants that need to be used across multiple sheets.
- UTILITIES.gs: Contains utility functions that can be reused in different classes.
- WIDGETS_CLASS.gs: Handles miscellaneous (widget-style) features like weather, exchange rates, and time.
- DATA_BASE_SHEET.gs: Acts like a database layer, storing and retrieving JSON-like data in specific rows and columns.
- TRIGGERS.gs: Handles the creation and deletion of time-based triggers.
- Scalability: The MVP may expand into a full-fledged web app, but the focus for now is on maintaining simplicity within Google Sheets.
- Versioning: As the project grows, we will adopt semantic versioning for features and updates (e.g., v1.0.0).