레이블이 Programming인 게시물을 표시합니다. 모든 게시물 표시
레이블이 Programming인 게시물을 표시합니다. 모든 게시물 표시

2015년 1월 2일 금요일

Everyone In Management Is A Programmer

http://techcrunch.com/2015/01/01/everyone-in-management-is-a-programmer/

Editor’s note: Adam Evans is the co-founder and CTO of RelateIQ.
When it comes to the task of finding and nurturing great engineering managers, misunderstandings at startups are all too common. It seems that many people assume great engineers don’t want to “give up” coding to take on leadership roles. To be clear, this is flat out wrong — and could create tremendous churn in your talent pool if you fail to recognize and elevate leaders in engineering as you would with any other team.
But, you might argue, engineers are introverted, right? And they would rather ponder big problems than worry about resource allocation? And they aren’t really interested in business problems as much as tech problems, correct?
The answer to all of these suppositions is “Not really.” All of these are just biases, or preconceived notions of what an engineer is like. We have some fantastically chatty engineers, and we have some quiet ones. We have some developers who would kill me if I asked them to do performance reviews, and some who genuinely enjoy coaching and mentoring as part of their jobs. It just depends.
Engineers, like all other teammates within your organization, run the gamut in terms of interest and proclivity for management roles. Some, I’ve found, just need a nudge to get there. They need you to frame the challenge in the right way to make it accessible to them.
So here’s my pitch to my engineering team: Anyone involved in management is aprogrammer. Being a leader within your organization requires you to master the art of motivating and coaching people, which isn’t all that different from, say, programming a person.
Sounds silly, I know, but think about it: As a programmer, your sole mission is to get a computer to do what you tell it to do — run the program the way you designed it to run. You spend all day trying to get that computer sitting across from you to follow your instructions. And it’s really stubborn. One bad keystroke and it doesn’t listen to anything you say. Maybe this metaphor is becoming more clear to anyone who has had a challenging direct report in the past.
There are major differences between programming computers and programming humans, of course, not the least of which is that some runtimes are much more volatile when you’reprogramming people.
Talking about programming humans really mimics how an engineer approaches a problem. Framing the management role in this way makes it instantly accessible, even to developers who never saw themselves enjoying management — and that’s something we can all agree is a welcome development.

2014년 4월 12일 토요일

DB서버 연동(1)

http://day0429.dothome.co.kr/xe/index.php?mid=android&document_srl=819

안드로이드 앱을 만들던 중 DB와 서버 연동에 대해, 알아보다가 안드로이드에서는 JDBC를 지원안한다는점을 알게 되었다.
때문에, 안드로이드와 DB서버 간 1:1 연동은 불가 하다는 점.

해결책의 방법으로, 
1. DB서버에서 php등을 이용하여 XML파일로 바꿔주고 그 XML파일을 안드로이드에서 파싱하는 방법
2. DB파일을 생성해서 서버에 두고, 안드로이드에서 그 DB를 다운로드 시켜서 안드로이드 내부 DB에 저장시키는방법
을 알게되었다.

그 중 1번째 방법을 소개.

( php로 DB서버와 연동해서 XML 파일만드는건 따로 글을 게재. 이번에는 XML파일과 안드로이드 파싱에 대해 소개)

XML파일 준비
<order>

<name>test1</name>
<list>test</list>
<source>www.naver.com</source>

</order>


JAVA XML 파싱
boolean inname = false;
boolean inlist = false;
boolean insource = false;

String Name = "";
String List = "";
String SOURCE = "";

