Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return Type of get_active_note_content: Dictionary of Lines vs. Full String #7

Open
mathe00 opened this issue Sep 30, 2024 · 0 comments
Labels
help wanted Extra attention is needed question Further information is requested

Comments

@mathe00
Copy link
Owner

mathe00 commented Sep 30, 2024

Problem Statement

When retrieving the content of a note using get_active_note_content, we need to decide what type of data the function should return. This decision affects both performance and ease of use. There are two main return types to consider:

  1. Option 1: Dictionary of Lines

    • Structure: Return the note's content as a dictionary, where each element represents a single line of the note.
    • Advantages:
      • Efficient for large files: Handling content line-by-line minimizes memory usage and processing overhead.
      • Easy manipulation: Developers can work with specific lines or sections of the note, simplifying tasks like editing specific parts.
      • Error handling: By processing each line individually, identifying and fixing errors is more straightforward.
    • Disadvantages:
      • Additional complexity: Developers would need to join lines if they want to work with the entire note as one block.
      • Unnecessary for small notes: For simple scripts or small notes, splitting content into lines adds unneeded complexity.
  2. Option 2: Full String

    • Structure: Return the entire content of the note as a single string, including all newline characters.
    • Advantages:
      • Simpler for full content operations: Developers can work with the entire note in one go, useful for large-scale transformations.
      • Less overhead: No need to worry about line breaks, making it more intuitive for scripts that don’t care about individual lines.
    • Disadvantages:
      • Risky for large notes: Storing and processing the entire note as a string can lead to performance issues, especially with large files.
      • Difficult to work with parts: For scripts requiring line-by-line manipulation, splitting the content into lines would need to be done manually.

Possible Solution: Parameter for Return Type

To accommodate different use cases, we could introduce a parameter that allows developers to choose the return type they prefer when calling get_active_note_content. For instance:

  • Parameter name: return_type
  • Default value: "string" (or "lines", based on consensus).
  • Accepted values:
    • "string": Returns the entire content as a single string.
    • "lines": Returns the content as a dictionary, with each entry representing a line.

This approach would give developers flexibility, allowing them to pick the return type that best suits their needs:

  • For small notes or full-content operations, they can choose "string".
  • For large notes or line-based processing, they can choose "lines".

Request for Feedback

We need input from developers on:

  • Which return type should be the default (string vs. lines).
  • Whether offering this parameter adds too much complexity or whether it simplifies development for various use cases.
  • Any performance concerns regarding large notes when returning the content as a single string.

By allowing developers to select their preferred format, we hope to cover all bases while minimizing any performance or usability issues. Looking forward to hearing your thoughts!

@mathe00 mathe00 added help wanted Extra attention is needed question Further information is requested labels Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant