Skip to content

taima aldossary - selection project#6

Open
taima-aldossary wants to merge 1 commit intoGDSC-IAU:masterfrom
taima-aldossary:master
Open

taima aldossary - selection project#6
taima-aldossary wants to merge 1 commit intoGDSC-IAU:masterfrom
taima-aldossary:master

Conversation

@taima-aldossary
Copy link

@taima-aldossary taima-aldossary commented Jan 30, 2024

Screenshot 2024-01-30 194125

I have implemented a user-friendly menu offering various options such as adding, editing, deleting, searching, and viewing notes. Also, there is a method for each option in the menu. The search method is employed within both the edit and delete methods to enhance code reusability.

Copy link
Contributor

@RyamAlmalki RyamAlmalki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, good job! Really proud of you. I can see the work and effort you have put in, and it's amazing. Don't take this as discouragement; there is always room for improvement. Take this as a challenge for next time to get better and better.

print('Note added successfully!');
}

void searchNote() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This error has occurred from this given function.
Screen Shot 1445-07-21 at 1 32 38 PM

First, let's take a look at how this error was produced.

  1. The user decides to create 3 notes.
    Screen Shot 1445-07-21 at 1 40 57 PM

  2. The user decides to delete the last note.
    Screen Shot 1445-07-21 at 1 41 34 PM

3.Now The user decides to delete the first note, but they didn't write the note name correct.
Screen Shot 1445-07-21 at 1 42 15 PM

An error has occurred, as you can observe.

Now, why did this error occur?

  1. The user decides to create 3 notes, and each note is assigned an index.
    Screen Shot 1445-07-21 at 1 55 14 PM

  2. Afterward, the user decides to delete the last note.
    Screen Shot 1445-07-21 at 1 58 45 PM
    Screen Shot 1445-07-21 at 2 00 06 PM
    Screen Shot 1445-07-21 at 2 01 02 PM

3.Now The user decides to delete the first note, but they didn't write the note name correct.
Screen Shot 1445-07-21 at 2 03 41 PM
Screen Shot 1445-07-21 at 2 05 16 PM
Screen Shot 1445-07-21 at 2 07 59 PM

Now, how to solve this issue?
Screen Shot 1445-07-21 at 2 09 40 PM

}
}

void addNote() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a condition in your add note to check that the name has not been used before, to avoid conflicts when deleting a specific note.
Screen Shot 1445-07-21 at 2 21 35 PM
Screen Shot 1445-07-21 at 2 22 16 PM
Screen Shot 1445-07-21 at 2 22 43 PM

}
}

void editNote() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Analyzing Logical Errors

Creating 2 Notes

  1. Two notes were created with the following screenshot:
    Screen Shot 1445-07-21 at 2:30:52 PM

Searching for a Note

  1. After creating the notes, a search for a specific note was initiated using this screenshot:
    Screen Shot 1445-07-21 at 2:31:43 PM

Editing a Note with a Wrong Name

  1. A logical error occurred while editing a note. Accidentally, the wrong name was entered, leading to unexpected behavior:
    Screen Shot 1445-07-21 at 2:32:21 PM

    • Noteworthy: The system prompted for a title even with the wrong name.

Unintended Note Edit

  1. Upon reviewing my notes, a startling observation was made— a note was edited without specific user request:
    Screen Shot 1445-07-21 at 2:32:35 PM

All of these issues can be attributed to the use of index=-1. This global value requires careful handling in each function to avoid unintended consequences. It serves as a reminder to exercise caution when utilizing global variables across functions in your code.

solution is to set it back
Screen Shot 1445-07-21 at 2 41 26 PM


import '../models/note_model.dart';

class NoteApp {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would have been a better option to separate this class more for readability. One that handles the menu operations and another that handles note app functionality, such as add/delete operations

print('Enter the note title: ');
title = stdin.readLineSync()!;

if (title == null || title.trim().isEmpty) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!: The null assertion operator. It is used to assert that the value to its left is non-null. It essentially tells the Dart analyzer that you are confident the value won't be null at runtime.

so having title == null is not needed since it will not be null

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants