0
Help me in assignment
Consider the following java code which contains two classes Subject and Topic. Perform program analysis and identify what type of coupling exists between the two classes. Also, comments what will be the impact of this type of coupling during code maintenance phase. class Subject { Topic t = new Topic(); public void startReading() { t.understand(); } } class Topic { public void understand() { System.out.println("Software Construction"); } }
1 Réponse
+ 2
The above two classes are tightly coupled.
Subject class is dependent on Topic class. If Topic class's understand() method change, then you have to change the startReading() method of Subject class also accordingly.
You can do a google search to read more docs and articles to get detailed understanding.
Best of luck 👍