0% found this document useful (0 votes)
41 views14 pages

Design Patterns

Design patterns are best practices used by experienced software developers to solve common problems. They have been developed over time through trial and error. Some key advantages of design patterns are that they provide reusable and proven solutions, help standardize language among developers, and make the code more flexible and extensible. The adapter pattern in particular acts as a bridge between two incompatible interfaces, allowing classes to work together that otherwise could not due to incompatible interfaces.

Uploaded by

nm
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views14 pages

Design Patterns

Design patterns are best practices used by experienced software developers to solve common problems. They have been developed over time through trial and error. Some key advantages of design patterns are that they provide reusable and proven solutions, help standardize language among developers, and make the code more flexible and extensible. The adapter pattern in particular acts as a bridge between two incompatible interfaces, allowing classes to work together that otherwise could not due to incompatible interfaces.

Uploaded by

nm
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

Design Patterns

 Design patterns represent the best practices


used by experienced object-oriented
software developers.
 Solutions to general problems that software
developers faced during software
development.
 Obtained by trial and error by numerous
software developers over quite a substantial
period of time.
Design Patterns have two main usages in software
development.
Common platform for developers
Best Practices
 Design patterns have been evolved over a long
period of time and they provide best solutions to
certain problems faced during software
development.
 Learning these patterns helps unexperienced
developers to learn software design in an easy and
faster way.
 Smart
 Generic
 Well-proven
 Simple
 Reusable
 Object Oriented
 Bridge between two incompatible interfaces.
 Comes under structural pattern as this pattern
combines the capability of two independent interfaces.
 A single class which is responsible to join
functionalities of independent or incompatible
interfaces.
 Card reader which acts as an adapter between memory
card and a laptop.
 Example in which an audio player device can play mp3
files only and wants to use an advanced audio player
capable of playing vlc and mp4 files.
 MediaPlayer interface and a concrete
class AudioPlayer implementing
the MediaPlayer interface. AudioPlayer can play mp3 format
audio files by default.
 Interface AdvancedMediaPlayer and concrete classes
implementing the AdvancedMediaPlayer interface. These
classes can play vlc and mp4 format files.
 Want AudioPlayer to play other formats as well, we created an
adapter class MediaAdapter which implements
the MediaPlayer interface and
uses AdvancedMediaPlayer objects to play the required format.
 AudioPlayer uses the adapter
class MediaAdapter passing it the desired
audio type without knowing the actual class
which can play the desired
format. AdapterPatternDemo, our demo
class will use AudioPlayer class to play various
formats.
 Bernd Bruegge & Alllen H. Dutoit- Object
Oriented Software Engineering- Using UML,
Patterns and Java

You might also like