OOP 소개

Similar documents
OOP 소개

11 템플릿적용 - Java Program Performance Tuning (김명호기술이사)

PowerPoint 프레젠테이션

01-OOPConcepts(2).PDF

09-interface.key

제8장 자바 GUI 프로그래밍 II

rmi_박준용_final.PDF

PowerPoint 프레젠테이션

05-class.key

어댑터뷰

PowerPoint 프레젠테이션

JMF3_심빈구.PDF

5장.key

02 C h a p t e r Java

PowerPoint 프레젠테이션

1

13ÀåÃß°¡ºÐ

신림프로그래머_클린코드.key

Something that can be seen, touched or otherwise sensed

@OneToOne(cascade = = "addr_id") private Addr addr; public Emp(String ename, Addr addr) { this.ename = ename; this.a

Interstage5 SOAP서비스 설정 가이드

Design Issues

ilist.add(new Integer(1))과 같이 사용하지 않고 ilist.add(1)과 같이 사용한 것은 자바 5.0에 추가된 기본 자료형과 해당 객체 자료 형과의 오토박싱/언박싱 기능을 사용한 것으로 오토박싱이란 자바 컴파일러가 객체를 요구하는 곳에 기본 자료형

07 자바의 다양한 클래스.key

q 이장에서다룰내용 1 객체지향프로그래밍의이해 2 객체지향언어 : 자바 2

fundamentalOfCommandPattern_calmglow_pattern_jstorm_1.0_f…

2014밝고고운동요부르기-수정3

2005프로그램표지

第 1 節 組 織 11 第 1 章 檢 察 의 組 織 人 事 制 度 등 第 1 項 大 檢 察 廳 第 1 節 組 대검찰청은 대법원에 대응하여 수도인 서울에 위치 한다(검찰청법 제2조,제3조,대검찰청의 위치와 각급 검찰청의명칭및위치에관한규정 제2조). 대검찰청에 검찰총장,대

chap10.PDF

Microsoft PowerPoint - java1-lab5-ImageProcessorTestOOP.pptx

3ÆÄÆ®-11

자바GUI실전프로그래밍2_장대원.PDF

자바로

K&R2 Reference Manual 번역본

11강-힙정렬.ppt

PowerPoint Presentation

내지무인화_

PowerPoint Presentation

Spring Data JPA Many To Many 양방향 관계 예제

ch09

Microsoft PowerPoint - 04-UDP Programming.ppt

( )부록

Spring Boot/JDBC JdbcTemplate/CRUD 예제

Mobile Service > IAP > Android SDK [ ] IAP SDK TOAST SDK. IAP SDK. Android Studio IDE Android SDK Version (API Level 10). Name Reference V

비긴쿡-자바 00앞부속

A Tour of Java V

untitled

초보자를 위한 C# 21일 완성

_ƯÁý-½ºÆù

제목

untitled

제목

<C0CCBCBCBFB52DC1A4B4EBBFF82DBCAEBBE7B3EDB9AE2D D382E687770>

제 1 강 희망의 땅, 알고리즘

10장.key

DocsPin_Korean.pages

2002년 2학기 자료구조

JAVA PROGRAMMING 실습 08.다형성


Inclusion Polymorphism과 UML 클래스 다이어그램 구조에 의거한 디자인패턴 해석

PowerPoint Presentation

제11장 프로세스와 쓰레드

안드로이드기본 11 차시어댑터뷰 1 학습목표 어댑터뷰가무엇인지알수있다. 리스트뷰와스피너를사용하여데이터를출력할수있다. 2 확인해볼까? 3 어댑터뷰 1) 학습하기 어댑터뷰 - 1 -

Microsoft PowerPoint - 2강

<C0DAB7E120C7D5BABB2E687770>

- JPA를사용하는경우의스프링설정파일에다음을기술한다. <bean id="entitymanagerfactory" class="org.springframework.orm.jpa.localentitymanagerfactorybean" p:persistenceunitname=

유니티 변수-함수.key

* Factory class for query and DML clause creation * tiwe * */ public class JPAQueryFactory implements JPQLQueryFactory private f

12-file.key

No Slide Title

Microsoft PowerPoint - 09-Object Oriented Programming-3.pptx

A Tour of Java IV

소프트웨어개발방법론

Data Provisioning Services for mobile clients

03장

<4D F736F F F696E74202D20C1A63139C0E520B9E8C4A120B0FCB8AEC0DA28B0ADC0C729205BC8A3C8AF20B8F0B5E55D>

슬라이드 1

I T C o t e n s P r o v i d e r h t t p : / / w w w. h a n b i t b o o k. c o. k r

교육자료

PowerPoint Presentation

14-Servlet

