GithubHelp home page GithubHelp logo

Step4 Feedback about swift-cardgameapp HOT 4 OPEN

jinios avatar jinios commented on August 25, 2024
Step4 Feedback

from swift-cardgameapp.

Comments (4)

jinios avatar jinios commented on August 25, 2024

객체 위임 관계

이름을 결정할 때 mainViewController 내부에서 다른 곳에 위임하는 객체를 cardGameDelegate로 정하고
카드게임을 전체 관리하는 싱글톤 객체를 CardGameManager로 하도록 하세요.
카드게임매니저가 ViewController 입장에서 델리게이트(위임한) 객체가 되는겁니다.

from swift-cardgameapp.

jinios avatar jinios commented on August 25, 2024

네이밍 이슈

  • 객체 타입 이름에 Delegate를 붙이기보다는 프로토콜 이름에 붙이는 편입니다. 참고하세요.
  • UIView에서 draw- 시작하는 것은 Rendering 규칙에 맞춰서 Core Graphics 수준에서 그릴 때 사용하는 용어입니다. 하위 뷰 객체를 설정하는 경우에 사용하면 헷갈릴 수 있습니다. configure- 혹은 setup- 같은 다른 표현을 사용하는게 좋겠습니다.
  • 위에 있는 drawRefresh()와 redraw()도 명확하게 구분이 안되는 것 같습니다. draw- 보다 다른 표현을 사용해서 명확하게 구분해주면 좋겠습니다. 다시 그리기 위한 표현은 invalidate- 도 많이 쓰는 표현입니다.
  • 위에 deckView와 foundationView는 drawDefault()로 동일한데 stackView는 newDraw() 네요? 같은 동작인데 함수 이름이 특별히 다른 이유가 있나요?

from swift-cardgameapp.

jinios avatar jinios commented on August 25, 2024

간단한 코드 이슈

class CardStacksView: UIView {
    var gameManager: CardGameManageable = CardGameDelegate.shared()
    var wholeStackManager: (CardStackManageable & Stackable)!
    var oneStackViews = [OneStack]()
 // ...
    convenience init() {
        self.init(frame: CGRect(x: 0, y: PositionY.bottom.value,
                                width: 414, height: 736 - PositionY.bottom.value))
        self.wholeStackManager = gameManager.getWholeStackDelegate()
    }
  • gameManager가 단지 wholeStackManager 만 가져오기 위한거라면 인스턴스 변수로 선언할 필요까지는 없고 여기서 CardGameDelegate.shared().getWholeStackDelegate() 로 접근해도 될 것 같네요.
    • CardStacksView에서 CardGameDelegate가 하는 일이 별로 없이 스택객체만 전달해주는 역할만 하기때문에 인스턴스변수로 선언해야하나 말아야하는지 고민했던 부분이다. 결국 가독성을 높일 겸 인스턴스변수로 선언하게되었는데 이정도는 오히려 바로 접근하도록 만드는 것이(특히 싱글톤객체이기때문에) 더 좋은 방법인 것 같다.

  • 습관적으로도 모든 var 변수는 private으로 선언하도록 하세요.
  • required init?(coder aDecoder: NSCoder)에 fatalError를 남겨놓기 보다는 동일하게 동작하도록 지정생성자를 연결해주는 게 좋습니다.

from swift-cardgameapp.

jinios avatar jinios commented on August 25, 2024

ViewController 중복코드 분리

  • deckViewDidDoubleTap()과 stackViewDidDoubleTap() 두 개 함수가 비슷한 부분이 많은 것 같은데... 합쳐서 공통화할 수 있을까요?

from swift-cardgameapp.

Related Issues (20)

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.