+ 4

have you ever used interface in your project???

if u have ever used interface or abstract class in ur project..then can u tell me what type of benefits did u get???

6th Mar 2017, 4:45 PM
Somnath Ghosh
Somnath Ghosh - avatar
8 Réponses
+ 11
Referring to oop principles: Interfaces: for encapsulation, generic interface: for polymorphism Abstract class: for abstraction You can search for the oop tags on Google to understand their benefits.
6th Mar 2017, 5:12 PM
Tashi N
Tashi N - avatar
+ 6
I think you, visit my latest Java codes for your problems.i hope they will help you?☺
14th Mar 2017, 10:18 AM
Ajay Agrawal
Ajay Agrawal - avatar
+ 5
Yes of course. Interfaces are very important even in your own project (don't want to share with anybody) if something has multiple implementation. For example: - if you create a calculator then operator should be an interface - if you create a drawing app then a shape should be an interface - if you create video or audio player then codec is an interface too If you don't use interfaces then probably you have ugly if else if else ... sequences in your code.
6th Mar 2017, 6:06 PM
Tamás Barta
Tamás Barta - avatar
+ 3
It is hard to explain it here. Try to create a simple program which accepts commands from standard input, for example (help, exit, sayhello, echo, ...). I wonder how you would do it. What would you do if you want to add a few new acceptable commands. Please write here your solution. I don't want a fully working code, just concept.
7th Mar 2017, 2:02 PM
Tamás Barta
Tamás Barta - avatar
+ 3
Hi, I created a few codes for you, check my codes: Commands without interfaces: this is the shortest solution without interfaces, uses ugly if else commands. Commands with interfaces: it is longer but it is a better solution for a larger project where you have to add more implementations Commands with enums: in this case it is the best solution. No if else needed and it is easier to find out what kind of commands are available
7th Mar 2017, 3:22 PM
Tamás Barta
Tamás Barta - avatar
+ 1
uufffffffffffffffff....i know what is interface...but practically i have never used i don't understand where to use and why??
6th Mar 2017, 6:01 PM
Somnath Ghosh
Somnath Ghosh - avatar
0
tamas....but we don't share our source code.. sorry..but still i could not understand
7th Mar 2017, 1:56 PM
Somnath Ghosh
Somnath Ghosh - avatar
0
tamas..leave it..i think u r too good...i could not understand what u wanted me to do...u know 12 languages..how?u r great
7th Mar 2017, 2:37 PM
Somnath Ghosh
Somnath Ghosh - avatar