try {
                      //다운제한 풀기
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
.permitAll().build();
StrictMode.setThreadPolicy(policy);

String xml = "서버 주소";
URL URL = new URL(xml);
InputStream in = URL.openStream();
XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
XmlPullParser parser = factory.newPullParser();
parser.setInput(in, "utf-8");

int eventType = parser.getEventType();
while (eventType != XmlPullParser.END_DOCUMENT) {
switch (eventType) {
case XmlPullParser.START_DOCUMENT:
break;
case XmlPullParser.END_DOCUMENT:
break;
case XmlPullParser.START_TAG:
if (parser.getName().equals("name")) {
inname = true;
} else if (parser.getName().equals("list")) {
inlist = true;
}else if (parser.getName().equals("source")) {
insource = true;
}
break;
case XmlPullParser.END_TAG:
break;
case XmlPullParser.TEXT:
if (inname) {
Name = parser.getText();
inname = false;
} else if (inlist) {
List = parser.getText();
inlist = false;
else if (insource) {
SOURCE = parser.getText();
insource = false;
}
break;
}
eventType = parser.next();
}
} catch (Exception e) {
Toast.makeText(this, "Parsing Fail", Toast.LENGTH_LONG).show();
}

즉, 태그 값으로 필터링하여 값을 자바변수에 적용시키는 것이다.
주의점은 다운제한을 풀어주어야한다는것

2014년 4월 4일 금요일

안드로이드(android)에서 java 의 HttpClient 4.0 클래스를 이용한 네트웍 프로그램 구현

http://mainia.tistory.com/568


개발환경 : JDK 1.5, eclipse-galileo, Google API 7(android API 2.1), window XP

org.apache.http.client.HttpClient 클래스는 안드로이드 뿐만 아니라 여러가지로
쓸만한데가 많아서 몇가지 예제를 정리 하였다나 같은 경우에는 안드로이드에서
서버와 통신하며 데이터를 받아올 때 사용한다안드로이드 API 내부에 HttpCliet
가 포함되어있기 때문이다.

(1) HttpClient 를 이용하여 POST 방식으로 멀티파일 업로드 구현

이 예제는 java application 으로 만든것이다서버에 WAS 가 돌고 있다면 멀티 파일 업로드가
가능하다로컬상에 web application 하나 구현해 놓고 테스트 해보면 될것이다.

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import java.io.File;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.HttpVersion;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.mime.MultipartEntity;
import org.apache.http.entity.mime.content.ContentBody;
import org.apache.http.entity.mime.content.FileBody;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.params.CoreProtocolPNames;
import org.apache.http.util.EntityUtils;
 
 
public class PostFile {
  public static void main(String[] args) throws Exception {
    HttpClient httpclient = new DefaultHttpClient();
    httpclient.getParams().setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1);
 
    HttpPost httppost = new HttpPost("http://localhost:9001/upload.do");
    File file = new File("c:/TRASH/zaba_1.jpg");
 
    MultipartEntity mpEntity = new MultipartEntity();
    ContentBody cbFile = new FileBody(file, "image/jpeg");
    mpEntity.addPart("userfile", cbFile);
 
 
    httppost.setEntity(mpEntity);
    System.out.println("executing request " + httppost.getRequestLine());
    HttpResponse response = httpclient.execute(httppost);
    HttpEntity resEntity = response.getEntity();
 
    System.out.println(response.getStatusLine());
    if (resEntity != null) {
      System.out.println(EntityUtils.toString(resEntity));
    }
    if (resEntity != null) {
      resEntity.consumeContent();
    }
 
    httpclient.getConnectionManager().shutdown();
  }
}

(2) HttpClient  를 이용하여 일반 데이터 전송받기

이 예제는 파일이 아닌 일반 text 데이터를 BasicNameValuePair 담아서 전송한다하나하나 담은
데이터는 다시 ArrayList 클래스에 넣고 UrlEncodedFormEntity 클래스로 UTF-8 로 인코딩한다.
서버에서 작업된 내용을 받을때는 ISO-8859-1 디코더해서 BufferedReader 로 읽어 들인다
그리고 마지막에 getConnectionManager().shutdown() ; 해준다.
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
InputStream is = null;
String totalMessage = "";
HttpClient httpclient = new DefaultHttpClient();
try {
    /** 연결 타입아웃내에 연결되는지 테스트, 5초 이내에 되지 않는다면 에러 */
    String id = "id";
    String pwd = "password";
     
    ArrayList<namevaluepair> nameValuePairs = new ArrayList<namevaluepair>();
    nameValuePairs.add(new BasicNameValuePair("ID", id));
    nameValuePairs.add(new BasicNameValuePair("PWD", pwd));
         
    /** 네트웍 연결해서 데이타 받아오기 */
    String result = "";
    HttpParams params = httpclient.getParams();
    HttpConnectionParams.setConnectionTimeout(params, 5000);
    HttpConnectionParams.setSoTimeout(params, 5000);
 
    HttpPost httppost = new HttpPost(url);
    UrlEncodedFormEntity entityRequest =
new UrlEncodedFormEntity(nameValuePairs, "UTF-8");
    httppost.setEntity(entityRequest);
         
    HttpResponse response = httpclient.execute(httppost);
    HttpEntity entityResponse = response.getEntity();
    is = entityResponse.getContent();
     
    /** convert response to string */
    BufferedReader reader = new BufferedReader(new InputStreamReader(
            is, "iso-8859-1"), 8);
    StringBuilder sb = new StringBuilder();
    String line = null;
    while ((line = reader.readLine()) != null) {
        sb.append(line).append("\n");
    }
    is.close();
    result = sb.toString();
         
} catch (IOException e) {
    e.printStackTrace();
} chatch (Exception e)
    e.printStackTrace();
 
} finally {
    httpclient.getConnectionManager().shutdown();
}
</namevaluepair></namevaluepair>

위의 내용은 아이디/패스를 서버에 전달하고 그 결과값을 받기 위해서 만들었던 것이다.
서버나 네트웍 상태가 안좋아서 데이터를 받아 올수 없을 때 무작정 기다릴수 없으므로
5초로 셋팅해주었다. 5초 이상 반응이 없으면 exception 을 던지게 된다.

이것으로 안드로이드에서 실시간 서비스정보구현을 위한 기본적인 코딩은 된것이다.
추가로 구현해야될 사항은 네트웍 연결부분을 별도의 쓰레드로 돌려야 되고 , 데이터를
받고 전달해줄 서버를 구현해야한다그리고 JSON 프로토콜을 사용할것이 때문에
JSON 파싱을 위한 구현을 해야한다.