[ 그림 8-1] XML 을이용한옵션메뉴설정방법 <menu> <item 항목ID" android:title=" 항목제목 "/> </menu> public boolean oncreateoptionsmenu(menu menu) { getme

소프트웨어 개발의 성공 열쇠 - 오브젝트 디자인

Microsoft PowerPoint - 테스트주도개발.pptx


rosaec_workshop_talk

자바 프로그래밍

쉽게 풀어쓴 C 프로그래밍

thesis

Microsoft PowerPoint - 14주차 강의자료

Java XPath API (한글)

JMF2_심빈구.PDF

Microsoft PowerPoint - Java7.pptx

Week5

목차 JEUS EJB Session Bean가이드 stateful session bean stateful sample 가이드 sample source 결과확인 http session에

PRO1_09E [읽기 전용]

Convenience Timetable Design

UML

Microsoft PowerPoint - RMI.ppt

Transcription:

OOP : @madvirus, : madvirus@madvirus.net : @madvirus : madvirus@madvirus.net ) ) ) 7, 3, JSP 2

? 3 case R.id.txt_all: switch (menu_type) { case GROUP_ALL: showrecommend("month"); case GROUP_MY: type = "all"; showmygroup(type, "newest"); case R.id.txt_share: switch (menu_type) { case GROUP_ALL: showgroup("newest"); case GROUP_MY: type = "share"; showmygroup(type, "share"); 4

case R.id.txt_all: switch (menu_type) { case GROUP_ALL: showrecommend("month"); case GROUP_MY: type = "all"; showmygroup(type, "newest"); case GROUP_FAVORITE: type = ""; showfavorite(type, "newest"); case GROUP_LIST: type = ""; showlist(type); case GROUP_WORDS: type = ""; showwordlist(type); case R.id.txt_share: switch (menu_type) { case GROUP_ALL: showgroup("newest"); case GROUP_MY: type = "share"; showmygroup(type, "share"); case GROUP_FAVORITE: type = "program"; showfavorite(type, "newest"); case GROUP_LIST: type = "PROGRAM"; showlist(type); case GROUP_WORDS: type = "PROGRAMCONTENT"; showwordlist(type); 5???? case R.id.txt_all: switch (menu_type) { case GROUP_ALL: showrecommend("month"); case GROUP_MY: type = "all"; showmygroup(type, "newest"); case GROUP_FAVORITE: type = ""; showfavorite(type, "newest"); case GROUP_LIST: type = ""; showlist(type); case GROUP_WORDS: type = ""; showwordlist(type); case R.id.txt_share: switch (menu_type) { case GROUP_ALL: showgroup("newest"); case GROUP_MY: type = "share"; showmygroup(type, "share"); case GROUP_FAVORITE: type = "program"; showfavorite(type, "newest"); case GROUP_LIST: type = "PROGRAM"; showlist(type); case GROUP_WORDS: type = "PROGRAMCONTENT"; showwordlist(type); case R.id.txt_n_share: switch (menu_type) { case GROUP_ALL: showgroup("hits"); case GROUP_MY: type = "unshare"; showmygroup(type, "unshare"); case GROUP_FAVORITE: type = "movie"; showfavorite(type, "newest"); case GROUP_LIST: type = "MOVIE"; showlist(type); case GROUP_WORDS: type = "MOVIE"; showwordlist(type); case R.id.txt_group: switch (menu_type) { case GROUP_ALL: showgroup("hits"); case GROUP_MY: type = "unshare"; showmygroup(type, "unshare"); case GROUP_FAVORITE: type = "group"; showfavorite(type, "newest"); case GROUP_LIST: type = "GROUP"; showlist(type); case GROUP_WORDS: type = "GROUP"; showwordlist(type); case R.id.btn_delete: if (btn_select.isshown()) { switch (menu_type) { case GROUP_MY: delete(); case GROUP_FAVORITE: deletefavorite(); else { hidebutton(); switch (menu_type) { case GROUP_MY: setmygrouplist(true); case GROUP_FAVORITE: setfavoritelist(true); 6

TOC vs 7 8

? 9 ( ) 10 객체지향 기초 소개, 최범균, 본 자료의 무단 배포를 금합니다.

11 /, 12

Object Oriented 13 14

15 16

(Object) TV 17, C# public class TV { public void increasevolume() { public void decreasevolume() { TV tv = new TV(); tv.increasevolume(); 18

/ (Responsibility) DB 19 SOLID S: Single Responsibility Principle HomeActivity HomeActivity TopFeatured ListView BottomBest ListView 20

( ) ( ) / ( ) 21 22

(Encapsulation) 23 : - public class ProceduralStopWatch { public long starttime; // (1/1000 ) public long stoptime; // 1/1000 public long getelapsedtime() { return stoptime - starttime; ProceduralStopWatch stopwatch = new ProceduralStopWatch(); stopwatch.starttime = System.currentTimeMillis(); // // stopwatch.stoptime = System.currentTimeMillis(); // long elapsedtime = stopwatch.getelapsedtime(); // 24

public class ProceduralStopWatch { public long starttime; public long stoptime; public long startnanotime; public long stopnanotime; - public long getelapsednanotime() { return stopnanotime - startnanotime; ProceduralStopWatch stopwatch = new ProceduralStopWatch(); stopwatch.startnanotime = System.nanoTime(); // // stopwatch.stopnanotime = System.nanoTime(); // long elapsedtime = stopwatch.getelapsednanotime(); // 25-26

- / public class StopWatch { private long starttime; private long stoptime; public void start() { starttime = System.currentTimeMillis(); public void stop() { stoptime = System.currentTimeMillis(); public Time getelapsedtime() { return new Time(stopTime - starttime); 27 / StopWatch stopwatch = new StopWatch(); stopwatch.start(); // starttime, // stopwatch.stop(); // stoptime, Time time = stopwatch.getelapsedtime(); // long time.getmillitime(); 28

- public class StopWatch { private long starttime; private long stoptime; public void start() { starttime = System.nanoTime(); public void stop() { stoptime = System.nanoTime(); public Time getelapsedtime() { return new Time(stopTime - starttime); public class Time { private long t; public Time(long t) { this.t = t; public long getmillitime() { return t / 1000000L; public long getnanotime() { return t; 29 StopWatch stopwatch = new StopWatch(); stopwatch.start(); // stopwatch.stop(); Time time = stopwatch.getelapsedtime(); time.getnanotime(); ProceduralStopWatch stopwatch = new ProceduralStopWatch(); stopwatch.startnanotime = System.nanoTime(); // // stopwatch.stopnanotime = System.nanoTime(); // long elapsedtime = stopwatch.getelapsednanotime(); // 30

-! 31 : Tell, Don't Ask 32

Tell, Don't Ask /,, if (member.getexpiredate().gettime() < System. System.currentTimeMillis) { if (member.isexpired()) { 33 Law of Demeter CQRS(Command Query Responsibility Segregation) 34

35 Polymorphism? Java/C# ' Inheritance' Motorcycle start() ZetMotorcycle start() ZetEngine zeton() AirPlane ZetMotorcycle zm = new ZetMotorcycle(); zm.start(); zm.zeton(); Motorcycle mc = zm; mc.start(); ZetEngine ze = zm; ze.zeton(); ZetEngine ap = new AirPlane(); ap.zeton(); 36

public class ZetEngine { public class AirPlane extends ZetEngine { AirPlane ap = new AirPlane(); ap.zeton(); public interface ZetEngine { public void zeton(); public interface Motorcycle { public void start(); public class ZetMotorcycle implements ZetEngine, Motorcycle { ZetMotorcycle zm = new ZetMotorcycle(); ZetEngine ze = zm; Motorcycle mc = zm; 37 Abstraction / / DB FTP SCP 38

( ) class FtpLogCollector { private String ftpserver; class FtpLogSet { class DBLogCollector { private String jdbcurl; class DBrowLogSet { interface LogCollector { LogSet collect(); interface LogSet { Iterator iterator(); 39 : class FtpLogCollector implements LogCollector { private String ftpserver; public LogSet collect() { class FtpLogSet implements LogSet { class DBLogCollector implements LogCollector { private String jdbcurl; public LogSet collect() { class DBrowLogSet implements LogSet { 40

LogCollector collector = new FtpLogCollector(ftpServer); LogSet logset = collector.collect(); Iterator iter = logset.iterator(); 41, DB 42

/ 43, FtpLogCollector collector = new FtpLogcollector(); FtpLogSet logset = collector.collect(); Iterator iter = logset.iterator(); FileLogCollector collector = new FileLogcollector(); FileLogSet logset = collector.collect(); Iterator iter = logset.iterator(); XXXLogCollector collector = new XXXLogcollector(); XXXLogSet logset = collector.collect(); Iterator iter = logset.iterator(); 44

( ) LogCollector collector = ; LogSet logset = collector.collect(); Iterator iter = logset.iterator(); LogCollector collector = ; LogSet logset = collector.collect(); Iterator iter = logset.iterator(); LogCollector collector = ; LogSet logset = collector.collect(); Iterator iter = logset.iterator(); 45 / : LogCollector collector = LogCollectorFactory.create(); LogSet logset = collector.collect(); Iterator iter = logset.iterator(); LogCollector collector = LogCollectorFactory.create(); LogSet logset = collector.collect(); Iterator iter = logset.iterator(); LogCollector collector = LogCollectorFactory.create(); LogSet logset = collector.collect(); Iterator iter = logset.iterator(); 46

/ : ( )! / if-else?., 47 :Composition over inheritance 48

( ) public class LuggageCompartment extends ArrayList<Luggage> { private int restspce; public void add(luggage piece) { this.restspace -= piece.getsize(); super.add(piece); public void cancontain(luggage piece) { return this.restspace > piece.size(); LuggageCompoartment lc = new LuggageCompartment(); lc.add(new Luggage(10)); //!! restspace! lc.remove(someluggage); lc.extract(anyluggage); lc.cancontain(aluggage); // public void extract(luggage piece) { this.restspace += piece.getsize(); super.remove(piece); 49 IS-A!=, ArrayList is a AbstractList 50

(composition) public class LuggageCompartment { private List<Luggage> luggages = new ArrayList<Luggage>(); private int restspce; public void add(luggage piece) { restspace -= piece.getsize(); luggages.add(piece); public void cancontain(luggage piece) { return this.restspace > piece.size(); public void extract(luggage piece) { restspace += piece.getsize(); luggage.remove(piece); 51 public class Calculator { private PriceStrategy strategy; public Calculator(PriceStrategy strategy) { this.strategy = strategy; public interface PriceStrategy { void apply(money price); public class RegularCustomerStrategy this.strategy.apply(price); public class FirstCustomerStrategy PriceStrategy strategy = new RegularCustomerStrategy(); Calculator cal = new Calculator(strategy); cal.calculate(); Calculator PriceStrategy strategy = new FirstCustomerStrategy(); Calculator cal = new Calculator(strategy); cal.calculate(); 52

/ 53 Seekbar/ Seekbar/ 54

public class Player { private TitleView titleview; private RecListView reclistview; private FuncButtonView funcbuttonview; private ClipPointView clippointview; private Controller controller; private boolean viewvisible; private int mode = 0; private void togglevisibility () { if (!viewshowing) { if (mode == 0) { titleview.show(); reclistview.show(); else if (mode == 1) { controller.show(); else { // if-else hide() 55 public class Player { private TitleView titleview; private RecListView reclistview; private FuncButtonView funcbuttonview; private ClipPointView clippointview; private Controller controller; private boolean viewvisible; private int mode = 0; mode / private void togglevisibility () { if (!viewshowing) { if (mode == 0) { titleview.show(); reclistview.show(); else if (mode == 1) { controller.show(); else { // if-else hide() 56

Player public class Player { private TitleView titleview; private RecListView reclistview; private FuncButtonView funcbuttonview; private ClipPointView clippointview; private Controller controller; private boolean viewvisible; private int mode = 0; public class Player { private ViewLayout layout; private void ontouch() { layout.togglevisibility(); private void togglevisibility () { if (!viewshowing) { if (mode == 0) { titleview.show(); reclistview.show(); else if (mode == 1) { controller.show(); else { // if-else hide() public class ViewLayout { private TitleView titleview; private RecListView reclistview; private Controller controller; private boolean viewvisible; private int mode = 0; public void togglevisibility () { 57 View public class ViewLayout { private TitleView titleview; private RecListView reclistview; private FuncButtonView funcbuttonview; private ClipPointView clippointview; private Controller controller; private boolean viewvisible; private int mode = 0; public interface View { public void show(); public void hide(); public class TitleView implements View { public void togglevisibility () { if (!viewshowing) { else { public class Controllerimplements View { 58

View public class ViewLayout { private TitleView titleview; private RecListView reclistview; private FuncButtonView funcbuttonview; private ClipPointView clippointview; private Controller controller; private boolean viewvisible; private int mode = 0; public class ViewLayout { private Map<Position, View> viewmap; public void setview( Position pos, View view) { viewmap.put(pos, view); private public void togglevisibility () { if (!viewshowing) { else { public void togglevisibility() { for (View view : viewmap.values()) { if (!viewshowing) { view.show(); else { view.hide(); viewshowing =!viewshowing; 59 ViewLayout public class ViewLayout { private Map<Position, View> viewmap; public void setview( Position pos, View view) { viewmap.put(pos, view); private public interface ViewLayout { public void togglevisibility(); public class BorderViewLayout implements ViewLayout { private Map<Position, View> viewmap; public void togglevisibility() { for (View view : viewmap.values()) { if (!viewshowing) { view.show(); else { view.hide(); viewshowing =!viewshowing; public void setview( Position pos, View view) { viewmap.put(pos, view); private public void togglevisibility() { 60

Player View View Player Player Layout Player View View BorderViewLayout 61 62

High Cohesion ( )!, Low Coupling ( ) 63 : <<<<,,, C# / Tell, Don't Ask Program To Interface Composition over Inheritance 64

UML, : SOLID (GoF ): TDD! Clean Code Implementation Pattern 65? 66