File:FactoryMethod.svg

http://en.wikipedia.org/wiki/Factory_method


추상화된 것이 의존하게 만든다.

구상클래스에 의존하게 만들지 않도록 한다.


http://en.wikipedia.org/wiki/Observer_pattern


서로 상호작용을 하는 객체 사이에는 가능하면 느슨하게 결합하는 디자인을 사용해야 한다.


class Observable(object):
  def __init__(self):
    self.__observers = []
  def addObserver(self, obs):
    self.__observers.append(obs)
  def notify(self, *args, **kwargs):
    for o in self.__observers:
      o.update(self, *args, **kwargs)
 
class Observer(object):
  def __init__(self, observable):
    observable.addObserver(self)
  def update(self, observable, *args, **kwargs):
    print 'Got', args, kwargs, 'From', observable
 
source = Observable()
target = Observer(source)
source.notify('test')

File:StrategyPattern IBrakeBehavior.svg


http://en.wikipedia.org/wiki/Strategy_pattern


애플리케이션에서 달라지는 부분을 찾아내고, 달라지지 않는 부분으로 부터 분리시킨다.

구현이 아닌 인터페이스에 맞춰서 프로그래밍한다.

상속보다 구성을 활용한다.


/** The classes that implement a concrete strategy should implement this.
* The Context class uses this to call the concrete strategy. */
interface Strategy {
    int execute(int a, int b); 
};
 
/** Implements the algorithm using the strategy interface */
class Add implements Strategy {
    public int execute(int a, int b) {
        System.out.println("Called Add's execute()");
        return a + b;  // Do an addition with a and b
    }
};
 
class Subtract implements Strategy {
    public int execute(int a, int b) {
        System.out.println("Called Subtract's execute()");
        return a - b;  // Do a subtraction with a and b
    }
};
 
class Multiply implements Strategy {
    public int execute(int a, int b) {
        System.out.println("Called Multiply's execute()");
        return a * b;   // Do a multiplication with a and b
    }    
};
 
// Configured with a ConcreteStrategy object and maintains
// a reference to a Strategy object 
class Context {
    private Strategy strategy;
 
    public Context(Strategy strategy) {
        this.strategy = strategy;
    }
    public int executeStrategy(int a, int b) {
        return this.strategy.execute(a, b);
    }
};
 
/** Tests the pattern */
class StrategyExample {
    public static void main(String[] args) {
        Context context;
        // Three contexts following different strategies
        context = new Context(new Add());
        int resultA = context.executeStrategy(3,4);
 
        context = new Context(new Subtract());
        int resultB = context.executeStrategy(3,4);
 
        context = new Context(new Multiply());
        int resultC = context.executeStrategy(3,4);
 
        System.out.println("Result A : " + resultA );
        System.out.println("Result B : " + resultB );
        System.out.println("Result C : " + resultC );
    }
};

    class Program

    {

        private const int MAX = 10;

        private static int[] memo;


        static void Main(string[] args)

        {

            memo = new int[MAX];

            for (int i = 0; i < MAX; ++i)

            {

                memo[i] = MAX - i;

            }


            memo = new int[] { 200, 3, 10, 9, 8, 7, 4, 12, 5, 2 };


            quicksort(0, memo.Count() - 1);


            for (int i = 0; i < MAX; ++i)

            {

                Console.Write(memo[i] + " ");

            }

        }


        static void quicksort(int left, int right)

        {

            if (left < right)

            {

                int pivot = memo[left];


                int i = left + 1;

                int j = right;


                while (i <= j)

                {

                    while (i <= j && memo[i] < pivot)

                    {

                        ++i;

                    }


                    while (i <= j && memo[j] > pivot)

                    {

                        --j;

                    }


                    if (i < j)

                    {

                        int tmp = memo[j];

                        memo[j] = memo[i];

                        memo[i] = tmp;

                    }

                }


                int tmp2 = memo[j];

                memo[j] = pivot;

                memo[left] = tmp2;


                quicksort(left, i - 1);

                quicksort(i + 1, right);

            }

        }

    }

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;


namespace Fibo

{

    class Program

    {

        private const int MAX = 512;

        private static decimal[] memo;


        static void Main(string[] args)

        {

            memo = new decimal[MAX];

            for (int i = 0; i < MAX; ++i)

            {

                memo[i] = 0;

            }


            int input = Convert.ToInt32(Console.ReadLine());


            Console.WriteLine(fibo(input));

        }


