![]() ![]() ![]() so due to this total abstraction and for defining theĬontract, interface is useful in this place. We are not aware of the implementation of all the 2 methods required,Īnd what we know is the contract methods that vendor(implementer) should In this situation, Interface is useful because Vendor is, you need " getAllAvailableFlights()" and " booking()" method from So we can say that we know the contract that irrespective of who the Flight Similarly, for booking I only care for method " booking()" that all vendors should have, internally how this vendors are doing booking that I don't care.Typical usage is when you want to embed default functionality into objects. Functional interfaces may not have fields unlike C++ abstract classes. It also defines the abstract characteristics of an object, including characteristics (its attributes, fields or properties) and the behavior (the things it can do, or methods, operations or features). Functional interfaces may have only a single abstract method. Class is a group of similar types of objects, which possesses same attributes and behavior. Differences: A class may extend multiple functional interfaces. "getAllAvailableFlights()" from "emirates" may have used CORBA service to return list of flights.īut we don't care how it is internally implemented and what we care is the contract method " getAllAvailableFlights" that all the flight vendor should provide and return list of flights. Functional interface are is used in a 'safe' multiple inheritance. "getAllAvailableFlights()" from " british airways" may have used REST service to return list of flights. "getAllAvailableFlights()" from "airasia" may have used SOAP service to return list of flights. Main difference is methods of a Java interface are implicitly abstract and cannot have implementations. This means I only care for method " getAllAvailableFlights()". ![]() How they are giving the list that we don't care. "british airways" and "emirates" to give us list of flights, internally Opts for booking then inform the respective flight vendor to do booking.įor this, first we need to tell "airasia", "emirates" about the list of flights available and later if customer imagine you have a huge application, and a lot of code. and Person person new Person () won't even compile. PersonImpl person new PersonImpl () is tightly coupled. we are just a middle man/aggregator and our task is to firstĮnquire "airasia", then enquire "british airways" and at last enquire the advantage in using Person person new PersonImpl () is that a loose coupling is maintained between the interface and the concrete implementation. Remember, In this application, we don't own any flight. How should we design our application considering interfaces and abstract class? In this scenario, interface is useful or abstract class? Place and order for seat to respective vendor.Displaying flights available from vendors like "airasia", "british airways" and "emirates".Service company and place an order from customer. Where we are responsible for displaying the flights from various flight We want to start a service like "" or "", ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |