you-play / YouPlay

An app that creates mood-based playlists for seamless music streaming.
MIT License
3 stars 0 forks source link

Feature/project scaffold #10

Closed sebastian-nunez closed 7 months ago

sebastian-nunez commented 7 months ago

Feature/project scaffold

Description

Adds the basic project scaffold and folder structure.

For the project, we will heavily use dependency injection and the MVVM architecture to make our code more modular and reduce coupling.

Dependency Injection in Action

// Without dependency injection
class Foo {
    let bar: Bar = Bar()
}

// With dependency injection
class Foo {
    let bar: Bar

    init(bar: Bar) {
        self.bar = bar
    }
}

Essentially, in the 2nd example, you can see that Bar is a dependency and it's passed in through the constructor. This way, we could sub-in/swap out different implementations of Bar.

Model-View-ViewModel

  1. Model: data layer which defines what the object looks like.
  2. View: displays the actual SwiftUI component and data (should not have much business logic)
  3. ViewModel: used to manipulate data. This piece interacts with services and models

View and ViewModel should be kept within the same folder. For a Login "page", we name the view and view-model like this LoginView and LoginViewModel (this applies to all pages or components)

- Login
  |- View
  |  |- LoginView.swift
  |  |- (Other view files)
  |
  |- ViewModel
  |  |- LoginViewModel.swift
  |  |- (Other ViewModel files)

Folder Notes