Giter Club home page Giter Club logo

ios-bank-manager's Introduction

🏦 은행 창ꡬ λ§€λ‹ˆμ € _ μ›°μ‹œμ½”λ”©πŸΆ

πŸ“– λͺ©μ°¨

πŸ€ μ†Œκ°œ
πŸ‘¨β€πŸ’» νŒ€μ›
⏱️ νƒ€μž„λΌμΈ
πŸ‘€ μ‹œκ°ν™”λœ ν”„λ‘œμ νŠΈ ꡬ쑰
πŸ’» μ‹€ν–‰ ν™”λ©΄
🧨 νŠΈλŸ¬λΈ” μŠˆνŒ…
πŸ“š μ°Έκ³  링크
πŸ‘₯ νŒ€ 회고


πŸ€ μ†Œκ°œ

ν•œ λͺ…μ˜ 직원을 가진 은행이 10 ~ 30λͺ…μ˜ 고객을 λ°›μ•„ μ‘λŒ€ν•˜λŠ” ν”„λ‘œκ·Έλž¨μž…λ‹ˆλ‹€.


πŸ‘¨β€πŸ’» νŒ€μ›

🐬Whales🐬 🍎Zion🍎
Github Profile Github Profile

⏱️ νƒ€μž„λΌμΈ

λ‚ μ§œ λ‚΄μš©
2023.07.10 - Node 클래슀 생성
- LinkedList ꡬ쑰체 생성
- LinkedList Test 진행
2023.07.11 - Queue ꡬ쑰체 생성
2023.07.12 - Client ꡬ쑰체 생성
- BankManager ꡬ쑰체 생성
- Bank 클래슀 생성
2023.07.13 - μ—…λ¬΄μ™„λ£Œ 메세지 둜직 μΆ”κ°€
- 파일 ꡬ쑰정리
2023.07.14 - usleep λ©”μ„œλ“œλ₯Ό Thread.sleep λ©”μ„œλ“œλ‘œ μˆ˜μ •

πŸ‘€ μ‹œκ°ν™”λœ ν”„λ‘œμ νŠΈ ꡬ쑰

ℹ️ File Tree

β”Œβ”€β”€ ios-bank-manager
β”‚Β Β  β”œβ”€β”€ BankManagerConsoleApp
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ Model
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ Client
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ BankManger
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ Bank
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ Node
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ LinkedList
β”‚Β Β  β”‚Β Β  β”‚Β Β  └── Queue
β”‚Β Β  └── Tests
└── README.md

πŸ“ Diagram

λ‹€μŒ Step 진행 ν›„ μž‘μ„± μ˜ˆμ •

πŸ’» μ‹€ν–‰ ν™”λ©΄

🧨 νŠΈλŸ¬λΈ” μŠˆνŒ…

1️⃣ Escaping closure captures mutating 'self' parameter Error

🚨 문제점
Bank Type을 struct둜 μ„€μ •ν•˜μ—¬ Closure λ‚΄λΆ€μ—μ„œ Captureμ‹œ Closureλ‚΄λΆ€μ˜ Bank와 ν΄λ‘œμ € μ™ΈλΆ€μ˜ Bankκ°€ λ™μΌν•˜μ§€ μ•Šμ•„ κ²½κ³  문ꡬ가 λ…ΈμΆœ λ˜μ—ˆμŠ΅λ‹ˆλ‹€.

πŸ’‘ 해결방법

DispatchQueue.global().async(group: group) {
                self.bankManger.work(client: client)
                semaphore.signal()
            }

ν˜„μž¬ Bank Type의 startTask 둜직 λ‚΄λΆ€μ—μ„œλŠ” Bank Type의 λ‚΄λΆ€ λ³€μˆ˜μ— μ ‘κ·Όν•˜λŠ” async둜직이 μ‘΄μž¬ν•©λ‹ˆλ‹€. λ”°λΌμ„œ Bank Type을 struct둜 μ„€μ •ν•˜κ²Œ λœλ‹€λ©΄ asyncκ°€ 등둝될 λ•Œμ˜ Bank와 async block λ‚΄μ—μ„œ capture 될 λ•Œμ—μ˜ Bankκ°€ μ„œλ‘œ λ‹€λ₯Έ Bank 일 수 μžˆμŠ΅λ‹ˆλ‹€.

κ·Έ μ΄μœ λŠ” 일반적으둜 ν΄λ‘œμ € λ‚΄μ—μ„œ 값을 μΊ‘μ³ν–ˆμ„ λ•Œμ—λŠ” κ°’ νƒ€μž…μ΄λ“  μ°Έμ‘° νƒ€μž…μ΄λ“  Strong Reference ν˜•νƒœλ‘œ 값을 μ°Έμ‘°ν•˜μ§€λ§Œ κ°’ νƒ€μž…μ˜ κ²½μš°μ—λŠ” λ³΅μ‚¬λœ 값에 λŒ€ν•œ μ£Όμ†Œ 값을 μ°Έμ‘°ν•˜κΈ° λ•Œλ¬Έμ— async둜 등둝할 λ•Œμ˜ Bank와 μ‹€μ§ˆμ μœΌλ‘œ async block이 싀행될 λ•Œμ˜ Bankκ°€ 같은 Bankμž„μ„ 보μž₯ν•  수 μ—†κΈ° λ•Œλ¬Έμž…λ‹ˆλ‹€.

