Search
Search titles only
By:
Search titles only
By:
Log in
Register
Search
Search titles only
By:
Search titles only
By:
Menu
Install the app
Install
Forums
New posts
All threads
Latest threads
New posts
Trending threads
Trending
Search forums
What's new
New posts
New ads
New profile posts
Latest activity
Free Ads
Latest reviews
Search ads
Members
Current visitors
New profile posts
Search profile posts
Contact us
Latest ads
Colombo
Kaduwela - Two Storey House for Sale
dilrasan
Updated:
Today at 2:23 PM
Ad icon
Wechat qr verification
Pawan2005
Updated:
Today at 1:28 AM
🚀 GOOGLE AI PRO 18 MONTHS ACTIVATION 🚀
sayuru bandara
Updated:
Yesterday at 5:34 PM
Pure VPN - Up to 27 Months
vgp
Updated:
Friday at 8:10 AM
එක පැකේජ් එකයි මාසෙටම Unlimited Internet. තාමත් DATA CARD දාන්න සල්ලි වියදම් කරනවද? අඩුම මිලට අපෙන්.
sayuru bandara
Updated:
Jun 2, 2026
Electronics
Vehicles
Property
Search
Reply to thread
Forums
General
ElaKiri Help
java help needed
Get the App
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Message
<blockquote data-quote="sihina_lahiru" data-source="post: 7285056" data-attributes="member: 149577"><p><span style="color: Red"><strong>5.</strong></span></p><p>Rewriting Interfaces</p><p> <p style="margin-left: 20px"> Consider an interface that you have developed called DoIt: <p style="margin-left: 20px">public interface DoIt {</p> <p style="margin-left: 20px"> void doSomething(int i, double x);</p> <p style="margin-left: 20px"> int doSomethingElse(String s);</p> <p style="margin-left: 20px">}</p> <p style="margin-left: 20px"></p></p> <p style="margin-left: 20px">Suppose that, at a later time, you want to add a third method to DoIt, so that the interface now becomes: <p style="margin-left: 20px">public interface DoIt {</p> <p style="margin-left: 20px"></p> <p style="margin-left: 20px"> void doSomething(int i, double x);</p> <p style="margin-left: 20px"> int doSomethingElse(String s);</p> <p style="margin-left: 20px"> boolean didItWork(int i, double x, String s);</p> <p style="margin-left: 20px"> </p> <p style="margin-left: 20px">}</p> <p style="margin-left: 20px"></p></p> <p style="margin-left: 20px">If you make this change, all classes that implement the old DoIt interface will break because they don't implement the interface anymore. Programmers relying on this interface will protest loudly. Try to anticipate all uses for your interface and to specify it completely from the beginning. Given that this is often impossible, you may need to create more interfaces later. For example, you could create a DoItPlus interface that extends DoIt: </p><p style="margin-left: 20px">public interface DoItPlus extends DoIt {</p> <p style="margin-left: 20px"></p> <p style="margin-left: 20px"> boolean didItWork(int i, double x, String s);</p> <p style="margin-left: 20px"> </p> <p style="margin-left: 20px">}</p> <p style="margin-left: 20px"></p></p> <p style="margin-left: 20px"> Now users of your code can choose to continue to use the old interface or to upgrade to the new interface. </p></blockquote><p></p>
[QUOTE="sihina_lahiru, post: 7285056, member: 149577"] [COLOR=Red][B]5.[/B][/COLOR] Rewriting Interfaces [INDENT] Consider an interface that you have developed called DoIt: [INDENT]public interface DoIt { void doSomething(int i, double x); int doSomethingElse(String s); } [/INDENT] Suppose that, at a later time, you want to add a third method to DoIt, so that the interface now becomes: [INDENT]public interface DoIt { void doSomething(int i, double x); int doSomethingElse(String s); boolean didItWork(int i, double x, String s); } [/INDENT] If you make this change, all classes that implement the old DoIt interface will break because they don't implement the interface anymore. Programmers relying on this interface will protest loudly. Try to anticipate all uses for your interface and to specify it completely from the beginning. Given that this is often impossible, you may need to create more interfaces later. For example, you could create a DoItPlus interface that extends DoIt: [INDENT]public interface DoItPlus extends DoIt { boolean didItWork(int i, double x, String s); } [/INDENT] Now users of your code can choose to continue to use the old interface or to upgrade to the new interface. [/INDENT] [/QUOTE]
Insert quotes…
Verification
Nawa warak dahaya keeyada? (Namaya wadi kireema dahaya)
Post reply
Top
Bottom