'분류 전체보기'에 해당되는 글 80건

  1. 2008.04.01 Page Replacements Algorithm by 파이팅야 2
  2. 2008.03.28 Collection 클래스 정리(자료구조) by 파이팅야 3
  3. 2008.03.26 JCO 다녀오며 by 파이팅야 1
  4. 2008.03.26 Eclipse 단축키 by 파이팅야 1
  5. 2008.03.18 ms-sql DB 연결문자 in iBatis by 파이팅야 2
  6. 2008.03.18 aggregation vs composition by 파이팅야 2
  7. 2008.03.17 Reflection Modifier의 보안문제 by 파이팅야 1
  8. 2008.03.16 구글 광고 by 파이팅야 2
  9. 2008.03.16 .net byte vs java byte by 파이팅야 3
  10. 2008.03.16 검색엔진 연산어... by 파이팅야 1

Demand Paging은 말그대로 프로세스의 필요한 page만 요청해서 사용하는 벙법이다. 현재 사용되지 않는 페이지는 가상 메모리에서 있게되며, 요청이 있을 경우 실제 메모리에 Swap in 되고, 사용이 끝나면 다시 가상 메모리로 Swap out 된다. 이때 어떤 페이지가 실제 메모리에 있고, 어떤 페이지가 swap out되어 가상 메모리에 있는지를 알기 위해서 Valid/Invalid bit set을 추가한다

우선 프로세스가 요구한 페이지가 Frame에 있는지 확인한다. Frame에 없을 경우 Frame이 꽉 찼을 경우 어떤 프레임에 있는 페이지를 쫓아내고 요청된 페이지를 올려야 한다. Frame에 있는 페이지를 쫓아내는 방법 Replacement Algorithm이라고 한다.

FIFO 기법
FIFO(First-In First-Out) 기법은 주기억 장치에 가장 먼저 적재된 페이지를 교체합니다. 이를 위해서는 페이지들의 주기억 장치 적재 시간을 기록해두어야 하는데, 사용 빈도가 높은 프로그램의 페이지들이 교체될 가능성이 높습니다.

time

0

1

2

3

4

5

6

7

8

9

10

w

 

c

a

d

b

e

b

a

b

c

d

frame 0

a-

a-

a-

a-

a-

e

e

e

e

e-

d

frame 1

b

b

b

b

b

b-

b-

a

a

a

a-

frame 2

c

c

c

c

c

c

c

c-

b

b

b

frame 3

d

d

d

d

d

d

d

d

d*

c

c

page fault

 

 

 

 

 

1

 

2

3

4

5

page(s) loaded

 

 

 

 

 

e

 

a

b

c

d

page(s) removed

 

 

 

 

 

a

 

b

c

d

e

 

FIFO with Second Chance(CLOCK, Sencd Chance)

FIFO방식에 referece bit을 추가한 방식이다. FIFO를 생각해보면 Queue에서 head부분을 victim으로 선택해서 replace했다. 여기에 각각의 페이지에 reference bit을 추가한다. , 페이지가 한번이라도 호출이 되었다면 reference bit 1로 만든다. 0은 한번도 호출이 안되었다는 말이다. FIFO방식에서 Queue head victim으로 선택할때 그 페이지의 reference bit을 체크해서 만약에 0이라면 그냥 replace한다. 왜냐하면 한번도 호출되지 않았다. (, 잘 사용 빈도가 적다는 말이다.) 그리고 reference bit 1이라면 replace하지 않고 다음 페이지로 건너뛴다. 이때, 1이었던 reference bit 0으로 만든다. 이것이 second-chance. , 한번의 기회를 더 주겠다는 말이다.

(- Check the reference-bit of the oldest page

- If it is 0, then replace it

- If it is 1, clear the reference-bit, move it to end of list, and continue searching

- Fast and does not replace a heavily used page, The worst case may take a long time)

This policy is similar to LRU and FIFO. Whenever a page is referenced, the use bit is set. When a page must be replaced, the algorithm begins with the page frame pointed to. If the frame's use bit is set, it is cleared and the pointer advanced. If not, the page in that frame is replaced. Here the number after the page is the use bit; we'll assume all pages have been referenced initially

time

0

1

2

3

4

5

6

7

8

9

10

w

 

c

a

d

b

e

b

a

b

c

d

frame 0

a

a/1-

a/1-

a/1-

a/1-

e/1

e/1

e/1

e/1

e/1-

d/1

frame 1

b

b/1

b/1

b/1

b/1

b/0-

b/1-

b/0

b/1

b/1

b/0

frame 2

c

c/1

c/1

c/1

c/1

c/0

c/0

a/1

a/1

a/1

a/0

frame 3

d

d/1

d/1

d/1

d/1

d/0

d/0

d/0-

d/0-

c/1

c/0

page fault

 

 

 

 

 

1

 

2

 

3

4

page(s) loaded

 

 

 

 

 

e

 

a

 

c

d

page(s) removed

 

 

 

 

 

a

 

c

 

d

e

 

