Page 1 of 1

Hi, I am very new to computer science. Can you pls explain your answer like I am an idiot? So sorry for the trouble. A

Posted: Fri Jun 10, 2022 11:58 am
by correctanswer
Hi, I am very new to computer science. Can you pls
explain your answer like I am an idiot? So sorry for the
trouble.

A management system for a university includes the following Java
classes. (Methods are not shown).


class Student {
String regno, name;
List<Module> modules;
}

class Module {
String code, name;
List<Student> students;
}


(i) Write a JSP fragment that will display in tabular form the
names and codes of all of the modules taken by a student, and also
the total number of modules taken by that student. You should
assume that a reference to the student is available in a variable
called stud of type Student

(ii) Briefly describe one weakness in the design of the classes
shown above and suggest a better approach.

For part (i) i really have no idea, pls help me with
that.

For part (ii) pls find my answer here and let me know how it can be
better.

Answer(ii):
The class design has tight coupling which is not ideal. For example
every time there is a new module we will add it to the Student list
and vice versa, this seems to be an unnecessary dependency. This
means that the student class cannot do without the module class and
likewise, should we need to make changes to either of the classes
it may affect the other class.
Loosely coupled modules are easier to develop and maintain since
they are independent of each other and can hence be modified and
updated without affecting each other.