        static decimal fibo(int idx)

        {

            if (idx == 0)

            {

                return 0;

            }

            else if (idx == 1)

            {

                return 1;

            }


            if (memo[idx] > 0)

            {

                return memo[idx];

            }

            else

            {

                memo[idx] = fibo(idx - 2) + fibo(idx - 1);

                return memo[idx];

            }

        }

    }

}




회귀분석(回歸分析, regression analysis)은 통계학에서 관찰된 연속형 변수들에 대해 독립변수와 종속변수 사이의 상관관계에 따른 수학적 모델인 선형적 관계식을 구하여 어떤 독립변수가 주어졌을 때 이에 따른 종속변수를 예측한다. 또한 이 수학적 모델이 얼마나 잘 설명하고 있는지를 판별하기 위한 적합도를 측정하는 분석 방법이다.

1개의 종속변수와 1개의 독립변수 사이의 관계를 분석할 경우를 단순회귀분석(Simple Regression Analysis), 1개의 종속변수와 여러 개의 독립변수 사이의 관계를 규명하고자 할 경우를 다중회귀분석(Multiple Regression Analysis)이라고 한다.


http://ko.wikipedia.org/wiki/%ED%9A%8C%EA%B7%80%EB%B6%84%EC%84%9D


JUnit 이 무엇인가?


간단하게 테스트를 위한 클래스를 만들고 테스트 하는거..


메소드 몇개 정리하고 갑니다.


Methods

 - assertEquals(A, B)

   A와 B가 일치하는지를 조사한다. A, B에는 Object, int, float, long, char, boolean등 모든 자료형이 들어갈 수 있다. 단 A, B의 타입은 언제나 같아야만 한다.

 - assertTrue(K)

   K가 참인지를 조사한다.

   K는 boolean형태의 값이어야 한다.

 - assertFalse(K)

   K가 거짓인지를 조사한다. assertTrue와 반대

   K는 boolean형태의 값이어야 한다.

 - assertNotNull(Object A)

   A가 Null이 아닌지를 확인한다.

   Null이라면 assertionFailedError가 발생

 - assertNull(Object A)

   A가 Null인지를 확인한다.

   Null이 아니라면 assertionFailedError가 발생

 - assertSame(Object A, Object B)

   A와 B가 같은 객체인지를 조사한다.



물론 목객체 라든지 다른 방법들도 있는데 작은단위에서 널리 활용될 메소드들이다.


버퍼 같은것도 많이 사용되는듯 하고..


퍼트려도 될런진 몰르지만.. 배포는 아니니.. 오래 되었지만 참고할 만한 동영상 링크도 걸어 보겠..;;


http://xper.org/LineReaderTdd/

동영상이다 걍 보쟈..


(문제가 된다면 삭제 하겠습니다.)


글고 메소드나 사용법등이 자세히 되어있는 블로그다

http://netrance.blog.me/110169530575

최근 ubuntu에서 debian으로 갈아탔다. ubuntu 가 처음에 6개월 업데이트라서 최신기능을 빨리 써볼수 있고 유니티 데스크톱이 보기 좋아서 그냥 좋았는데 몇년 쓰다보니 업데이트 될 때마다 문제가 생기곤한다. 그리고 메이저 하드웨어를 사용하지 않는 나로써는 매번 힘들다. 그래서 보수적? 이라고 할 수 있는 debian으로 저번 주말에 설치! 그리고 오늘 node.js 도 설치해보려고 한다.


안정 패키지에 안들어있어서 소스컴파일 하기로했다. 아래 링크 참고,

http://sekati.com/etc/install-nodejs-on-debian-squeeze

간단히 필요한 패키지 설치하고

sudo apt-get update && apt-get install git-core curl build-essential openssl libssl-dev

git에서 최신버전 받은 후

git clone https://github.com/joyent/node.git


./configure --openssl-libpath=/usr/lib/ssl
make
make test
make install

하면 끝


rsync Secure Copy (SCP)


둘의 차이는 뭘까?



두개 다 원격 파일 전송이라는 공통점은 있지만 왜 다르게 쓸까? 

그 이유는 옵션의 차이도 있겠지만 무엇보다 symbolic link 를 처리하는데 차이가 있다. 


scp는 전송하려 하는 파일중에 symbolic link 가 있다면 링크된 원본파일이 전송된다. 

즉, symlink 가 유지 되지 않는다.

+ Recent posts