무작위 기법
무작위(Random) 기법은 원칙없이 임의로 교체 대상 페이지를 선정하는 기법으로, 교체될 페이지를 선정하는 오버헤드는 적지만 페이지 부재 횟수를 줄이려는 어떠한 시도도 하지 않습니다.

 

NRU or NUR(Not-Recently-Used or Not Used Recently) 기법

NUR(Not Used Recently) 기법은 적은 오버헤드로 LRU 기법의 성능을 내기 위한기법으로, 이 기법에서는 근래에 쓰이지 않은 페이지는 가까운 미래에도 쓰이지 않을 가능성이 많기 때문에 이러한 페이지를 호출되는 페이지와 교체합니다. NUR 기법에서는 참조 비트와 갱신 비트의 조합을 검사하여 페이지를 교체합니다. 참조 비트는 일정 주기마다 '0' 으로 재설정되며, 이후 해당 페이지가 참조되면'1' 로 설정됩니다. 갱신 비트는 내용이 갱신되었을 경우 '1'로 설정되어 해당 페이지의 내용을 디스크로 옮겨야 함을 나타냅니다.

(-Randomly pick a page from the following (in order)

1)Not referenced and not modified

2)Not referenced and modified

3)Referenced and not modified

4)Referenced and modified

- Easy to implement, Not very good performance, takes time to classify)

This policy selects for replacement a random page from the following classes (in the order given): not used or modified, not used but modified, used and not modified, used and modified. In the following, assume references 2, 4, and 7 are writes. The two numbers written after each page are the use and modified bits, respectively.)

time

0

1

2

3

4

5

6

7

8

9

10

w

 

c

a*

d

b*

e

b

a*

b

c

d

frame 0

a

a/00

a/11

a/11

a/11

a/01

a/01

a/11

a/11

a/01

a/01

frame 1

b

b/00

b/00

b/00

b/11

b/01

b/11

b/11

b/11

b/01

b/01

frame 2

c

c/10

c/10

c/10

c/10

e/10

e/10

e/10

e/10

e/00

d/10

frame 3

d

d/00

d/00

d/10

d/10

d/00

d/00

d/00

d/00

c/10

c/10

page fault

 

 

 

 

 

1

 

 

 

2

3

page(s) loaded

 

 

 

 

 

e

 

 

 

c

d

page(s) removed

 

 

 

 

 

c

 

 

 

d

e

 

 

LRU 기법
LRU(Least Recently Used)
기법은 참조된 시간을 기준으로 교체될 페이지를 선정하는 기법으로, 가장 오랫동안 참조되지 않은 페이지를 교체합니다. 이를 위해서는 적재되어 있는 페이지가 참조될 때마다 참조 시간을 기록해두어야 하기 때문에 그 오버헤드가 단점입니다. 하지만 LRU 기법은 최적의 기법인 MIN 기법의 성능에 가장 근사하게 접근한 기법으로, 실제로도 가장 많이 사용되고 있는 기법입니다
(어떤 시간값을 캐쉬Data마다 적제해서 구분하지는 않고 position을 변경해서 사용함, 물론 구현은 가능함)

This policy selects for replacement the page that has not been used for the longest period of time

time

0

1

2

3

4

5

6

7

8

9

10

w

 

c

a

d

b

e

b

a

b

c

d

frame 0

a

a

a

a

a

a

a

a

a

a

a

frame 1

b

b

b

b

b

b

b

b

b

b

b

frame 2

c

c

c

c

c

e

e

e

e

e

d

frame 3

d

d

d

d

d

d

d

d

d

c

c

page fault

 

 

 

 

 

1

 

 

 

2

3

page(s) loaded

 

 

 

 

e

 

 

 

c

d

 

page(s) removed

 

 

 

 

c

 

 

 

d

e

 

stack (top)

 

c

a

d

b

e

b

a

b

c

d

 

 

--

c

a

d

b

e

b

a

b

c

 

 

--

--

c

a

d

d

e

e

a

b

stack (bottom)

 

--

--

--

c

a

a

d

d

e

a


LFU or MFU
기법
LFU(Least Frequently Used)
기법은 참조된 횟수를 기준으로 교체될 페이지를 선정하는 기법으로, 가장 참조 횟수가 적은 페이지를 교체합니다. 이를 위해서는 페이지들이 참조될 때마다 참조 횟수를 누적시켜야 하기 때문에, 그 오버헤드가 단점입니다. 또한 최근에 적재된 페이지가 이후 참조될 가능성이 많음에도 불구하고 참조 횟수가 적어 교체될 가능성이 있습니다.

 

Least Frequently Used (LFU): ``replace page with smallest count''

Most Frequently Used (MFU): ``replace page with largest count''

 

LRU 알고리즘의 구현 예

