Skip to main content

Adapter Pattern

Adapter Pattern
wrapper라 불리기도 한다.


개념
기존 클래스를 사용하고 싶은데, 인터페이스가 맞지 않을 때, 이 수법을 사용한다.

예,
110볼트 어댑터를 220볼트 어댑티에 연결할 때, 우리는 변환 어댑터를 끼워사용한다.

적용 사례
인터페이스는 상속을 받고, 구현은 상속하지 않는다.


장단점

요약


Comments

Popular posts from this blog

Linux Resources Monitoring

dstat Requirements:python Dstat is a versatile replacement for iostat, vmstat and ifstat http://linux.softpedia.com/get/System/Diagnostics/Dstat-1401.shtml  - download the source file  - tar -xvjf dstate-0.7.2.tar.bz2  - cd dstate-0.7.2  - sudo make install 사용법 dstat -cdngys --top-io-adv --top-bio-adv 창넓이가 크면 dstat -cdngys --top-io --top-bio dstat 기본옵션은 -cdngy 2. pktstat requirements: libpcap-devel, ncurses-devel pktstat man page 사용법:sudo pktstat -i eth0 -T -l 실행결과 interface: eth0    total: 43.9Mb (3s) cur: 12.3M (78%) min: 12.3M max: 15.8M avg: 14.5M bps    bps    %      b desc   1.4k   0%   4.3k arp  591.8   0%   1.2k ip proto 88 55.101.66.3 <-> igrp-routers  91.3k   0%  91.3k tcp a100236:4478 <-> console:ssh  42.6k   0% 216.4k tcp a100390:mailprox <-> console:ssh   1.1k   0%   ...

nginx로 다중 포트 설정 및 다중 react app 설정

nginx에 다중 포트 설정하기 react로 여러 webapp를 개발하고, 동일한 서버에 실행시킬 필요가 있다. 이때 간단히 nginx에서 다중포트로 여러 webapp를 동일한 서버에서 실행시킬 수 있다. /etc/nginx/sites-available/에 default 파일이 있다. 보통 port 80로 설정되어 있다. 이 파일을 복사해서 sub로 명명한다.   아래와 같이 포트 8080으로 정하고, react app를 build한 디렉터리를 root <dir>로 지정하고, $> sudo service nginx restart 하면 된다. $>sudo systemctl status nginx.service 로 nginx 상태 확인이 가능하면, $> netstat -ano | grep 8080 으로 8080 포트가 살아있는 또는 외부PC에서  $>telnet ip 8080으로 telnet 접속이 되는지 확인하면 된다. 종종 Nginx 500 Interval Server Error가 발생하는데, 이는 1) root <dir>에서 <dir> 주소가 정확하지 않거나, 2) 파일 권한이 없거나이다. chmod 755 <dir>하면 대부분 해결될 것이다. 그럼 오늘도 유익한 하루 되시길..   

gnome screen

screen nano editor에서 빠져나오기 C+x가 screen prefix 일 경우, nano 에디터에서 빠쪄나오기 어렵다. 이때는 C+t, C+z하면 background 처리한 후, kill 명령어로 nano 실행 프로세스를 죽여야 한다.     그리고 crontab -e를 실행할 때, export VISUAL=vim; crontab -e로 실행해라.     screen session title를 변경 원할 경우 C+x, shift+a 하면 각 창 제목을 변경할 수 있다.     user's manual http://www.delorie.com/gnu/docs/screen/screen_toc.html - Run a new screen session # screen - Reattach to a previously detatched session # screen -R - Create a new window. # '''prefix''' c - Kill the current window - after confirmation # '''prefix''' k - 현재 창의 창 번호를 변경하는 방법 예 창번호 3에서 1로 변경할 경우, 먼저 창 3으로 이동한 상태에서 # '''prefix''' :number 1 [enter]하면 창번호3이 1로 변경됨.  - Switch to the other window # '''prefix''' space - Detach & Attach screen を起動した状態で、 # Ctrl-z d or Ctrl-z ^D とすると、screenを起動する前のシェルに戻ります。screenはバックグランドで動いています。これを「Detachedデタッチ」と言います。 Attachedとは「再開」 デタッチしたセッションを確認...