Java Interview Guide: How to Build Confidence With a Solid Understanding of Core Java Principles pdfdrive com



Yüklə 0,53 Mb.
Pdf görüntüsü
səhifə31/47
tarix06.05.2023
ölçüsü0,53 Mb.
#108601
1   ...   27   28   29   30   31   32   33   34   ...   47
Java Interview Guide

Structural Design Patterns
Structural design patterns solve common problems that arise due to the
relationship between different objects.


Adapter Pattern
The adapter pattern converts an incompatible object into a form that a module
accepts. This allows separate modules of code to communicate without coupling
them together. The Arrays#asList(Object[]) method is an example
of the adapter pattern.


Composite Pattern
The composite pattern treats a collection of objects as if it were a single object.
This is useful when a group of objects share similar functionality, such as the
elements of a Swing application. The Container#add(Component)
method is an example of the composite pattern.


Decorator Pattern
The decorator pattern provides additional behavior to an object by wrapping
it with a delegator. This provides a flexible alternative to creating multiple
subclasses. The Collections#unmodifiableList(List) method is an
example of the decorator pattern.


Facade Pattern
The facade pattern provides a simplified interface over a large body of code.
This is useful when a system is complex or poorly designed and clients are only
interested in a subset of functionality. The Logger interface in the SLF4J
library is an example of the facade pattern.


Flyweight Pattern
The flyweight pattern reduces the memory footprint of an application by reusing
objects. This is useful when a large number of immutable objects are frequently
instantiated. The Integer#valueOf(String) method is an example of the
flyweight pattern.


Questions
What is the adapter pattern? When is it useful?
What is the composite pattern? When is it useful?
What is the decorator pattern? When is it useful?
What is the facade pattern? When is it useful?
What is the flyweight pattern? When is it useful?



Yüklə 0,53 Mb.

Dostları ilə paylaş:
1   ...   27   28   29   30   31   32   33   34   ...   47




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©azkurs.org 2024
rəhbərliyinə müraciət

gir | qeydiyyatdan keç
    Ana səhifə


yükləyin