public class LRUCache<K,V> {

private static final float   hashTableLoadFactor = 0.75f;

private LinkedHashMap<K,V>   map;

private int                  cacheSize;

 

/**

* Creates a new LRU cache.

* @param cacheSize the maximum number of entries that will be kept in this cache.

*/

public LRUCache (int cacheSize) {

   this.cacheSize = cacheSize;

   int hashTableCapacity = (int)Math.ceil(cacheSize / hashTableLoadFactor) + 1;

   map = new LinkedHashMap<K,V>(hashTableCapacity, hashTableLoadFactor, true) {

      // (an anonymous inner class)

      private static final long serialVersionUID = 1;

      @Override protected boolean removeEldestEntry (Map.Entry<K,V> eldest) {

         return size() > LRUCache.this.cacheSize; }}; }

 

public synchronized V get (K key) {

   return map.get(key); }

 

public synchronized void put (K key, V value) {

   map.put (key,value); }

 

public synchronized void clear() {

   map.clear(); }

 

public synchronized int usedEntries() {

   return map.size(); }

 

public synchronized Collection<Map.Entry<K,V>> getAll() {

   return new ArrayList<Map.Entry<K,V>>(map.entrySet()); }

 

} // end class LRUCache

 

public static void main (String[] args) {

   LRUCache<String,String> c = new LRUCache<String,String>(3);

   c.put ("1","one");                            // 1

   c.put ("2","two");                            // 2 1

   c.put ("3","three");                          // 3 2 1

   c.put ("4","four");                           // 4 3 2

   if (c.get("2")==null) throw new Error();      // 2 4 3

   c.put ("5","five");                           // 5 2 4

   c.put ("4","second four");                    // 4 5 2

   // Verify cache content.

   if (c.usedEntries() != 3)              throw new Error();

   if (!c.get("4").equals("second four")) throw new Error();

   if (!c.get("5").equals("five"))        throw new Error();

   if (!c.get("2").equals("two"))         throw new Error();

   // List cache content.

   for (Map.Entry<String,String> e : c.getAll())

      System.out.println (e.getKey() + " : " + e.getValue());

}

 

관련 URL 및 출처

- replacement algorithm관련

http://www.sci.csuhayward.edu/~billard/cs4560/node15.html

http://people.msoe.edu/~mccrawt/resume/papers/CS384/mccrawt_cs384_virtual.pdf

http://bcook.cs.georgiasouthern.edu/cs523/lectureb.htm

http://nob.cs.ucdavis.edu/classes/ecs150-1999-02/mm-pagexample.html

http://www.javastudy.co.kr/docs/jhan/javaadvance/8-6.htm#one

http://www.source-code.biz/snippets/java/6.htm

http://cherrykyun.tistory.com/146

http://jakarta.apache.org/jcs/                                                                    

http://www.developer.com/open/article.php/10930_3700661_1

http://gaia.ecs.csus.edu/~zhangd/oscal/PagingApplet.html

Posted by 파이팅야
,

■ Collection : 오브젝트 집합을 나타내는 가장 기본적인 인터페이스
   □ Set : 중복 요소 없는 오브젝트 집합
      ○ SortedSet : 요소가 자동 올림순으로 정렬된다.
                            삽입되는 요소는 Comparable 인터페이스 속성을 갖고 있지만
                            지정된 Comparator에 의해 받아들여진다.
   □ List : 순서있는 오브젝트 집합, 중복허가, 리스트내의 특정위치에 요소를 넣을 수 있다.
               유저는 위치(인덱스)를 지정하여 각요소에 접근할 수 있다.

■ Map : 키-값으로 나타내는 오브젝트 집합. 키는 중복될 수 없다.
   □ SortedMap : 요소가 키로서 자동 올림순 정렬되는 Map.
                          삽입된 키는 Comparable 인터페이스 속성을 갖고 있지만
                          지정된 Comparator에 의해 받아들여진다.

구분

해쉬테이블

가변배열

밸런스트리

링크리스트

해쉬테이블&링크리스트

Set

HashSet

 

TreeSet

 

LinkedHashSet

List

 

ArrayList

 

LinkedList

 

Map

HashMap

 

TreeMap

 

LinkedHashMap


HashSet   : HashMap 인터페이스를 기본으로 Set인터페이스를 구현한 것. 순서를 보장할 수 없다.

TreeSet    : TreeMap 인터페이스를 기본으로 Set인터페이스를 구현한 것. 올림순으로 소트된다.

LinkedHashSet : 삽입된 순서를 기억한다.
                          같은 요소를 다시 삽입하면 이전 순서를 그대로 기억한다.

ArrayList   : List 인터페이스 속성을 갖고 배열크기를 변경할 수 있다.
                  배열크기를 조작하는 메소드를 제공한다.

LinkedList : 리스트의 처음과 마지막 요소를 삽입,삭제할 수 있다.
                  그 관련 메소드 제공.
                  동기화되어 있지 않다는 것을 제외하면 Vector와 같다.

HashMap : 동기화되어 있지않다는 것과 Null을 허용한다는 것 이외에는 HashTable과 같다.

TreeMap  : Red-Black Tree. 키의 올림순으로 소트된다.
                  LinkedHashMap : 키가 맵에 삽입된 순서를 기억한다.
                  같은 키로 삽입해도 이전의 순서를 기억한다.


