Giter Club home page Giter Club logo

yagom_juice-maker's Introduction

๐Ÿ“ ํ”„๋กœ์ ํŠธ ์ •๋ณด

  • Project: ์ฅฌ์Šค๋ฉ”์ด์ปค

  • Date: [3์ฃผ] 2021-10-18 ~ 2021-11-05

  • Contributors: ์š”ํ•œ(@YohanBlessYou, ์˜ˆ๊ฑฐ(@Jager-yoo)

  • Reviewer: ์—˜๋ฆผ (@lina0322)


๐Ÿ”‘ Project Summary

Basic

  • Singleton ๊ตฌํ˜„ ::: FruitStore.shared

  • commit ๋ฉ”์‹œ์ง€ ๋ชฉ๋ก์˜ ๊ฐ€๋…์„ฑ ๋†’์ผ ์ˆ˜ ์—†์„๊นŒ? ::: ํฐ ์ฃผ์ œ๋ณ„๋กœ prefix ๋ถ™์ด๊ธฐ

  • #selector()์— ๋“ค์–ด๊ฐˆ ๋ฉ”์„œ๋“œ๋Š” ์—๋Ÿฌ๋ฅผ ์™ธ๋ถ€๋กœ ๋˜์ง€๋ฉด(throws) ์•ˆ๋œ๋‹ค

Foundation ๊ด€๋ จ

  • Alert ๊ตฌํ˜„ ::: ๋™์ž‘ ์„ฑ๊ณต ์—ฌ๋ถ€๋ฅผ Alert๋กœ ์•Œ๋ฆผ

  • NotificationCenter ๊ตฌํ˜„ ::: ํŠน์ • Modal์˜ dismiss๋ฅผ ๋‹ค๋ฅธ ๋ทฐ์ปจ๋“ค์—๊ฒŒ ์•Œ๋ฆฌ๊ธฐ ์œ„ํ•จ

  • App ์ข…๋ฃŒ ๊ตฌํ˜„ ::: exit() (Linux Standard Exit status code)

  • ์ฝ”๋“œ ์˜ˆ์•ฝํ•˜๊ธฐ ๊ตฌํ˜„(ํƒ€์ด๋จธ์™€ ์œ ์‚ฌ) ::: DispatchQueue.main.asyncAfter(deadline: )

  • Device ํ™ˆ ํ™”๋ฉด์œผ๋กœ ์ด๋™ ๊ตฌํ˜„ ::: UIApplication.shared.perform(#selector(NSXPCConnection.suspend))

  • sleep()์€ ํƒ€์ด๋จธ๊ฐ€ ์•„๋‹ˆ๋‹ค ::: ์ปดํ“จํŒ… ์ž์›์„ ๋…์ ํ•˜์—ฌ sleep๋™์•ˆ ์–ด๋– ํ•œ interaction๋„ ๋ถˆ๊ฐ€

UI/UX ๊ด€๋ จ

  • Modal + Navigation bar ::: view์— ๋„ค๋น„ ๋ฐ”๋ฅผ ์ง์ ‘ ๋„ฃ๊ฑฐ๋‚˜, ์ฐจ์ƒ์œ„์— ๋„ค๋น„ ์ปจํŠธ๋กค๋Ÿฌ๋ฅผ ์ถ”๊ฐ€

  • Alert ๋ฒ„ํŠผ์— ํ™”๋ฉด์ „ํ™˜ ::: ์Šคํ† ๋ฆฌ๋ณด๋“œ์— segue๋ฅผ ๋งŒ๋“ค๊ณ  performSegue(identifier) ํ˜ธ์ถœ

  • ์ž๋™ Font size ๋ณ€๊ฒฝ ::: label.adjustsFontSizeToFitWidth

  • ๋ฒ„ํŠผ์— padding ์ฃผ๊ธฐ ::: title-insets

  • Alert์™€ Action sheet ์šฉ๋„ ์ฐจ์ด ::: H.I.G ์ฐธ๊ณ  / ๋ฒ„ํŠผ์ด 3๊ฐœ ์ด์ƒ์ด๋ฉด Action sheet ๊ณ ๋ ค

  • Stepper๋Š” +/- ๋ฒ„ํŠผ์„ ๊ตฌ๋ถ„ํ•˜์ง€ ๋ชปํ•œ๋‹ค ::: value change๋กœ๋งŒ ๊ฐ€๋Šฅ. ๋”ฐ๋ผ์„œ 'value ์ดˆ๊ธฐํ™”' ํ•„์š”

  • ์ง„๋™ ๊ตฌํ˜„ ::: UIFeedbackGenerator. ์ง„๋™ ํŒจํ„ด์— ๋”ฐ๋ผ 3์ข…๋ฅ˜๊ฐ€ ์žˆ๋‹ค. H.I.G์ฐธ๊ณ 

  • ์œ ์ €๊ฐ€ ํ™”๋ฉด์„ ๋ณผ ์ˆ˜ ์žˆ๋Š” ์‹œ์ ์€ viewWillAppear์™€ viewDidAppear ์‚ฌ์ด๋‹ค


UML

image

image

๐Ÿค” ํ‚ค์›Œ๋“œ Detail


ํƒ€์ž… ์„ค๊ณ„

1. ๊ณผ์ผ ์žฌ๊ณ ๋ฅผ ๊ด€๋ฆฌํ•˜๋Š” ๋ณ€์ˆ˜ ํƒ€์ž…์„ Dictionary ์™€ Array with tuples ์ค‘์— ๊ณ ๋ฏผํ–ˆ์Šต๋‹ˆ๋‹ค.

  • ๊ฐ ๊ณผ์ผ์˜ ์ด๋ฆ„๊ณผ ์žฌ๊ณ ๋ฅผ pair ๋กœ ๊ด€๋ฆฌํ•˜๊ณ  ์‹ถ์—ˆ์Šต๋‹ˆ๋‹ค.

  • ํŠœํ”Œ์„ ๋ฐฐ์—ด ์•ˆ์— ๋‹ด์•„ ์“ฐ๋Š” ๋ฐฉ๋ฒ•์„ ๊ณ ๋ฏผํ–ˆ์œผ๋‚˜, ๊ณผ์ผ ์ด๋ฆ„ ์ค‘๋ณต๋„ ํ”ผํ•˜๊ณ  ์ˆœ์„œ(index) ๋˜ํ•œ ๊ณ ๋ คํ•  ํ•„์š”๊ฐ€ ์—†์œผ๋‹ˆ, ๋”•์…”๋„ˆ๋ฆฌ๊ฐ€ ์ ํ•ฉํ•  ๊ฒƒ์ด๋ผ ์ƒ๊ฐํ–ˆ์Šต๋‹ˆ๋‹ค.

    private var inventory: [Fruit: Int] = [:]

2. ์ดˆ๊ธฐํ™”ํ•  ๋•Œ CaseIterable ํ”„๋กœํ† ์ฝœ์„ ์ฑ„ํƒํ–ˆ์Šต๋‹ˆ๋‹ค.

  • FruitStore ์ธ์Šคํ„ด์Šค๋ฅผ ์ƒ์„ฑํ•  ๋•Œ 5๊ฐ€์ง€ ๊ณผ์ผ ๋ชจ๋‘ 10๊ฐœ์”ฉ ์ฑ„์›Œ์ฃผ๋Š” ๊ณผ์ •์ด ํ•„์š”ํ–ˆ์Šต๋‹ˆ๋‹ค.

  • Fruit ์—ด๊ฑฐํ˜•์— CaseIterableํ”„๋กœํ† ์ฝœ์„ ์ฑ„ํƒํ•˜์—ฌ for๋ฌธ์œผ๋กœ ์ดˆ๊ธฐํ™”ํ–ˆ์Šต๋‹ˆ๋‹ค.

    enum Fruit: CaseIterable {
        case strawberry
        case banana
        case pineapple
        case kiwi
        case mango
    }
    
    // FruitStore ํด๋ž˜์Šค ๋‚ด์˜ init() ๊ตฌ๋ฌธ ์•ˆ์—์„œ for๋ฌธ ์‚ฌ์šฉ
    for fruit in Fruit.allCases {
        self.inventory[fruit] = FruitStore.defaultFruitAmount
    }

3. ๋ฉ”์„œ๋“œ ๋„ค์ด๋ฐ์€ ํŒŒ๋ผ๋ฏธํ„ฐ์™€ ํ•จ๊ป˜ ์ž์—ฐ์Šค๋Ÿฝ๊ฒŒ ์ฝํžˆ๋„๋ก ์„ค๊ณ„

// ๊ณผ์ผ์˜ ์žฌ๊ณ ๊ฐ€ ์ถฉ๋ถ„ํ•œ์ง€ ํ™•์ธํ•˜๋Š” ์ธ์Šคํ„ด์Šค ๋ฉ”์„œ๋“œ
fruitStore.has(.strawberry, amount: 10)

// ๊ณผ์ผ์˜ ๊ฐœ์ˆ˜๋ฅผ ์ฆ๊ฐ€์‹œํ‚ค๋Š” ์ธ์Šคํ„ด์Šค ๋ฉ”์„œ๋“œ
fruitStore.increase(.kiwi, amount: 10)

// ์ฅฌ์Šค๋ฅผ ๋งŒ๋“œ๋Š” ์ธ์Šคํ„ด์Šค ๋ฉ”์„œ๋“œ
juiceMaker.make(.bananaJuice)

Nested Type vs ํŒŒ์ผ ๋ถ„๋ฆฌ

  • ์—ด๊ฑฐํ˜•์„ ์™ธ๋ถ€ ํŒŒ์ผ๋กœ ๋ถ„๋ฆฌํ•  ๊ฒƒ์ธ๊ฐ€, ๋˜๋Š” ํƒ€์ž… ์•ˆ์— Nested Type ์œผ๋กœ ๋„ฃ์„ ๊ฒƒ์ธ๊ฐ€๋ฅผ ๊ณ ๋ฏผํ–ˆ์Šต๋‹ˆ๋‹ค.

  • Fruit ์—ด๊ฑฐํ˜•๊ณผ Error ์—ด๊ฑฐํ˜•์€ ์™ธ๋ถ€ ํŒŒ์ผ๋กœ ๋ถ„๋ฆฌํ–ˆ์Šต๋‹ˆ๋‹ค. STEP์ด ์ง„ํ–‰๋˜๋ฉด์„œ ํ”„๋กœ์ ํŠธ ๋‚ด์˜ ๋‹ค๋ฅธ ํŒŒ์ผ์—์„œ๋„ ์‚ฌ์šฉ๋  ๊ฐ€๋Šฅ์„ฑ์ด ์žˆ๋‹ค๊ณ  ํŒ๋‹จํ–ˆ์Šต๋‹ˆ๋‹ค.

  • Juice ์—ด๊ฑฐํ˜•์€ JuiceMaker ํƒ€์ž…์˜ Nested Type ์œผ๋กœ ๋„ฃ์—ˆ์Šต๋‹ˆ๋‹ค.

  • Juice ์—ด๊ฑฐํ˜• ์•ˆ์— ์žˆ๋Š” recipe ํ”„๋กœํผํ‹ฐ๋Š” fileprivate ์ ‘๊ทผ์ œ์–ด์ž๋ฅผ ์ ์šฉํ–ˆ์Šต๋‹ˆ๋‹ค.

  • ์™ธ๋ถ€ ํŒŒ์ผ์—์„œ๋„ ์ฅฌ์Šค์˜ ์ข…๋ฅ˜(cases)๋ฅผ ๋ณผ ์ˆ˜๋Š” ์žˆ์ง€๋งŒ, recipe ๋Š” ๋ณผ ์ˆ˜ ์—†๋„๋ก ๋งŒ๋“ค์—ˆ์Šต๋‹ˆ๋‹ค.

    // JuiceMaker.swift
    struct JuiceMaker {
        enum Juice {
            case ...
            
            fileprivate var recipe: [(Fruit, Int)] {
                switch self {
                    ...
                }
            }
        }
    }

yagom_juice-maker's People

Contributors

youngwoo-jang avatar jager-yoo avatar yagom avatar

Watchers

 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.