프로그래밍6 [axios] axios 비동기 통신 목차샘플 코드function callAPI(e) { e.preventDefault(); const url = 'api.test.com'; axios.post(url, { param: //데이터 있으면.. 넣기 }) // 정상인 경우 .then((response) => { if (response.data.success) { location.href = "/"; } }) // 예외 발생 .catch((error) => { console.error('데이터 처리 .. IT/development 2025. 1. 19. [jQuery] 체크 이벤트 강제 발생 시키기 목차화면에 체크박스가 2개 있고, 체크박스의 change 이벤트를 감지하여 두 체크박스가 모두 체크되었을 때만 버튼을 활성화시키는 기능이 있다.그런데, 사용자가 직접 체크박스를 체크했을 때는 이벤트가 잘 감지되었지만, 함수 호출로 동적으로 체크박스를 체크한 경우는 감지되지 않는 문제가 있었다.이유는 기본적으로 체크박스를 동적으로 조작하면 이벤트가 발생하지 않기 때문에 그렇다.그래서 trigger.('이벤트명')으로 이벤트를 강제로 발생시켜 해결 했다.수정 전function check(checkId, target) { document.getElementById(target).classList.add('d-none'); $("#" + checkId).prop('checked', true); .. IT/development 2025. 1. 11. [java] 직접 구현한 List 추상화 (feat. 의존관계 주입) 목차복잡한 로직을 수행하는 배치 프로그램이 있다고 가정한다.로직은 매개변수로 넘어온 인자만큼 루프를 돌면서 list의 앞부분에 데이터를 넣는 로직이다.(앞부분인게 중요)배치프로그램 코드를 점점 개발자들이 리팩토링 했다는 스토리다.Ver 1: ArrayList 사용의 성능 문제package collection.test;import collection.list.MyArrayList;public class BatchProcessorV1 { // MyArrayList에 직접 의존(bad) private final MyArrayList list = new MyArrayList(); //엄청 복잡한 로직이라고 가정 public void logic(int size) { long st.. IT/development 2025. 1. 5. [java] 직접 구현하는 연결리스트 > 추가, 삭제 기능 (feat. 자료구조) 목차연결리스트의 추가, 삭제 원리는 정말 간단한데 그 추상적인 개념을 머릿속으로 그리는게 너무 오래 걸렸다.source codepackage collection.link;public class MyLinkedListV2 { private Node first; private int size = 0; //마지막 인덱스에 값을 추가 public void add(Object e) { Node newNode = new Node(e); if(first == null) { first = newNode; } else { getLastNode().next = newNode; } size++; .. IT/development 2025. 1. 5. [java] LinkedList(연결 리스트) 내 방식대로 이해 (feat. 자료구조) 목차카테고리를 고민하다가 스스로 아직 자료구조에 대해 잘 정리가 안된 상태라서 그냥 java로 분류했다.source code package collection.link;public class NodeMain1 { public static void main(String[] args) { //노드 생성하고 연결하기: A -> B -> C Node first = new Node("A"); //1번 째 노드의 참조값 first.next = new Node("B"); //1번 째 노드의 next필드에 2번 째 노드의 참조값 저장 first.next.next = new Node("C"); //2번 째 노드의 next필드에 3번 째 노드의 참.. IT/development 2025. 1. 4. [java] 다형성을 이용한 중복 코드 분리 (feat. 정적 중첩 클래스) 목차Ex2Mainpackage nested.anonymous.ex;public class Ex2Main { public static void helloThor() { System.out.println("프로그램 시작"); //코드 조각 시작 for (int i = 0; i helloThor(), helloLoki()의 코드 조각 시작 ~ 종료부분은 중복코드다.리팩토링 😃Godpackage nested.anonymous.ex;public interface God { void god();}Ex2RefMainV1package nested.anonymous.ex;public class Ex2RefMainV1 { public static void hello(.. IT/development 2024. 12. 25. 이전 1 다음