■HashSet,TreeSet,LinkedHashSet 비교
중복요소없는 오브젝트 집합을 관리하는 클래스에는 HashSet,TreeSet,LinkedHashSet가 있다.
Set기능만 필요한 경우에는 HashSet.
요소를 올림차순으로 정렬하는 경우에는 TreeSet.
요소의 삽입순서를 기억할 필요가 있을 때에는 LinkedHashSet.

■ArrayList와 LinkedList
순서있는 오브젝트 집합을 관리하는 클래스로는 ArrayList와 LinkedList가 있다.

구분 인덱스 엑세스 Iterator 엑세스 추가 삽입 삭제
ArrayList 느림 느림
LinkedList 느림

ArrayList는 인덱스에 의한 랜덤엑세스 성능이 좋지만
요소의 삽입, 삭제에는 좋지않다.
LinkedList는 거꾸로 요소의 삽입, 삭제에는 성능이 좋지만
인덱스에 의한 랜덤엑세스는 좋지 않다.

■HashMap, TreeMap, LinkedHashMap
키-값 관계로 맵핑하는 경우에 사용하는 클래스에는 HashMap, TreeMap, LinkedHashMap이 있다.
Map 기능만 필요한 경우는 HashMap
키를 올림차순으로 소트할 필요가 있을 때는 TreeMap
키의 삽입순서를 기억할 필요가 있을 때에는 LinkedHashMap

■Set Class Test

import java.util.*;

public class SetClassTest {
  public static void main(String[] args) {
    try {
      // HashSet
      Set hashSet = new HashSet();
      addData(hashSet);
      System.out.println("HashSet : " + hashSet);

      // TreeSet
      Set treeSet = new TreeSet();
      addData(treeSet);
      System.out.println("TreeSet : " + treeSet);

      // LinkedHashSet
      Set linkedHashSet = new LinkedHashSet();
      addData(linkedHashSet);
      System.out.println("LinkedHashSet : " + linkedHashSet);

    } catch (Exception e) {
      e.printStackTrace();
    }
  }

  static void addData(Set set) {
    for (int i = 10;i >= 1;i--) {
      set.add(new Integer(i));
    }
  }
}

결과 :

   HashSet : [2,4,8,9,6,1,3,7,10,5]

   TreeSet : [1,2,3,4,5,6,7,8,9,10]

   LinkedHashSet : [10,9,8,7,6,5,4,3,2,1]


■List Class Test

import java.util.*;

