design patterns - Extend multiple Java classes without duplication -


i have java class can extend either of 2 third-party classes, cannot change. can choose either of these implementations @ compile time no changes class other "extends" declaration. unfortunately need choose implementation use @ runtime, not @ compile time. what's best way select between these 2 implementations @ run-time without duplicating entire derived class?

it sounds require strategy pattern.

the strategy pattern (also known policy pattern) particular software design pattern, whereby algorithms can selected @ runtime.

so java class should contain reference 1 of 2 classes want use, , bridge implementation. implementation choose can selected @ runtime. it's not clear problem description, if 2 3rd-party classes implement common interface, java class implement interface , can directly map referenced 3rd-party class.


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -