The following GUI interface is used to perform SQL commands on the Database
Initially, there were three classes: Main, DatabaseController, and GUI. The SQL instruction code was placed within the GUI class, resulting in the GUI class becoming about 1000 lines long. Consequently, adding or modifying SQL instructions became very difficult.
After refactoring, the SQL command code was moved out of the GUI class. Subsequently, adding a SQL command only requires creating a new class to implement the Command.
"Problem": The GUI class had approximately 1000 lines of code, making it difficult to add or remove functionality.
Solution: Introduce an interface Command and extract the SQL code into separate classes, each implementing the Command interface.
Result: The GUI class was reduced to 200 lines of code. Now, adding a new SQL command only requires creating a new class to implement the Command interface.
Original Implementation: The Delete and Insert commands were initially implemented using the Delete_Press and Insert_Press functions, respectively.
Solution: These commands were refactored by introducing an interface Command, and each SQL operation was extracted into separate classes that implement the Command interface.
Result: The refactoring reduced the GUI class to 200 lines of code. Now, adding a new SQL command only requires creating a new class to implement the Command interface.
Handling User Input: The press() function is used to process user input SQL commands and outputs the results to the database.
SQL Command Structure: Each SQL command is encapsulated in its own class, which implements the Command interface.