λ”°λΌμ„œ Bankλ₯Ό Class μ°Έμ‘° νƒ€μž…μœΌλ‘œ μ„€μ •ν•˜μ—¬ μ°Έμ‘°ν•  수 μžˆλ„λ‘ λ³€κ²½ν–ˆμŠ΅λ‹ˆλ‹€. λ˜ν•œ Strong Reference μ°Έμ‘°λ₯Ό ν•˜κ²Œλœλ‹€λ©΄ μˆœν™˜μ°Έμ‘°μ˜ κ°€λŠ₯μ„±μ—λŒ€ν•΄ κ³ λ―Όν•΄λ΄€μ§€λ§Œ μœ„μ™€ 같은 κ²½μš°μ—μ„œλŠ” async blockμ—μ„œλŠ” Bankλ₯Ό μ°Έμ‘°ν•˜κ³  μžˆμ§€λ§Œ Bankμ—μ„œλŠ” ν•΄λ‹Ή async block을 μ§μ ‘μ μœΌλ‘œ μ°Έμ‘°ν•˜κ³  μžˆμ§€μ•ŠμœΌλ―€λ‘œ μˆœν™˜μ°Έμ‘°κ°€ λ°œμƒν•˜μ§€μ•ŠκΈ° λ•Œλ¬Έμ— [weak self]의 μΊ‘μ³ν‚€μ›Œλ“œλŠ” μƒλž΅ν–ˆμŠ΅λ‹ˆλ‹€.

2️⃣ DispatchQueue vs OperationQueue

🚨 문제점
DispatchQueue와 OpeartionQueue 쀑 μ–΄λ–€ λ°©μ‹μœΌλ‘œ 문제λ₯Ό 해결할지 κ³ λ―Όν–ˆμŠ΅λ‹ˆλ‹€.

πŸ’‘ 해결방법
쑰금 더 객체지ν–₯적인 ν”„λ‘œκ·Έλž¨μ˜ λ™μž‘μ„ μœ„ν•΄ DispatchQueueλ₯Ό μ‚¬μš©ν•˜μ—¬ κ΅¬ν˜„ν–ˆμŠ΅λ‹ˆλ‹€.

DispatchQueue을 ν™œμš©ν•΄ ν•΄λ‹Ή μš”κ΅¬μ‚¬ν•­μ„ κ΅¬ν˜„ν•˜λŠ” λ°©λ²•μœΌλ‘œλŠ” DispatchGroup 및 DispatchSemaphoreλ₯Ό ν™œμš©ν•˜λŠ” 방법이 μžˆμ—ˆκ³  OperationQueueλ₯Ό ν™œμš©ν•œλ‹€λ©΄ maxConcurrentOperationCount property 및 waitUntilAllOperationsAreFinished λ©”μ„œλ“œμ˜ ν™œμš©μœΌλ‘œ 과제λ₯Ό ν•΄κ²°ν•  수 μžˆμ—ˆμŠ΅λ‹ˆλ‹€.

ν•˜μ§€λ§Œ Bank, BankManager, Clientκ°€ μ½”λ“œλ₯Ό μ½λŠ” μž…μž₯μ—μ„œ 쑰금 더 μžμ—°μŠ€λŸ½κ²Œ 객체지ν–₯적으둜 μ˜μ‚¬μ†Œν†΅ν•  수 μžˆλŠ” 섀계에 λŒ€ν•΄ κ³ λ―Όν–ˆκ³  Operation을 μƒμ†λ°›λŠ” Type을 λ§Œλ“€μ–΄μ„œ OperationQueue에 λ„£μ–΄μ£ΌλŠ” λ°©λ²•λ³΄λ‹€λŠ” DispatchQueue async 둜직 λ‚΄λΆ€μ—μ„œ BankManagerκ°€ μ§μ ‘μ μœΌλ‘œ 업무λ₯Ό μ‹€ν–‰ν•˜κ³  κ·Έ 업무λ₯Ό μ‹€ν–‰ν•˜λŠ” 데 μžˆμ–΄μ„œ customerλ₯Ό μ£Όμž… λ°›λŠ” 방식을 μ‚¬μš©ν–ˆμŠ΅λ‹ˆλ‹€.

λ¬Όλ‘  같은 결과물을 λ‚˜νƒ€λƒˆκ² μ§€λ§Œ 쑰금 더 객체지ν–₯에 λŒ€ν•΄μ„œ κ³ λ―Όν•΄λ³Ό 수 μžˆμ–΄μ„œ μ’‹μ•˜μŠ΅λ‹ˆλ‹€.

πŸ“š μ°Έκ³  링크

ios-bank-manager's People

Contributors

leezion94 avatar whalesjin avatar yagom avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.