전체 글819 On the Canadian Border (SQL for Beginners #2) You are a border guard sitting on the Canadian border. You were given a list of travelers who have arrived at your gate today. You know that American, Mexican, and Canadian citizens don't need visas, so they can just continue their trips. You don't need to check their passports for visas! You only need to check the passports of citizens of all other countries! Select names, and countries of orig.. 2022. 6. 2. Easy SQL: Bit Length Given a demographics table in the following format: ** demographics table schema ** id name birthday race you need to return the same table where all text fields (name & race) are changed to the bit length of the string. Solution: SELECT id, BIT_LENGTH(name) AS name, birthday, BIT_LENGTH(race) AS race FROM demographics Result: id name birthday race 1 40 1983-01-30 200 2 40 1974-09-15 200 3 40 19.. 2022. 6. 2. Easy SQL: ASCII Converter Given a demographics table in the following format: ** demographics table schema ** id name birthday race you need to return the same table where all text fields (name & race) are changed to the ascii code of their first byte. e.g. Verlie = 86 Warren = 87 Horace = 72 Tracy = 84 Solution: SELECT id, ASCII(name) AS name, birthday, ASCII(race) AS race FROM demographics Result: id name birthday race.. 2022. 5. 31. 퍼사드 패턴 퍼사드 디자인 패턴 개요 퍼사드는 건물의 정면, 돋보이는 쪽을 의미. 즉, 건물의 외관만 신경 쓰지 내부 구조는 신경 쓰지 않는다. 복잡한 내부 로직을 감추고 클라이언트가 쉽게 접근할 수 있는 인터페이스 제공 구성요소 : 퍼사드, 시스템, 클라이언트 목적 서브시스템의 인터페이스를 통합시킨 단일 인터페이스를 제공해 클라이언트가 쉽게 서브시스템에 접근할 수 있게 한다. 단일 인터페이스 객체로 복잡한 서브시스템을 대체한다. 서브시스템을 캡슐화하는 것이 아니라 모든 서브시스템들을 결합한다. 클라이언트와 내부 구현을 분리한다. 퍼사드 어떤 서브시스템이 요청에 알맞는지 알고 있다. 컴포지션을 통해 클라이언트의 요청을 서브시스템 객체에 전달 클라이언트는 서브시스템이 아닌 퍼사드에만 요청 단, 퍼사드는 서브시스템을 캡.. 2022. 5. 31. Easy SQL: Rounding Decimals Given the following table 'decimals': ** decimals table schema ** id number1 number2 Return a table with two columns (number1, number2), the value in number1 should be rounded down and the value in number2 should be rounded up. Solution: SELECT FLOOR(number1) as number1, CEIL(number2) as number2 FROM decimals Result: number1 number2 2409 -261 1411 -4694 2666 -2280 3616 -2987 4110 -2420 3654 -146.. 2022. 5. 30. 팩토리 메소드, 추상 팩토리 패턴 팩토리 메소드 패턴 인터페이스를 통해 객체를 생성하지만 팩토리가 아닌 서브 클래스가 해당 객체 생성을 위해 어떤 클래스를 호출할지 결정한다. 팩토리 메소드는 인스턴스화가 아닌 상속을 통해 객체를 생성한다. 팩토리 메소드 디자인은 유동적이다. 특정 객체가 아닌 같은 인스턴스나 서브 클래스 객체를 반환할 수 있다. 팩토리 메소드 패턴은 객체를 생성하는 인터페이스를 정의하고 어떤 클래스를 초기화할지는서브 클래스의 결정에 맡긴다. 팩토리 메소드 구현 예 커리어 서비스(링크드인)과 앨범 서비스(페이스북)가 개별적으로 존재한다. 두 서비스는 공통적으로 개인 정보를 입력해야한다. 서비스 종류에 따라 알맞는 내용을 포함하는 프로필을 생성해보자 from abc import abstractmethod # Product 인.. 2022. 5. 30. 이전 1 ··· 75 76 77 78 79 80 81 ··· 137 다음