In: Computer Science
a) Explain the relationship between "programming to interfaces" and "loose coupling," why we care about these two things, and why it is not possible to create completely decoupled code.
b) Given the fact that we care about these two concepts, why might this imply that the new operator is problematic for creating flexible code?
a.) Programming interfaces means that we are implementing the program using the classes based on interfaces and these interfaces determine the behaviour of the object in the classes , like we can use deifferent interfaces to define and declare various classes and then using these classes in program by inheriting these interfaces and the loosely coupling means that the various classes or interfaces are interacting with each other to deliver the desired output from the program and they are connected to each other and using data from each other to complete the tasks , we do not use the loosely coupling , our program will be very bilky and consume more resources than interpreted and make our program more laggy and more prone to bugs.
b.) New operator is problematic for the flexible code because we will needed to change the implementation of the previous classes and interfaces which will be very time consuming and confusing and as the program is coupled together to deliver the required output , we need to change or use the operator in the program in same way otherwise , the data may become inconsistent and we will lose data integrity , so prefer not to add or use new operator in the programs.