본문 바로가기 메뉴 바로가기

eblo

프로필사진
  • 글쓰기
  • 관리
  • 태그
  • 방명록
  • RSS

eblo

검색하기 폼
  • 분류 전체보기 (113)
    • Spring Frameworks (27)
      • RESTful Service (4)
      • Thymeleaf (4)
    • Java (8)
    • UI(Front-End) (17)
      • 그리드 (11)
      • vuejs (0)
      • javascript 일반 (1)
      • css (0)
    • DB (4)
    • Server & System (0)
    • Design Pattern & Refactorin.. (0)
    • 잡동사니 (5)
      • 개인정보보안 (2)
    • 참고링크 (2)
    • 리팩토링(스프링기반) (13)
    • 프로젝트 (1)
    • Working log (14)
    • Test & ProtoTyping (2)
    • 엘라스틱서치 (0)
    • study (18)
      • springboot (18)
  • 방명록

리팩토링(스프링기반) (13)
Remove this "BigDecimal" constructor

Remove this "BigDecimal" constructor수정 전 public void serialize(Double value, JsonGenerator jgen, SerializerProvider provider) throws IOException { if (null == value) { jgen.writeNull(); } else { jgen.writeNumber(new BigDecimal(value).setScale(2, BigDecimal.ROUND_DOWN)); } }수정 후 public void serialize(Double value, JsonGenerator jgen, SerializerProvider provider) throws IOException { if (null == v..

리팩토링(스프링기반) 2019. 1. 8. 21:00
java.nio.Files을 이용한 파일 삭제

Use "java.nio.Files#delete" here for better messages on error conditions.SonarQube를 이용하니 새로운 기술도 알려 주네요. ^^수정 전public static boolean deleteFile(String path, String name){ File file = new File(path + name);if(file.exists()){return file.delete();}return false;}수정 후 public static boolean deleteFile(String path, String name) { Path filePath = FileSystems.getDefault().getPath(path, name); try { Files..

리팩토링(스프링기반) 2019. 1. 8. 18:09
private 생성자 추가

"Add a private constructor to hide the implicit public one."유틸 클래스에서는 public 생성자가 없어야 합니다. 유틸 클래스 만들 때는 private 생성자를 추가해 주세요. public class ValidatorUtil { private ValidatorUtil() { throw new IllegalStateException("Utility class"); }...} Utility classes should not have public constructors (squid:S1118) Code smell MajorUtility classes, which are collections of static members, are not meant to be i..

리팩토링(스프링기반) 2019. 1. 8. 17:53
동일 처리를 하는 catch문 합치기

Combine this catch with the one at line 82, which has the same body. 동일 처리를 하는 catch문 합치기 수정 전public boolean checkUser(UserParam userParam) {try {if(getUserInfo(userParam) != null) return true;}catch(DataNotFoundException e) {return false;}catch(UserNotFoundException e) {return false;}return false;}수정 후public boolean checkUser(UserParam userParam) {try {if(getUserInfo(userParam) != null) return ..

리팩토링(스프링기반) 2019. 1. 8. 16:41
private method의 @Transactional 제거

"Make this method "public" or remove the "@Transactional" annotation"@Transactional(propagation=Propagation.REQUIRED, readOnly=false, rollbackFor=Exception.class)

리팩토링(스프링기반) 2019. 1. 8. 09:26
Map 전체 내용을 읽을 때 Key, Value를 모두 사용한다면 "entrySet"을 사용하라

Iterate over the "entrySet" instead of the "keySet". Map에 있는 키 값을 꺼내서 루프를 돌리는데 만약 key값 이외 value도 필요하다며 keySet을 사용하지 말고 entrySet을 사용하라. "entrySet()" should be iterated when both the key and value are needed (squid:S2864) Code smell Major When only the keys from a map are needed in a loop, iterating the keySet makes sense. But when both the key and the value are needed, it's more efficient to iter..

리팩토링(스프링기반) 2019. 1. 8. 09:06
오브젝트 복제하기

Object를 일반적인 방법으로 복제를 하는 경우 문제가 발생할 수 있습니다. 아래 예제를 통해 확인해 보겠습니다. 테스트 코드 public class TestClone { public static void main(String[] args) { User user1 = new User("test1"); User cUser1 = (User)user1.clone(); cUser1.setName("test2"); System.out.println(user1.toString()); System.out.println(cUser1.toString()); } public static class User implements Cloneable, Serializable{ private String name; private..

리팩토링(스프링기반) 2019. 1. 7. 15:06
타입선언은 인터페이스로 하자

검출 메시지 The type of the "map" object should be an interface such as "Map" rather than the implementation "HashMap".List, Set, Map 사용 시 자주 실수하는 내용 중 하나입니다. 심지어 List가 인터페이스인 줄도 모르는 개발자가 많습니다. 왜 인터페이스를 사용해야 하는지를 모르면서 습관처럼 만들고 사용합니다. 왜 그러해야하는가에 대한 것을 공부하고 좋은 습관을 만드는게 중요한거 같습니다. 잘못 사용 되는 예ArrayList list = new ArrayList();HashMap map = new HashMap();HashSet set = new HashSet(); public void test(HashMap..

리팩토링(스프링기반) 2019. 1. 7. 11:13
Java class, method 선언 시 표현 순서

리팩토링 검출 메시지 "Reorder the modifiers to comply with the Java Language Specification."Java class, method 선언 시 표현 순서 1. Annotations 2. 접근자 (public/protected/private) 3. abstract 4. static 5. final 6. transient 7. volatile 8. default 9. synchronized10. native11. strictfp 잘못된 예 : public synchronized static String replace(...} 변경 : public static synchronized String replace(...}참고 및 발췌8.1. Class Declara..

리팩토링(스프링기반) 2019. 1. 7. 10:43
로그인 프로세스 개선

기존 코드 if(구글로그인){ // 로그인 처리}else if(인스타로그인){ // 로그인 처리}else if(페이스북로그인){ // 로그인 처리}else{ // 로그인 처리}문제점 새로운 추가가 발생할 때 마다 소스를 추가/변경해 주어야 한다.코드의 양이 커진다. 복잡도 증가한다. 가독성이 떨어진다. 부분 테스트 불가능하다. 리팩토링인터페이스를 생성하고 각각의 로그인 형태에 따라 클래스로 분리한다.flyweight pattern과 유사한 형태로 만든다. 각각의 클래스를 자료 구조에 담아 두고 꺼내 이용한다. 설계상에는 Factory를 별도로 만들지 않았습니다. Contorller123456789101112131415161718192021222324252627282930@RestController@Slf..

리팩토링(스프링기반) 2019. 1. 3. 23:27
이전 1 2 다음
이전 다음
공지사항
최근에 올라온 글
  • Maven System scope 사용하기
  • 017. Logback 설정
  • 016. 스프링부트 Profile 설정
  • 015. 메지시 관련 공통 설정(Converter⋯
최근에 달린 댓글
  • cellRenderer 쓰면 editable 을 fa⋯
  • 감사합니다
  • 안녕하세요. 이런좋은 코드개발자가 한국분이라니 대단하십⋯
  • 감사합니다~
Total
536,116
Today
28
Yesterday
349
링크
TAG
  • sample
  • cache
  • Spring Boot
  • 예제
  • springboot
  • AG-GRID
  • listToMap
  • 스프링부트
  • oracle
  • example
  • 설정
  • 엑셀
  • Javascript
  • lombok
  • RESTful
  • 샘플
  • java
  • 메시지
  • SHEETJS
  • mapToList
  • 타임리프
  • thymeleaf
  • REST
  • spring
  • 스프링
  • 그리드
  • mybatis
  • restful서비스
  • UI
  • ag grid
more
«   2023/02   »
일 월 화 수 목 금 토
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
글 보관함
  • 2022/08 (1)
  • 2022/05 (18)
  • 2021/12 (6)
  • 2021/10 (4)

Blog is powered by Tistory / Designed by Tistory

티스토리툴바