자바2 기말고사 실습문제

범위: 처음부터 – 배운데까지 (DAO 패턴은 DB를 설치해야하므로 기말고사에서는 제외됨)

일시: 12/8 (화) 1:30-2:40

장소: online final exam (대면시험 vs 온라인시험 설문조사 실시 12/5~12/6 후 최종 결정은 online final exam)


Lab9 프로젝트 디렉토리 안에 모든 파일(src/*.java & bin/*.class)와 보고서 (장수제한없음)를 넣고 JAVA20-2_Lab9_학번_이름.zip 압축한 후 제출 (due by 11/30)



Lab8 프로젝트 디렉토리 안에 모든 파일(src/*.java & bin/*.class)와 보고서 (장수제한없음)를 넣고 JAVA20-2_Lab8_학번_이름.zip 압축한 후 제출 (due by 11/16)



Proxy, Decorator, Adapter, Bridge, Facade

Proxy, Decorator, Adapter, and Bridge are all variations on “wrapping” a class. But their uses are different.

Proxy could be used when you want to lazy-instantiate an object, or hide the fact that you’re calling a remote service, or control access to the object.

Decorator is also called “Smart Proxy.” This is used when you want to add functionality to an object, but not by extending that object’s type. This allows you to do so at runtime.

Adapter is used when you have an abstract interface, and you want to map that interface to another object which has similar functional role, but a different interface.

Bridge is very similar to Adapter, but we call it Bridge when you define both the abstract interface and the underlying implementation. I.e. you’re not adapting to some legacy or third-party code, you’re the designer of all the code but you need to be able to swap out different implementations.

Facade is a higher-level (read: simpler) interface to a subsystem of one or more classes. Suppose you have a complex concept that requires multiple objects to represent. Making changes to that set of objects is confusing, because you don’t always know which object has the method you need to call. That’s the time to write a Facade that provides high-level methods for all the complex operations you can do to the collection of objects. Example: a Domain Model for a school section, with methods like countStudents(), reportAttendance(), assignSubstituteTeacher(), and so on.

Proxy and Decorator both have the same interface as their wrapped types, but the proxy creates an instance under the hood, whereas the decorator takes an instance in the constructor.

Adapter and Facade both have a different interface than what they wrap. But the adapter derives from an existing interface, whereas the facade creates a new interface.

Bridge and Adapter both point at an existing type. But the bridge will point at an abstract type, and the adapter might point to a concrete type. The bridge will allow you to pair the implementation at runtime, whereas the adapter usually won’t.

Decorator vs Adapter

Decorator Pattern says wrap an original object and add additional features in the wrapper object.
Adapter pattern says changing one object by creating an instance of it and adding functionalities to it. These functionalities do not match those of the original object so we have to modify them, but we may also add our own extra methods which are not a part of the original object.

Decorator, attach additional responsibilities to an object dynamically. For example adding sugar in a coffee.
Adapter, adapts interface of an existing class to another interface. For example eletrical adapter.

Decorator is used to decorate individual objects at run-time.
Adapter is used to add features to the class and therefore to ALL of its objects.