2. 발표자 소개
임선용, 텔레톡비 CTO 짂성주 ( @geekbeast )
http://dicebattle.wordpress.com http://softwaregeeks.org
• 제 11회 JCO “Google App Engine과 • KTH – 플랫폼개발팀 PD
Android의 하모니” 발표 • (저) 앆드로이드 프로그래밍 : 제대로 된
• 책 공유 서비스 BooksTour, 모임 관리 앆드로이드 앱 개발을 위핚
서비스 MeetOK 등 수많은 스타트업 • SW 아키텍트 실무자 포럼 모바읷 분과
서비스 개발 위원, NIPA SW 공학센터
• 2011, 2012 공개SW 개발자대회 금상, • 2012 공개SW(OSS) 개발자대회 멘토,
은상 수상 공개소프트웨어협회
• 제 3회 슈퍼 앱 코리아 우수상 수상
3. 발표자 소개
임선용, 텔레톡비 CTO
http://dicebattle.wordpress.com
• 제 11회 JCO “Google App Engine과
Android의 하모니” 발표
• 책 공유 서비스 BooksTour, 모임 관리 서비스
MeetOK 등 수많은 스타트업 서비스 개발
• 2011, 2012 공개SW 개발자대회 금상, 은상
수상
• 제 3회 슈퍼 앱 코리아 우수상 수상
22. 02 빠르게 개발하려면
다른
Client 거 만들 때도 똑같네?
Client Client Client
Server Server Server Server
웹 페이지 웹 페이지 웹 페이지 웹 페이지
관리 콘솔 관리 콘솔 관리 콘솔 관리 콘솔
Infra Infra Infra Infra
53. 03 codebone 개발하며 > 소개
동영상
http://blog.softwaregeeks.org/archives/907
54. 03 codebone 개발하며 > 소개
Console Manager Domain A Org
Mana
Auth Menu
ger
Source Code
Mustache Mapper Spring
Domain B Sitemesh
Security
Object Relation Source Code
Manager Spring MVC
Domain C
Template File Loader Source Code Hibernate
Database Schema Domain D
Crawler
Source Code Spring
Source Generator Skeleton
55. 03 codebone 개발하며 > 소개
스키마 관계 분석 소스코드 생성
불러오기
Source Generator
Apache commons + SchemaCrawler + mustache
56. 03 codebone 개발하며 > 소개
{{#columns}}
public {{{javaType}}} get{{nameCamelcase}}(){
return {{name}};
}
{{/columns}}
Source Generator
public Long getIndex(){
return index;
}
public String getData(){
return data;
}
57. 03 codebone 개발하며 > 소개
Skeleton
Spring 3.1 + Hibernate + Jersey + Swagger + Bootstrap
74. 04 개발 하면서 > 메타데이터
DatabaseMetaData meta =
connector.getConnection().getMetaData();
복잡핚 JDBC
ResultSet datas = meta.getTables("", "", "", null);
while (datas.next()) {
out.println(datas.getString("TABLE_NAME"));
}
75. 04 개발 하면서 > 메타데이터
Java MySQL PostgreSQL Oracle
Integer INT INT INTEGER
Long BIGINT BIGINT X
Java Type, DB Type 불일치
String X X LONG
Date DATE DATE X
Java.sql.
X X DATE
Timestamp
Byte[] BLOB BLOB X
Java.sql.Blob X X BLOB
80. 04 개발 하면서 > 메타데이터
관계
• One To One
• One To Many
• Many To Many
81. 04 개발 하면서 > 메타데이터
OneToOne
People Partner
ID Name Partner_id ID Partner_Name
1 AMY 1 1 HENDEL
2 DARREL 3 2 SOPIA
3 LYDIA 2 3 LISA
4 SETH
82. 04 개발 하면서 > 메타데이터
OneToMany
Post User
ID Post_Title User_id ID Name
1 Hello World 2 1 Dice
2 I’m Hungry 1 2 Realbeast
3 Studying… 4 3 Samerook
4 Test! 1 4 Anbaeng
83. 04 개발 하면서 > 메타데이터
ManyToMany
Mapping Table
Programmer Prog_id Lang_id Language
ID Name 1 1 ID Lang_Title
1 Dice 1 2 1 C
2 Realbeast 2 2 2 Java
3 Samerook 2 3 3 Python
4 Anbaeng 3 1 4 Objective-C
3 3
4 4
84. 04 개발 하면서 > 메타데이터
관계
• One To One
• One ToKey, Foreign Key 등
Primary Many
메타 데이터 관계!
• Many To Many
85. 04 개발 하면서 > 메타데이터
for (Column column : table.getColumns()) {
if (column.isPartOfForeignKey()) {
if (isUniqueColumn (column)) {
relation = new Relationship(column, OneToOne);
} else {
relation = new Relationship(column, OneToMany);
}
94. 04 개발 하면서 > 메타데이터
Swagger
http://developers.helloreverb.com/swagger
95. 04 개발 하면서 > 메타데이터
Annotation
@POST
@ApiOperation(value = “User Create")
public User create(
@ApiParam(value="Creating User Data“)
@ModelAttribute User model) {
return service.create(model);
}
96. 04 개발 하면서 > 메타데이터
JSON Data
{ "apiVersion" : "0.2",
"apis" : [ { "description" : "Operations about user",
"operations" : [ { "httpMethod" : "POST",
"nickname" : "createUsersWithArrayInput",
"parameters" : [ { "allowMultiple" : false,
"dataType" : "Array[User]",
"description" : "List of user object",
"paramType" : "body",
"required" : true
} ],
"responseClass" : "void",
"summary" : "Creates list of users with given input array"
} ],
"path" : "/user.{format}/createWithArray"
},
107. 04 개발 하면서 > 다양핚 요구사항
• 테이블 이름을 Camelcase 로 변환해줘
• Primary Key 이고 Auto increment 이면
입력 시 제외시켜줘
변화에 대처하기 어려움
• OneToOne 관계에서는 특정핚 키워드로
변환해줘
• 데이터 타입이 timestamp 읷 때 사용자에
맞게 뭘 해줘…
• 컬럼 설명을 가져와서 변환해줘
120. 04 개발 하면서 > 서버와 모바읷을 핚방에
@POST
@Consumes("application/json")
public User create(
REST API 자동 생성!
@ModelAttribute User model) {
return service.create(model);
}
121. 04 개발 하면서 > 서버와 모바읷을 핚방에
백엔드는 자동화를 했는데
모바일은?!
122. 04 개발 하면서 > 서버와 모바읷을 핚방에
클라이언트 네트워크 통싞은
다운로드 업로드
- 네트워크 통싞 - 객체를 데이터로
- 데이터를 객체로 - 네트워크 통싞
upload
download
123. 04 개발 하면서 > 서버와 모바읷을 핚방에
Java http client code
HttpClient client = new DefaultHttpClient();
HttpGet get = new HttpGet();
get.setURI(new URI("http://www.google.com/"));
HttpResponse resp = client.execute(get);
BufferedReader br = new BufferedReader(new
InputStreamReader(resp.getEntity().getContent()));
String str = null;
StringBuffer sb = new StringBuffer();
while ((str = br.readLine()) != null) {
sb.append(str).append(" ");
}
br.close();
125. 04 개발 하면서 > 서버와 모바읷을 핚방에
Spring for Android code
HttpHeaders requestHeaders = new HttpHeaders();
requestHeaders.setContentType(new
MediaType("text", "xml"));
HttpEntity<String> requestEntity = new
HttpEntity<String>(requestHeaders);
과연 좋아졌나요?
String url = “http://google.com";
RestTemplate restTemplate = new RestTemplate();
ResponseEntity<String> responseEntity =
restTemplate.exchange(url,
HttpMethod.GET, requestEntity, String.class);
String result = responseEntity.getBody();
126. 04 개발 하면서 > 서버와 모바읷을 핚방에
retrofit
https://github.com/square/retrofit
127. 04 개발 하면서 > 서버와 모바읷을 핚방에
사용자 정보 조회 API
https://api.github.com/users/{user_id}
128. 04 개발 하면서 > 서버와 모바읷을 핚방에
사용자 클래스
class User {
String id;
String login;
String name;
String blog;
String avatar_url;
}
129. 04 개발 하면서 > 서버와 모바읷을 핚방에
통싞핛 인터페이스 정의
interface GitHub {
@GET("users/{id}")
User getUser(@Named("id")
String id);
}
130. 04 개발 하면서 > 서버와 모바읷을 핚방에
실제 통싞
RestAdapter restAdapter = new
RestAdapter.Builder()
.setServer(“https://api.github.com/”)
.build();
GitHub github =
restAdapter.create(GitHub.class);
User me = github.getUser("realbeast");
131. 04 개발 하면서 > 서버와 모바읷을 핚방에
public interface {{tableNameCamelcase}}RestService {
@POST("/api/{{mappingUri}}")
void create(@SingleEntity {{tableNameCamelcase}}
{{tableNameLowercase}});
@GET("/api/{{mappingUri}}")
List<{{tableNameCamelcase}}> getList(@Named("page") int page);
@GET("/api/{{mappingUri}}/{id}")
{{tableNameCamelcase}} get(@Named("id") {{primaryKeyType}} id);
@PUT("/api/{{mappingUri}}/{id}")
void update(@SingleEntity {{tableNameCamelcase}}
{{tableNameLowercase}});
@DELETE("/api/{{mappingUri}}/{id}")
{{tableNameCamelcase}} delete(@Named("id") {{primaryKeyType}}
id);
143. 04 개발 하면서 > Git,Versioning
http://www.sourcetreeapp.com
144. 04 개발 하면서 > Git,Versioning
http://www.syntevo.com/smartgithg
145. 04 개발 하면서 > Git,Versioning
http://opentutorials.org
146. 04 개발 하면서 > Git,Versioning
http://learnbranch.urigit.com/
147. 04 개발 하면서 > Git,Versioning
http://goo.gl/H9vKa
148. 04 개발 하면서 > Git,Versioning
배포를 하려고 하는데 버젂은 어떻게?
149. 04 개발 하면서 > Git,Versioning
http://semver.org
핚글 : http://spoqa.github.com/2012/12/18/semantic-versioning.html
150. 04 개발 하면서 > Git,Versioning
X.Y.Z (Major.Minor.Patch)
• 중요 업데이트 : 1.0.0 -> 2.0.0
• 마이너 업데이트 : 1.1.0 -> 1.2.0
• 버그 개선 버젂 : 0.1.1 -> 0.1.2
• 최초 개발 버젂 : 0.1.0
• 선행배포 : 0.X.0-alpha, 0.X.0-beta
• 빌드버젂 : 0.1.1+build.29