To make it simple - Java Interfaces are nothing but APIs, without implementation, as they are nothing but component interfaces. Using Interfaces in the design, one can achieve loose coupling, but declaring the component interfaces and vary the implementations
2. Agenda
●
Application
●
Interface – What is an Interface
●
Components and Interface
●
Java Interface
●
Abstraction & Interfaces
●
Design Patterns
●
Good Design Practices
3. Applications
●
Applications that can grow
●
Plugins and Addons
●
Examples
–
–
●
Application should grow
–
●
Browser - Firefox
IDE – Eclipse, Netbeans
Provide plugin/ addon design
How to design such an application???
4. Interface
●
What is an INTERFACE
●
Tell me the interface for this room
●
Doors
●
Windows
●
Interfaces are nothing but communication points
●
How do you interface with your Bike or Car
●
Interfaces to the Computer
●
USB, HDMI, VGA , Serial Ports
●
Will this device work with my computer????
8. Java Interface
●
A way to implement multiple inheritance
●
Interface is a collection of abstract methods
●
●
now, we can have default implemented methods too
.... :)
All methods in an interface are public
9. Abstraction
●
What does Abstract mean ???
●
I need to go to Mumbai – abstract statement
●
Whats missing
–
–
–
●
Means of transport
Date and time
Budget
I am travelling to Mumbai on Monday 7 am, by
Indigo – Concrete Statement
10. Abstraction
●
Your College Project
●
Abstract - ????
–
–
–
●
Problem Statement
Solution
Whats missing - How ??? The Implemention
Where's the Implementation
–
The whole project is the Implementation !!!! ;)
11. Abstraction
●
An idea without Implementation
●
Why do we need it??
●
Object Oriented Design
Interfaces have abstract methods
12. Abstraction and Interfaces
●
Runnable Interface
●
<Code>
●
What it does
●
JVM has to deal with unknown code
●
Its not aware of Our Code
●
Interface Design provides Loose Coupling
●
Eclipse Rich Client Platform
●
Netbeans Platform
13. Design Patterns
●
Mixture of Abstract Classes and Interfaces
●
No logic, only provides a guideline/approach
●
Upto to programmer to write an implementation
– logic
14. Good Design Practices
●
Program to an interface , not to implementation
●
●
●
Spring Framework
Code can grow, more implementations
clients remain unaware
●
●
●
of the specific types of objects they use, as long as the
object adheres to the interface
of the classes that implement these objects; clients only
know about the abstract class(es) defining the interface
Use of an interface also leads to dynamic binding and
polymorphism