Skip to content

jim0987795064/Software_Design_FinalProject

Repository files navigation

Implement database of personnel department in school

Use Mysql to build a relational database system�

image

Use JavaFx to build the following GUI

The following GUI interface is used to perform SQL commands on the Database image

Original Class Diagram

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. image

Modified Class Diagram

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. image

Use Strategy Pattern

"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.

image

Example

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. image

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. image image

image

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages