例如,我正在开发一个项目,该项目创建学生成绩单,接受输入并创建课程,并显示所有学期/课程,同时还跟踪所有学期的统计数据和GPA。目前,我有一个Semester类,它有以下方法:
Constructor - Creates a new semester with a given semester name
Is Valid Semester - Confirms semester name is legal
Add Course - Adds the given course
Search Course - Gives index of course in list, or -1 if not found
Remove Course - Removes the given course if it exists
Withdraw Course - Withdraws a course from semester
Calc GPA - Calculates the overall GPA of the semester
To String - Displays one-line summary of semester
Console menu - Command-line menu for semester editor
Prompt Course List - Command prompts for courses to add them from console input
Prompt Remove Course - Command prompt for adding a course
Prompt Withdraw Course - Command prompt for withdrawing a course
Display Semester - Display detailed output of semester and its courses' info
我知道逻辑和IO应该总是分开的,并且它们在方法基础上肯定是分开的(换句话说,所有io功能都与逻辑方法分离)。但是,我正在考虑将类拆分为具有所有静态方法的单独SemesterIO类。这会导致更多的内存或处理时间吗?我知道类中的方法存储在内存中“一次”,并且它的所有实例都指向该引用。但是,当你有多个班级而不是一个班级时会发生什么?