@Entity
public
class
Forum {
@Id
private
Long id;
@Column
private
String name;
@Column
private
String description;
@Column
private
Date createdAt;
// Omit Getters/Setters....
}
@Entity
public
class
Forum {
@Id
private
Long id;
@Column
private
String name;
@Column
private
String description;
@Column
private
Date createdAt;
// Omit Getters/Setters....
}
SQL Injection
XSS (Cross Site Scripting) - javascirpt를 입력.
==> 해결책: escapeHtml, escapeScirpt 등을 사용하거나, MVC framework을 사용. angular.js도 어느정도 막을 수 있을 듯.
그외,
Command Injection
XXE(XML External Entity)
등의 해킹법도 있음.
(Sometiems ArrayList is better when no synchronize, Sometimes Vector is better because of Size doubling )
ArrayList : Resizable Array - fast because of index. Add/Delete is Slow for data Copy. ==> 50% increase its array size
Vector : Similar to ArryList.. a little heavy because of synchronize processing. ==> doubles its array size
LinkedList: Fast for ADD/Delete. But No Index so sequential search is slow.
HashSet, SortedSet,
HashMap
DelayQueue, - - - |> BlockingQueue
Stack
several I/F like:
Queue, - 보통 new LinkedList<T>();
Deque, - 상동.
BlockingQueue : (waiting in some cases)
put은 queue가 꽉 차 있을 경우, take
는 queue가 비어있을 경우가 블로킹 조건이다.
TransferQueue
<class>
ConcurrentXX Collections : thread-Safe
-ConcurrentHashMap : synchronize detail이 HashTable과 약간 다름.
- SynchronousQueue: 초기 size가 0이고.. 다른Thread에서 빼려고 할때만 삽입이 가능한 놈이므로 peek도 안됨..
TreeMap - red-black Tree 기반의 sorted NavigableMap
TreeSet - TreeMap기반.
PriorityQueue - Heap자료구조 기반..
PriorityQueue 클래스는 기본적으로 작은 값이 우선순위가 높은 것으로 취급합니다. 따라서, 1에서 100까지의 숫자를 PriorityQueue에 추가하면, 1이 가장 높은 우선순위를 갖게 되고, 100이 가장 낮은 우선순위를 갖게 됩니다. 따라서 poll() 메서드를 호출하면, 가장 높은 우선순위를 갖는 1이 먼저 반환됩니다. => 체육복 코딩테스트에 사용 됨.
ThreadLocal은 jdk1.2부터 있었다고 하는데, 그 동안 이런게 있는지 잘 몰랐다.
용도는 2가지인데
1. Thread별로 싱글턴 같은 global(local)변수를 생성/관리되므로, Thread별로 분리된 변수를 사용가능.
=> REF : per-thread Singleton.
==> synchronized없이도 Lock이 자동으로 방지 될 걸로 예상 됨..(이건 좀 토론이 필요함)
1.1. 하나의 Thread안에서 여러 class가 공용메모리 처럼 사용가능. (왜냐하면 Thread안에서 global이니깐)
File f = File.createTempFile("aaa",".tmp") 도 유사한 성격으로 동시 접근을 피할 수 있다.
write다한 후에 보통 f.setReadOnly();
==> 똑같은 파일명으로 만들어도 알아서 숫자가 붙는 방식임. 따라서 .deleteOnExit() 설정을 꼭 해주는 게 좋다.
참고사이트: http://egloos.zum.com/slog2/v/3581446 https://docs.oracle.com/javaee/6/tutorial/doc/bnahq.html
EL (expression language) -> JSP2부터 기본 지원
JSTL (JavaServer Pages Standard Tag Library ) -> c tag를 가장 많이 사용.
앞부분에 taglib 디렉티브로 사용함을 표시한다.
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> // c:tag사용.
<EL>
<JSTL>
<c:forEach items="${list}" var="listItem" ><td>${listItem.title}</td>
</c:forEach>
javascript에는 function statement와 function expression이 존재한다.
비슷하지만 약간의 차이가 난다.
<Function>
- function expression: var x = function fname(){} (fname is optional)
=> 이걸로 싱글턴 만들수 있다. class만들고 싱클턴 만드는 거 보다 less expensive.
- function statement: function fname(){}
<기타>
- javascript 에 {blocks} 는 scope을 가지지 않는다.
<슈도 파라미터 2가지>
- arguments : parameter와 밀접한 관계가 있으므로, read-only로 사용하는 게 좋다.
일종의 array로 최근(ES5)에 .reduce 등이 소개되었다.
arguments.length
arguments[i]
- this : function 내에서 멤버변수를위한 public 키워드처럼 동작하기도 하며, (이건 아래2번)
1. reference to the object of invocation.
2. allows to know the concerned Object
3. allows single function object to service many functions ?
4. key to prototype inheritance
Function.prototype.bind를 통해 this를 강제로 할당 할 수 있다.
<prototype이란>
All JavaScript objects inherit the properties and methods from their prototype.
Allows you to add properties and methods to an object
we can inherit using prototype. and by overriding construct(). => prototype is copied.
<function관련 Form종류들>
- New폼: new functionObject()
- function폼: functionObject(arg) 이 경우, var that = this; 많이 사용. inner function이 outer를 접근하기 위해서..
(왜냐면 자체 this가 있기 때문)
- method폼: functionObject(arg).method()
- apply폼: apply() form , 유사한것으로 call도 있는데, apply는 (this,array) call은 (this, a,b,c : each object of array)가 전달된다.
this 참고사이트: http://mobicon.tistory.com/189
유투브: 15분-this, 30분-closure (English)
javascript에서 hoisting이란
변수나 함수를 var 로 선언하기 전에도 사용할 수 있다는 의미이다. 참고사이트
(global함수의 경우는 어디서나 사용할 수 있으므로 hoisting이 아니다.)
In JavaScript, a variable can be used before it has been declared.
hoisting이 왜 중요한가?
==> 크드가 잘 돌아가더라도 hoisting이 동작한 것일 수 있기 때문에, hoisting을 알아두는 것이 각종버그를 방지할 수 있다.
strict mode : "use strict"; 를 사용하면 hoisting을 방지할 수 있다. (꼭 선언 후 사용하는 모드) w3schools_js
finalize(): GC calls when Instance is garbage collected. which has no reference. 참고사이트:
hashCode(); when making equals method of Object. we must consider this method().
final: (method or class) will not be inheritted.
(팁: 크롬으로 javascript 개발시 F12 키가 debug모드이다 : 메뉴엔 Ctrl-Shft-J)
JavaScript의 객체 상속도를 잘 나타낸 그림은 다음과 같다. 참고사이트:devbox
DOM구조에서 거의 모든 object들이 Node를 상속받아서 만들어 졌다고 보면된다.
그런데 개발시에는 node API를 쓰면 필요없는 tag등이 한번씩 나오는 경우가 있어서
위한 children() 함수를 더 많이 쓰게 된다.
<많이 쓰는 코드>
document.getElementById('aa').children -> HTMLCollections 를 리턴함.
(document.getElementByxxx부터 해서, Element를 특히 많이 씀)
document.getElementById('aa').children.item(i) --> Element 리턴.
jquery의 경우는 : $('#aa')[0].childNodes[0].nodeValue;
$($('h1').contents().get(0)).text(); //.get(0)=[0]
$('h1').contents().each(function() {
if(this.nodeType == 3) { }
removeChild(e)
appendChild(e)
document.createElement('div')
<UML> Reference Site:
Inheritance: ㅡㅡㅡㅡㅡD
Interface: - - - - - - D
association(has): A ㅡㅡㅡㅡㅡ> B class A { member B}
Leg <.>-----> 필수.
Flea <>------>
dependency: A - - - - - > B class A uses B temporary.
<Gof Pattern> Reference SIte
Creational Pattern: Singleton, (Abstract)Factory, Builder, Prototype
Structral Pattern: Adapter, Decorator, Bridge, Proxy
Behavior Pattern: Command, Iterator, Visitor, Observer, Chain of Responsibility