public class ListClassTest {
  public static void main(String[] args) {
    try {
      long start, end;
      /** 추가 **/
      // ArrayList
      List arrayList = new ArrayList();
      start = System.currentTimeMillis();
      addData(arrayList);
      end = System.currentTimeMillis();
      System.out.println("ArrayList 추가 : " + (end - start));

      // LinkedList
      List linkedList = new LinkedList();
      start = System.currentTimeMillis();
      addData(linkedList);
      end = System.currentTimeMillis();
      System.out.println("LinkedList 추가 : " + (end - start));

      /** 삭제 **/
      // ArrayList
      start = System.currentTimeMillis();
      removeData(arrayList);
      end = System.currentTimeMillis();
      System.out.println("ArrayList 삭제 : " + (end - start));

      // LinkedList
      start = System.currentTimeMillis();
      removeData(linkedList);
      end = System.currentTimeMillis();
      System.out.println("LinkedList 삭제 : " + (end - start));

      /** 삽입 **/
      // ArrayList
      start = System.currentTimeMillis();
      insertData(arrayList);
      end = System.currentTimeMillis();
      System.out.println("ArrayList 삽입 : " + (end - start));

      // LinkedList
      start = System.currentTimeMillis();
      insertData(linkedList);
      end = System.currentTimeMillis();
      System.out.println("LinkedList 삽입 : " + (end - start));


      /**  인덱스 접근 **/
      // ArrayList
      start = System.currentTimeMillis();
      indexAccess(arrayList);
      end = System.currentTimeMillis();
      System.out.println("ArrayList 인덱스 접근 : " + (end - start));

      // LinkedList
      start = System.currentTimeMillis();
      indexAccess(linkedList);
      end = System.currentTimeMillis();
      System.out.println("LinkedList 인덱스 접근 : " + (end - start));

      /** Iterator 로 접근 **/
      // ArrayList
      start = System.currentTimeMillis();
      iteratorAccess(arrayList);
      end = System.currentTimeMillis();
      System.out.println("ArrayList Iterator로 접근 : " + (end - start));

      // LinkedList
      start = System.currentTimeMillis();
      iteratorAccess(linkedList);
      end = System.currentTimeMillis();
      System.out.println("LinkedList Iterator로 접근 : " + (end - start));

    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  static void addData(List list) {
    for (int i=1;i<100000;i++) {
      list.add(new Integer(i));
    }
  }
  static void removeData(List list) {
    while(!list.isEmpty()) {
      list.remove(0);
    }
  }
  static void insertData(List list) {
    for (int i=1;i<100000;i++) {
      list.add(0 , new Integer(i));
    }
  }

  static void indexAccess(List list) {
    int size = list.size();
    for (int i=0;i<size;i++) {
      Integer integer = (Integer)list.get(i);
    }
  }
  static void iteratorAccess(List list) {
    Iterator iterator = list.iterator();
    while (iterator.hasNext()) {
      Integer integer = (Integer)iterator.next();
    }
  }
}

결과 :

  ArrayList 추가 : 451

  LinkedList 추가 : 230

  ArrayList 삭제 : 45315

  LinkedList 삭제 : 20

  ArrayList 삽입 : 45416

  LinkedList 삽입 : 170

  ArrayList 인덱스로 접근 : 0

  LinkedList 인덱스로 접근 : 231473

  ArrayList Iterator로 접근 : 60

  LinkedList Iterator로 접근 : 50


■Map Class Test

import java.util.*;

public class MapClassTest {
  public static void main(String[] args) {
    try {
      // HashMap
      Map hashMap = new HashMap();
      putData(hashMap);
      System.out.println("HashMap : " + hashMap);

      // TreeMap
      Map treeMap = new TreeMap();
      putData(treeMap);
      System.out.println("TreeMap : " + treeMap);

      // LinkedHashMap
      Map linkedHashMap = new LinkedHashMap();
      putData(linkedHashMap);
      System.out.println("LinkedHashMap : " + linkedHashMap);

    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  static void putData(Map map) {
    map.put("5" , "Five");
    map.put("4" , "Four");
    map.put("3" , "Three");
    map.put("2" , "Two");
    map.put("1" , "One");
  }
}

결과 :

HashMap : {3=Three, 5=Five, 2=Two, 4=Four, 1=One}

TreeMap : {1=One, 2=Two, 3=Three, 4=Four, 5=Five}

LinkedHashMap : {5=Five, 4=Four, 3=Three, 2=Two, 1=One}

HashMap 기준에서 Hashtable과 비교하면

1. HashMap은 key와 value에 null을 허용하지만 Hashtable은 그렇지 않다.

2. HashMap은 thread safe하지 않고 (not synchronized) Hashtable은 그렇다 (synchronized). 진정한 Java인이라면 미래를 위해 Hashtable을 쓰는 게 맞을 것 같기도 하다.
HashMap 자체는 not synchronized하기 때문에 다음과 같이 Collection.synchronizedMap을 이용해서 synchronized하게 만들 수 있다.

Map m = Collections.synchronizedMap(new HashMap(...));

3. HashMap은 bucket에 element들을 흩어뿌리기 때문에 get/put과 같은 기본 동작들이 동일한 시간 (constant-time performance) 에 수행된다.

출처: http://dojeun.egloos.com/317868

Posted by 파이팅야
,

JCO 다녀오며

기타 2008. 3. 26. 19:27

JCO 다녀와서... 들은내용 정리한것
 
1. 오픈 소스 프레임워크를 활용한 비즈니스 어플리케니션 개발 방안 – 김창제
- 오픈소소를 사용해서 다양한 프로젝트를 경험한 노하우를 공유
- 많은 Join문이 있을 때 Hibernate에서의 문제점이 있어서 국내에서는 iBatis를 사용하는 경향이 짙음
- Maven + CVS + LuntBuild를 사용해서 CTIP(Continuous Test & Integration Platform) 개발환경 구축
(CVS에서 소스 가져와서 빌드 + JUnit으로 TestCode처리 + 패키징 +
이상유무에 따라 메일발송 + 배포 + Reuse Repository)
- Eclipse기반의 플러그인을 많이 사용하여 소스코드 생성 및 DB I/O처리등을 쉽게 수행할 수 있으며,
개발 시 오류 발생을 사전에 감지함으로 소스품질 및 생산성 향상
([자동코드생성]  WTP + Code/Conf.Gen, [SQL, Spring XML생성] Spring IDE, DBIO)
- 설계 단계의 모델링된 클래스와 소스코드상의 클래스가 서로 자동으로 반영되도록 유지
- Spring의 DI, AOP와 JUnit의 TDD의 중요성을 강조

2. 이클립스 SWT 실용주의 – 박용우
- 이클립스 SWT를 사용할 때 고려해야 할 사항들에 대해서 공유
- 자동배포 기능 사용시 RCT를 사용해서 만들어야 함
- 개발중에 Thread를 사용해서 swf 프로그램을 호출 시[Invalid thread access]관련 오류가 발생하면 Thread마다 Display객체를 호출하는 방식으로 변경해야함
- JSmooth를 사용해서 jar => exe 파일로 변경
- InstallFactory를 사용해서 install기능 가능(http://file.naver.com/view.php?fnum=28516)

3. 패턴언어(Pattern Language) – 최상훈
- 패턴은 크게 architecture(ex> MVC), design(ex> Observer), Idiom(언어별 존재하는 패턴, Micro)로 나뉘고 프로젝트에는 3가지가 모두 섞여있는 형태로 존재한다.
- 프로젝트 설계 시 architecture 을 사용, 세부설계 시 design, 개발 중에 Idiom을 사용하여
전체 프로젝트를 pattern으로 구성이 가능하고 가장 좋은 구성은 패턴들의 집합(Grady Booch : The best architectures are full of patterns)이다.

4. 애자일에 대한 7가지 교훈 – 김창준(http://agile.egloos.com)
- 1. 삼위일체 - 배움과 즐거움과 성과는 하나이다.  어느 하나를 강요해서도 안되며,
성과에 실패를 하더라도 실패한 것을 즐겁게 개선하는 방법으로 즐거움이 있었다면, 후에, 도움이 된다
- 2. 품질 - 품질의 기준은 사람마다 다르다(설명이 없었음)
- 3. 왜 이걸 하는가 – 돈을 벌기위한 수단으로 생각하지 않고,
즐거움으로 일할 수 있어야 한다. 자신이 좋아하는 것을 할 때, 뇌의 불이 켜진다고 한다.
- 4. 우선순위 – 다 하려고 하면 못한다.
- 5. 마음의 중요성 - 테스트를 성공하고, 실행을 했는데, 중간에 버그가 발생한 경우.
당황하지 말고, 바로 수정하기 전에 어느 곳에서 문제가 발생했을지 미리 생각해 본다.
문제가 예상되는 곳을 정하고 해당 부분을 직접 소스를 보고 수정한 후 확인한다.
위와 같이 무조건 수정하기 전에 문제의 원인과 수정 후 결과를 생각해 봄으로 에러를 8/1정도 줄일 수 있다고 함
- 6. 생명의 느낌 – 프로그램을 생명과 같이 생각해야 한다.
- 7. 끝없는 길 – 계속적으로 애자일 하도록 노력해야 한다.

5. Spring OSGi – 이일민(http://toby.epril.com)
- Spring OSGi를 사용하면 runtime에 install, start, stop, uninstall, update등을 할 수 있고,
다른 버전들을 같이 사용 할 수 있다. 기존 Spring에서 xml부분에 약간의 수정으로
바로 Spring OSGi를 사용할 수 있음
- 아직 바로 적용하기에는 OSGi를 위한 강력한 관리툴 부재등이 있음, 올해말 쯤부터 사용하는 것이 좋을 것 같다고 예상함

Posted by 파이팅야
,

Eclipse 단축키

풀그림 2008. 3. 26. 19:20
===== 실행 =====
1. Ctrl + F11 : 바로 전에 실행했던 클래스 실행
===== 소스 네비게이션 =====
1. Ctrl + 마우스커서(혹은 F3) : 클래스나 메소드 혹은 멤버를 상세하게 검색하고자 할때
2. Alt + ->, Alt + <- : 이후, 이전
3. Ctrl + o : 해당 소스의 메소드 리스트를 확인하려 할때
4. F4 : 클래스명을 선택하고 누르면 해당 클래스의 Hierarchy 를 볼 수 있다.

===== 문자열 찾기 =====
1. Ctrl + k : 찾고자 하는 문자열을 블럭으로 설정한 후 키를 누른다.
2. Ctrl + Shift + k : 역으로 찾고자 하는 문자열을 찾아감.
3. Ctrl + j : 입력하면서 찾을 수 있음.
4. Ctrl + Shift + j : 입력하면서 거꾸로 찾아갈 수 있음.
5. Ctrl + f : 기본적으로 찾기

===== 소스 편집 =====
1. Ctrl + Space : 입력 보조장치(Content Assistance) 강제 호출 => 입력하는 도중엔 언제라도 강제 호출 가능하다.
2. F2 : 컴파일 에러의 빨간줄에 커서를 갖져다가 이 키를 누르면 에러의 원인에 대한 힌트를 제공한다.
3. Ctrl + l : 원하는 소스 라인으로 이동
로컬 히스토리 기능을 이용하면 이전에 편집했던 내용으로 변환이 가능하다.
4. Ctrl + Shift + Space : 메소드의 가로안에 커서를 놓고 이 키를 누르면 파라미터 타입 힌트를 볼 수 있다.
5. 한줄 삭제 CTRL + D
6. 파일 닫기 : CTRL+W
7. 들여쓰기 자동 수정. (3.0 NEW) : CTRL+I
8. 블록 주석(/*..*/) 추가.(3.0 NEW): CTRL+SHIFT+/
8.1 Ctrl + / 해주면 여러줄이 한꺼번에 주석처리됨. 주석 해제하려면 반대로 하면 됨.
9. 위(아래)줄과 바꾸기 : ALT+UP(DOWN)
10. 블록 선택하기. : ALT+SHIFT+방향키
11. 메소드의 파라메터 목록 보기. : CTRL+SHIFT+SPACE
12. 자동으로 import 하기 : CTRL+SHIFT+O
13. 열린 파일 모두 닫기 : CTRL + SHIFT + F4
14. 블록 주석 제거 : CTRL+SHIFT+/
15. 전체화면 토글 : CTRL+M
16. 한줄(블럭) 복사 : Ctrl + Alt + 위(아래)
17. 다음 annotation(에러, 워닝, 북마크 가능)으로 점프 : Ctrl + , or .
18. 퀵 픽스 : Ctrl + 1
19. 메소드 정의부로 이동 : F3
20. 하이어라키 팦업 창 띄우기(인터페이스 구현 클래스간 이동시 편리) : Ctrl + T
21. 메소드나 필드 이동하기 CTRL + O
22. ULTRAEDIT나 EDITPLUS 의 CTRL+TAB 과 같은 기능. : CTRL+F6

===== 템플릿 사용 =====
1. sysout 입력한 후 Ctrl + Space 하면 System.out.println(); 으로 바뀐다.
2. try 입력한 후 Ctrl + Space 하면 try-catch 문이 완성된다.
3. for 입력한 후 Ctrl + Space 하면 여러가지 for 문을 완성할 수 있다.
4. 템플릿을 수정하거나 추가하려면 환경설정/자바/편집기/템플리트 에서 할 수 있다.

===== 메소드 쉽게 생성하기 =====
1. 클래스의 멤버를 일단 먼저 생성한다.
2. override 메소드를 구현하려면 : 소스->메소드대체/구현 에서 해당 메소드를 체크한다.
3. 기타 클래스의 멤버가 클래스의 오브젝트라면 : 소스->위임메소드 생성에서 메소드를 선택한다.
===== organize import =====
1. 자바파일을 여러개 선택한 후 소스 -> 가져오기 체계화 해주면 모두 적용된다.
===== 소스 코드 형식 및 공통 주석 설정 =====
1. 환경설정 -> 자바 -> 코드 스타일 -> 코드 포멧터 -> 가져오기 -> 프로파일.xml 을 불러다가 쓰면 된다.
2. 또한 다수의 자바파일에 프로파일을 적용하려면 패키지 탐색기에서 패키지를 선택한 후 소스 -> 형식화를 선택하면 된다.
3. 환경설정 -> 자바 -> 코드 스타일 -> 코드 템플리트 -> 가져오기 -> 템플리트.xml 을 불러다가 쓰면 된다.

===== 에디터 변환 =====
1. 에디터가 여러 파일을 열어서 작업중일때 Ctrl + F6 키를 누르면 여러파일명이 나오고 F6키를 계속 누르면 아래로
2. Ctrl + Shift + F6 키를 누르면 위로 커서가 움직인다.
3. Ctrl + F7 : 뷰간 전환
4. Ctrl + F8 : 퍼스펙티브간 전환
5. F12 : 에디터로 포커스 위치
Posted by 파이팅야
,

iBatis로 ms-sql에 DB연결 시

1. [SelectMethod=cursor] 없으면 안된다.
driver=com.microsoft.jdbc.sqlserver.SQLServerDriver
url=jdbc:microsoft:sqlserver://SERVER\\INSTANCENAME:1433;
SelectMethod=cursor;DatabaseName=TESTDB
username= USERID
password=PASSWORD

2. 그래도 안되면 [instanceName=xxx]구문을 넣어야 되는 경우도 있다.
url=jdbc:microsoft:sqlserver://SERVER:1433;instanceName=INSTANCENAME;
SelectMethod=cursor;DatabaseName=TESTDB

[USERID, PASSWORD, SERVER, INSTANCENAME]은 임의값

Posted by 파이팅야
,

1. Aggregation(따로 죽자)

Class Club() {

          Person[] person = null;

          Int i = 0;

          Public setRegisterPerson (Person[] p[]) {

                       person = System.ArrayCopy(p[]);

          }

}

- 일부분이 되는관계

(Aggregation is the part-of relationship.)

- 부분과 전체관계

- 하나의 객체가 다른 객체들의 조합에 의해 만들어진 것

- 공유가능

- ex)      차 – 엔진,

             컴퓨터 – 모니터, CD-ROM, 키보드

             클럽 – 사람

             식사 – 디저트, 샐러드, 수프

 

2. Composition(같이 죽자)

Class Polygon() {

          Point[] point = null;

          Public Polygon() {

                       point =  new Point[100];

          }

}

- 공유되지 않음 전체(Polygon)이 삭제될 때, 부분(Point)도 같이 삭제됨

(Thre no sharing rule is the key to composition.)

- ex)      나무 – 잎사귀

             셔츠 – 소매, 단추, 단추구멍

             커피테이블 – 몸체, 다리(4)

 

핵심은 Life Time이네요~(같이 죽자, 따로 죽자)

A Class가 B Class를 포함하고 있다면 Aggreation은
A Class가 Terminate된다고 해서 B Class가 Terminate되지 않는다.
그러나,
Composition의 경우 A Class가 Terminate되면 B Class도 Terminate된다.
Aggregation의 Life Time에 있어 독립적이지만 Composition은 종속적이다.

참고 URL : http://www.ibm.com/developerworks/kr/library/sep04/bell/




Posted by 파이팅야
,

1. Reflection 이란?
String값으로 컴파일 된 자바의 class, field, method에 대한 정보를 제공하고,
field값의 변경 및 method의 실행(invoke)을 가능하게 하는것
(Glen McCluskey 1988 reflection은 자바언어의 특징이다. 라고함)

2. Invoke하는 예제와 Modifier의 보안문제
package Invoke;
import java.lang.reflect.Method;
public class TestInvoke {
 public String display(){
  return "in display";
 }
 private String privateMethod(){
  return "in privateMethod";
 }
 public static void main(String[] args) {
  try{
   // Invoke하는 예
   Class c = Class.forName("Invoke.TestInvoke");
   Class partypes[] = new Class[0];
   Method m = c.getMethod("display", partypes);
   Object o = m.invoke(c.newInstance(), null);
   String sResult = o.toString();
   System.out.println("Result :" + sResult);
   
   // Modifier의 보안문제
   Class c2 = Class.forName("Invoke.TestInvoke");
   Class partypes2[] = new Class[0];
   Method m2 = c2.getDeclaredMethod("privateMethod", partypes2);
   Object o2 = m2.invoke(c2.newInstance(), null);
   String sResult2 = o2.toString();
   System.out.println("Result2 :" + sResult2);
  }catch(Exception e){
   System.out.println(e);
  }
 }
}


*. 여러가지 사용예
Class cls = Class.forName("constructor1");

###### is Instance
cls.isInstance()

###### method info
Method methlist[] = cls.getDeclaredMethods();
Method m = methlist[0];
Class pvec[] = m.getParameterTypes();
Class evec[] = m.getExceptionTypes();
m.getReturnType());

###### constructor
Constructor ctorlist[] = cls.getDeclaredConstructors();

###### field
Field fieldlist[] = cls.getDeclaredFields();
Field fld = fieldlist[0];
fld.getName()
fld.getDeclaringClass()
fld.getType()
fld.getModifiers()

###### create object
Class partypes[] = new Class[2];
partypes[0] = Integer.TYPE;
partypes[1] = Integer.TYPE;
Constructor ct = cls.getConstructor(partypes);
Object arglist[] = new Object[2];
arglist[0] = new Integer(37);
arglist[1] = new Integer(47);
Object retobj = ct.newInstance(arglist);

###### array
Class cls = Class.forName("java.lang.String");
Object arr = Array.newInstance(cls, 10);
Array.set(arr, 5, "this is a test");
String s = (String)Array.get(arr, 5);
System.out.println(s);

###### 적용예
eclipse의 자동완성기능으로 메소드명 찾아주기
spring의 Dependency Injection
spring의 AOP(Proxy Pattern)


참조 URL : http://java.sun.com/developer/technicalArticles/ALT/Reflection/index.html




Posted by 파이팅야
,

구글 광고

기타 2008. 3. 16. 13:55
방문자도 확인하고, 구글광고도 등록해서 앞으로 더 열심히 하게 하는 원동력이 될듯...

구글 방문자 확인 : https://www.google.com/analytics
구글 광고 : https://www.google.com/adsense/login/ko/
기존 블로그 이사를 도와줌 : http://s.freedomz.co.kr/

Posted by 파이팅야
,

.net byte vs java byte

풀그림 2008. 3. 16. 13:07
So a byte is a byte is a byte unless it is not! That in one sentence sums up my findings from yesterday. A byte in .NET represents a unsigned byte (0 - 255) automatically but a byte in Java is a signed byte(-128 - 127) and no there is no way to get an unsigned byte. I never really came across this problem till I was running some encryption algorithms on both. I need to encrypt a string in .NET and decrypt it on Java. For this I was converting the byte array into a hex string and asking users to enter it. However, because of the difference in interpretation of bytes I am running into problems.
NOTE: There is a signed byte in .NET available called ssbyte. I am not sure how an encryption algorithm can stuff it's data into it thgh. Sad! Sad! Sad!
CORRECTION: Okay so I had a brain-dead day and worte this out. It does not really matter how the two languages interpret the bits as long as the bits are the same going in to the encryption/decryption libraries.I am keeping this here to remind myself how stupid I can be.

.net byte => 0 ~ 255
java byte => -128 ~ 127

.net byte - 128 = java byte

출처 : http://geekswithblogs.net/rishi/archive/2006/01/27/67310.aspx


Posted by 파이팅야
,

검색엔진 연산어...

기타 2008. 3. 16. 12:59

연산어 - AND(&), OR(|), NOT(-,!), NEAR, WITHIN

네이버, 다음, 엠파스등은 현재 지원하지 않고 있다.

구글은 현재 다양하게 지원하고, 추가적인 연산어들도 있다.
1. ["홍길동 만세"] ""를 붙이면 붙어진 문자로 검색됨. ""가 없으면 [홍길동 AND 만세]임
2. [홍길동 -만세]는 [홍길동]검색안에서 [만세]문구 제거
3. [전자상거래 site:go.kr] go.kr도메인안에서 [전자상거래] 검색함
4. 영문일 경우 [~food]하면 food과 비슷한 [cooking, recipe]등도 검색됨
5. [전자상거래 filetype:ppt] ppt파일형식으로 검색
6. [엑셀 OR Excel] OR검색
7. [물가지수 2000..2007] 2000, 2001, 2002 ... 2007년 까지 모두 검색함
8. [1+2+3] 6 값 반환됨
9. [define:love] 사전기능
10. [inurl:report site:re.kr]re.kr도메인이고 report가 들어가는 URL을 검색함




Posted by 파이팅야
,