2023-02-07-TIL
2023-02-07-TIL
Today I Learned
Java Web Crawling: Jsoup vs Selenium
- https://hanke-r.tistory.com/161
- https://lotuus.tistory.com/107
- https://shinsunyoung.tistory.com/63
- https://vmpo.tistory.com/113
- https://medium.com/@sushain_Dilishan/building-web-scraping-api-with-spring-boot-jsoup-a0cc19dbd5dd
- https://github.com/hedza06/spring-boot-crawler
- https://heodolf.tistory.com/104
- https://stackoverflow.com/questions/33982064/selenium-vs-jsoup-performance
- https://imover.tistory.com/179
- https://www.linkedin.com/pulse/speed-up-your-selenium-test-jsoup-library-java-fakrudeen-shahul
- https://heekng.tistory.com/64
- https://medium.com/analytics-vidhya/scrapy-vs-selenium-vs-beautiful-soup-for-web-scraping-24008b6c87b8
- https://jsoup.org/cookbook/extracting-data/selector-syntax
- https://heodolf.tistory.com/103#:~:text=Jsoup%EC%9D%80%20HTTP%20Request%EB%A5%BC,Jsoup%EC%9D%84%20%EC%9D%B4%EC%9A%A9%ED%95%98%EB%8A%94%20%EA%B2%83%EC%9D%B4%20%EC%A2%8B%EB%8B%A4.
- https://fubabaz.tistory.com/24
- https://wonyong-jang.github.io/java/2020/07/01/Java-Selenium.html
- https://rladuddms.tistory.com/64
- https://guafindel.tistory.com/158
- https://db-log.tistory.com/entry/Selenium-Spring-boot%EC%97%90%EC%84%9C-Selenium%EC%9C%BC%EB%A1%9C-%ED%81%AC%EB%A1%A4%EB%A7%81%ED%95%98%EA%B8%B0
Controller Naming Convention
Controller 클래스 작성 규칙
- [메인테이블 명] + Controller.java 로 작성한다.
- 컨트롤러 클래스 안에서 메서드 명을 작성 할 때는 기본적으로 동사로 시작하고 뒤에 동작의 대상이 되는 리소르 이름을 붙인다. 대상 리소스가 하나일때는 단수, 여러개일때는 복수형으로 작성한다. 웬만하면
getXxx()/setXxx()
와 같은 네이밍은 지양한다.
1
2
3
4
5
6
listProducts() – 목록 조회 유형의 서비스
detailProduct() – 단 건 상세 조회 유형의 서비스
saveProduct() – 등록/수정/삭제 가 동시에 일어나는 유형의 서비스
addProduct() – 등록만 하는 유형의 서비스
modifyProduct() – 수정만 하는 유형의 서비스
removeProduct() – 삭제만 하는 유형의 서비스
Service 클래스 작성 규칙
- [메인테이블 명] + Service.java로 인터페이스를 작성한다.
- [메인테이블 명] + ServiceImpl.java 로 인터페이스를 구현하고 있는 클래스를 작성한다.
- 서비스 클래스 안에서 메서드 명을 작성 할 때는 아래와 같은 접두사를 붙인다.
1
2
3
4
5
findProduct() - 조회 유형의 서비스
addProduct() - 등록 유형의 서비스
modifyProduct() - 변경 유형의 서비스
removeProduct() - 삭제 유형의 서비스
saveProduct() – 등록/수정/삭제 가 동시에 일어나는 유형의 서비스
Mapper 클래스 작성 규칙
- [메인테이블 명]+Mapper.java로 클래스를 작성한다.
- Mapper 클래스 안에서 메서드 명을 작성 할 때는 아래와 같이 접두사를 붙인다.
- JPA를 사용하는 경우에는 해당 네이밍 규칙을 따른다.
1
2
3
4
selectProduct() - 조회 유형의 서비스
insertProduct() - 등록 유형의 서비스
updateProduct() – 변경 유형의 서비스
deleteProduct() - 삭제 유형의 서비스
- https://taestory.tistory.com/8
- https://www.slipp.net/questions/79
- https://docs.spring.io/spring-framework/docs/3.0.0.M3/reference/html/ch16s10.html
- https://help.hcltechsw.com/commerce/7.0.0/com.ibm.commerce.webservices.doc/tasks/twvrestsamplecmd.html
- https://www.oracle.com/java/technologies/javase/codeconventions-namingconventions.html
- https://howtodoinjava.com/java/basics/java-naming-conventions/
- https://www.javaguides.net/2018/08/java-standard-naming-conventions.html
- https://cloud.google.com/apis/design/naming_convention?hl=ko
- https://laracasts.com/discuss/channels/general-discussion/controller-name-prefix-get-del-post-etc-anti-patterns
- https://cocobi.tistory.com/27
- https://www.oracle.com/java/technologies/javase/codeconventions-introduction.html
- https://groups.google.com/g/ksug/c/OD2rFrJeMhs
- https://okky.kr/articles/484228
- https://google.github.io/styleguide/javaguide.html
- https://week-year.tistory.com/131
API Design Best Practices
- https://cloud.google.com/files/apigee/apigee-web-api-design-the-missing-link-ebook.pdf
- https://www.mimul.com/blog/web-api-design-from-apigee/?fbclid=IwAR1Q5QmdYTLpgc9c5w9IKQM2i49JBsNuEwyJHntYjWytEYQK89m2fJUMPAE
- https://pages.apigee.com/rs/apigee/images/api-design-ebook-2012-03.pdf
Mapping Multiple Entities to the Same Table
하나의 테이블에 대해 하나의 엔티티를 사용하는데, 종종 특정 서비스에서 불필요한 필드를 DB로부터 조회하게 될 때가 있다. 물론 그냥 다 가져온 다음에 프로젝션으로 필요한 필드만 추려내어서 응답으로 내려줄 수도 있겠지만, 애초에 DB에서 필요한 필드만 조회할 수 있다면 성능 개선 등의 이점이 있다. Vlad Mihalcea의 글에서 볼 수 있듯이, BaseEntity를 두고 상속하는 형태로 구성하면 하나의 테이블에 여러개의 엔티티를 두고 구조화해서 사용할 수 있게된다. 단, 주의할 점은 하나의 메서드에서 두 개 이상의 엔티티를 동시에 사용하거나 동시성 이슈가 있는 부분에서 사용하게 되면, 영속성 컨텍스트를 flush할때 비일관성의 문제가 발생할 수 있다.
- https://vladmihalcea.com/map-multiple-jpa-entities-one-table-hibernate/
- https://thorben-janssen.com/hibernate-tips-map-multiple-entities-same-table/
- https://smallbusiness.chron.com/difference-between-single-entity-multi-entity-financial-report-26060.html
- https://programmingnote.tistory.com/88
- https://stackoverflow.com/questions/18547932/hibernate-one-table-multiple-entities
- https://www.baeldung.com/jpa-mapping-single-entity-to-multiple-tables
- https://www.youtube.com/watch?v=RxE9nU285nM
@RequestBody vs @RequestParam
- https://stackoverflow.com/questions/28039709/what-is-difference-between-requestbody-and-requestparam
Swagger V3
- https://bcp0109.tistory.com/326
- https://springdoc.org/
- https://swagger.io/specification/
- https://jeonyoungho.github.io/posts/Open-API-3.0-Swagger-v3/
- https://jeonyoungho.github.io/posts/Open-API-3.0-Swagger-v3-%EC%83%81%EC%84%B8%EC%84%A4%EC%A0%95/
API Documentation Best Practices
- https://www.pandium.com/blogs/3-best-practices-for-api-documentation
- https://stoplight.io/api-documentation-guide
- https://swagger.io/blog/api-documentation/best-practices-in-api-documentation/
- https://medium.com/dev-genius/6-tips-of-api-documentation-without-hassle-using-swagger-openapi-spring-doc-3762cf36cae7
Java Exception Handling Best Practices
- https://www.theserverside.com/blog/Coffee-Talk-Java-News-Stories-and-Opinions/Java-Exception-handling-best-practices
- https://www.javacodegeeks.com/10-best-practices-to-handle-java-exceptions.html
- https://stackify.com/best-practices-exceptions-java/
- https://blog.devgenius.io/5-best-practices-to-handle-exceptions-in-java-5e1534f83772
- https://www.linkedin.com/pulse/java-exceptions-handling-best-practices-abid-anjum
- https://howtodoinjava.com/best-practices/java-exception-handling-best-practices/
Spring Exception Handling Best Practices
- https://climbtheladder.com/10-spring-boot-exception-handling-best-practices/
- https://medium.com/globant/best-practice-for-exception-handling-in-springboot-540484db8a1a
- https://dzone.com/articles/best-practice-for-exception-handling-in-spring-boo
- https://stackoverflow.com/questions/66762006/spring-boot-exception-handling-best-practice
- https://spring.io/blog/2013/11/01/exception-handling-in-spring-mvc
Java Copy On Write
- https://www.baeldung.com/java-copy-on-write-arraylist
- https://www.javamex.com/tutorials/synchronization_concurrency_8_copy_on_write.shtml
- https://stackoverflow.com/questions/32691747/how-do-copy-on-write-collections-provide-thread-safety
- https://dzone.com/articles/java-concurrency-copy-on-write
- https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/CopyOnWriteArrayList.html
Java List unmodifiableList
- https://lts0606.tistory.com/133
The best way to clone or duplicate an entity with JPA and Hibernate
- https://vladmihalcea.com/clone-duplicate-entity-jpa-hibernate/
Dangling Pointer
- https://thinkpro.tistory.com/67
- https://en.wikipedia.org/wiki/Dangling_pointer
Kotlin Sealed Classes
- https://kotlinlang.org/docs/sealed-classes.html
- https://kotlinworld.com/165
Java Objects.deepEquals
- https://www.educative.io/answers/what-is-objectsdeepequals-in-java
Immutable Objects in Java
- https://www.baeldung.com/java-immutable-object
- https://www.javatpoint.com/mutable-and-immutable-in-java
- https://www.digitalocean.com/community/tutorials/how-to-create-immutable-class-in-java
Go Pipeline
- https://pa-pico.tistory.com/38
- https://hamait.tistory.com/927
- https://simplear.tistory.com/21
Go mutable vs immutable data type
- https://www.meetgor.com/golang-mutable-immutable/
Fail-Safe Iterator vs Fail-Fast Iterator
- https://www.baeldung.com/java-fail-safe-vs-fail-fast-iterator
Java Stream Pipeline
- https://java-design-patterns.com/patterns/pipeline/#explanation
- https://cornswrold.tistory.com/295
Response or Controller by Privilege
- https://stackoverflow.com/questions/62793553/spring-boot-customize-api-response-based-on-the-user-roles
- https://www.baeldung.com/spring-security-create-new-custom-security-expression
- https://www.digitalocean.com/community/tutorials/spring-security-role-based-access-authorization-example
MapStruct vs ModelMapper
- https://dev-splin.github.io/spring/Spring-ModelMapper,MapStruct/
- https://kth990303.tistory.com/131
- https://recordsoflife.tistory.com/1148
- https://ykh6242.tistory.com/entry/%EB%B0%98%EB%B3%B5%EC%A0%81%EC%9D%B8-DTO-%EB%B3%80%ED%99%98-%EC%9E%91%EC%97%85%EC%9D%84-%ED%95%9C-%EB%B2%88%EC%97%90-%EC%A0%95%EC%9D%98-MapStruct-%EA%B8%B0%EB%B3%B8-%EC%A0%95%EB%A6%AC
- https://coding-start.tistory.com/349
- https://www.skyer9.pe.kr/wordpress/?p=1596
- https://mapstruct.org/documentation/stable/reference/html/
- https://www.youtube.com/watch?v=nvjqtWQ5zj8
- https://dzone.com/articles/map-struct-jakarta-ee-cloud?ref=morioh.com&utm_source=morioh.com
gson.fromjson vs objectmapper.readvalue
- https://stackoverflow.com/questions/2378402/jackson-vs-gson
- https://www.baeldung.com/jackson-vs-gson
- https://velog.io/@z-no_on/JSON-%EB%9D%BC%EC%9D%B4%EB%B8%8C%EB%9F%AC%EB%A6%AC-JacksonGSON-%EB%B9%84%EA%B5%90
- https://velog.io/@sa1341/Java-%EC%A7%81%EB%A0%AC%ED%99%94%EB%A5%BC-%ED%95%98%EB%8A%94-%EC%9D%B4%EC%9C%A0%EA%B0%80-%EB%AC%B4%EC%97%87%EC%9D%BC%EA%B9%8C
This post is licensed under CC BY 4.0 by the author.