Skip to content

[CVW-039] 코인 거래내역 정보 객체 책임 리팩토링#51

Merged
J0onYEong merged 5 commits intomainfrom
refactor/CoinTradeStream
Apr 21, 2025
Merged

[CVW-039] 코인 거래내역 정보 객체 책임 리팩토링#51
J0onYEong merged 5 commits intomainfrom
refactor/CoinTradeStream

Conversation

@J0onYEong
Copy link
Collaborator

변경된 점

  • 코인 거래내역 정보 객체 책임 리팩토링

코인 거래내역 정보 객체 책임 리팩토링

기존 책임 분리

레이어 책임
Presentation 텍스트 가공, 거래내역 테이블 데이터 관리, UI업데이트 주기 관리, 테이블 크기 결정, 테이블 정렬방식 결정
Domain -
Data DTO를 엔티티화

기존방식의 클린아키텍처에 어긋납니다.
거래정보의 경우 데이터 레이어에 위치시키고 도메인 로직에 따라 정렬 및 가공을 하는 것이 올바릅니다.

변경된 책임

레이어 책임
Presentation UI업데이트 주기 관리, 테이블 크기 결정
Domain 데이터 업데이트 주기 결정, 테이블 정렬방식 결정, 요청받은 테이블 개수로 데이터 가공
Data - Repository DTO를 엔티티화
Data - DataSource 전체 개래내역 테이블을 관리(DTO형태)

불필요하게 많은 데이터 업데이트 되는 것을 방지하기 위해 도메인 레이어에서 테이블의 업데이트 주기를 결정하도록 했습니다.
※ 해당 제약의 경우 UI업데이트와 무관한 데이터 업데이트입니다.

Repository의 책임은 DTO를 엔티티로 적응시키는 것임으로 DataSource객체를 만들어 전체 거래내역정보를 관리하도록 했습니다.

@J0onYEong J0onYEong requested a review from Copilot April 21, 2025 05:39
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the responsibility for handling coin trade information by moving trade data processing into the domain layer and updating repository and data source interfaces accordingly. Key changes include:

  • Removal of the TradeContainer and associated logic in the CoinDetailPageViewModel.
  • Introduction of new publisher-based methods for retrieving recent coin trades in the use case and repository layers.
  • Updates to dependency injection in DI assemblies along with removal of outdated repository implementations.

Reviewed Changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated no comments.

Show a summary per file
File Description
Projects/Utils/CoreUtil/Sources/Swift+Extension/Type+Copyable.swift Adds retroactive conformance for Date and Int64 to the Copyable protocol.
Projects/Utils/CoreUtil/Sources/DataStructure/ThreadSafeHashMap.swift Introduces an actor-based thread-safe hash map.
Projects/Features/CoinDetail/Feature/Sources/Model/TradeContainer.swift Removes the TradeContainer, shifting responsibility for trade data handling.
Projects/Features/CoinDetail/Feature/Sources/CoinDetailPageViewModel.swift Updates recent trade stream handling to use a publisher that returns a pre-processed trade list.
Projects/Features/CoinDetail/Example/Sources/DI/Assemblies.swift Adjusts DI registrations to use the new CoinTradeRepository and CoinTradeDataSource.
Projects/Domain/Interface/UseCase/CoinDetailPageUseCase.swift Updates the interface for retrieving recent trades to return an AnyPublisher of trade lists.
Projects/Domain/Interface/Repository/* Removes the old TradeRepository interface and adds CoinTradeRepository.
Projects/Domain/Concrete/UseCase/DefaultCoinDetailPageUseCase.swift Adapts the coin trade use case to the new publisher-based interface.
Projects/Data/Repository/Sources/Util/ThreadSafeOrderbookHashMap.swift Deletes the old thread-safe orderbook hash map in favor of the newer implementation.
Projects/Data/Repository/Sources/BinanceTradeRepository.swift Removes the old BinanceTradeRepository.
Projects/Data/Repository/Sources/BinanceOrderbookRepository.swift Updates orderbook store types to use ThreadSafeHashMap with explicit generic parameters.
Projects/Data/Repository/Sources/BinanceCoinTradeRepository.swift Introduces the new BinanceCoinTradeRepository that maps DTOs to domain entities.
Projects/Data/DataSource/Sources/DataSource/CoinTradeDataSource.swift Adds a new data source for handling coin trade DTOs using a reactive publisher.
Projects/App/Sources/DI/Assembly/DataAssembly.swift Updates DI assembly registrations to use the new data source and repository types.
Comments suppressed due to low confidence (2)

Projects/Features/CoinDetail/Feature/Sources/CoinDetailPageViewModel.swift:213

  • The previous TradeContainer logic that handled insertion, sorting, and limiting of trades has been completely removed. Please verify that the new publisher-based approach fully replicates the intended data-processing behavior.
func listenToRecentTradeStream() {

Projects/Data/DataSource/Sources/DataSource/CoinTradeDataSource.swift:35

  • The data source uses an Int64 key for trade times while the repository mapping later uses these values to construct entities keyed by Date. Please ensure that this type conversion is intentional and consistent across the layers.
await source.tradeList.insert(key: dto.tradeTime, value: dto)

@J0onYEong J0onYEong merged commit 481578f into main Apr 21, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants