CoreData + UI/Unit Tests + Pure Swift

Related tags

Core Data MamadTodo
Overview

Swift Architecture CoreData UI/UnitTests build

What is it? 🙋🏻

It's a Todo iOS Application with offline support by the use of Core Data which has been developed as a code challenge. It's written purely in Swift without using 3rd party frameworks. The project included Unit Tests for the Core Data Layer and UI Tests exist as well.

What do you want to show by this project

How DO I respect the topics below while developing a software:

  • Reusability of the code 🔁
  • Clean Code Principles 🧼
  • SOLID Principles 🥰
  • Design Patterns 🖌
  • Loose coupling 🙇🏻‍♂️
  • Abstraction ☁️
  • Modularity 🧱
  • Testability 🧪
  • and Clean Architecture for sure! 😁

Architecture (heart of the app ❤️ )

MVVM-C + Services

J

Why ⁉️

MVVM? 🏛

MVC architecture in iOS translated to Massive View Controller. The first reason for this choice is because soon or late the code base converts to a spaghetti code-base easily. The second one is that I highly believe in sOlid principles, especially the o one which means Open For Extension So, I used this architecture to make a passive ViewController by outsourcing business logic to the ModelView layer.

Coordinator Design Pattern? 🚦

It makes the app coordination super simple. Plus, it brings loosely coupling between ViewControllers. Thus, we'll have a more testable codebase. In another way, a Coordinator is like a company that knows how to make each scene(VCs and VMs).

Services?🧑🏻‍🔧

This layer is simply responsible for communicating with whatever exists outside of the application. Like API calls, Bluetooth, saving on storage or database, etc. Again, I highly respect the SOLID principles. On the diagram image on part services, you can see Dependency Inversion. For example, in the future, if we would like to use Realm instead of Core Data, we can simply implement the Storage protocol in a class that uses Realm and easily inject it into the services layer instead of the current implementation of the Storage which is using Core Data. Thus, again, this brings Modularity and Open For Extention principles to the code-base.

Models?🫥

  1. Todo
    • Simply represent a todo model which fetchs from the HDD (a pure model)
  2. TodoViewData
    • It's a wrapper(decorator) around each Todo which do some preprocess on data before use them on ViewControllers.
  3. TodoObject
    • It contains both models above + TodoNSManagedObject of each Todo. It uses as a container which knows 3 aspects of each todo. How its NSObject, ViewData and pure model represented.

CoreData testability? 😍

If we use the same Core Data stack for the application and the same one for the tests. It's near impossible to test the Core Data CRUD actions. Why? Because if you use the same stack for saving on disk using the application, your disk data gets changes,so, you must always change your test accordingly.

J

Solution? Make 2 different stacks which makes storage and Core Data layer of the application super testable and runs tests super faster.

J

Images' source

How to reach it? 🧠

J

The left one uses by the application to really save on disk.

The right one uses by the test cases. It's created on memory that is why tests run very fast.

Video 🎥

Show.Case.mov

The last words

I invite you to see Unit Tests of the Core Data and application itself as well as UI Tests. I used GWT method to make the tests cleaner.

Attention☝🏼 Before running UITests, press Command⌘ + k on the Simulator to toggle the software keyboard.

Diagram

You can find the diagram file in the repo and open it in here

Project Definition

Project:

We would like you to build a simple "to-do" app which consists of tasks in list and task detail in detail screen.

Technical Requirements:

  • Feel free to use any architecture or design pattern
  • Do not use any reactive paradigm (SwiftUI, RxSwift etc.)
  • You can build the user interface with XIBs || Storyboards || Code
  • For the local storage, you should use Realm or CoreData

Evaluation Criteria:

  • For the local storage, you should use Realm or CoreData
  • Keep code as clean as possible
  • Your code should be easy to maintain
  • Do not try to build a fancy UI, your implementation details are more important
  • Consistency on code convention and indentation
  • Library usage (No more and less than required)
  • Git usage
  • A README.md which describes technical details/decisions
  • Unit Tests or UI Tests are bonus

Submission:

After completing the assignment, create a pull request to main branch. Then please send an email to the People Department with the link of the GitHub repo.

You might also like...
Simple IOS notes app written programmatically without storyboard using UIKit and CoreData
Simple IOS notes app written programmatically without storyboard using UIKit and CoreData

Notes Simple Notes app. Swift, UIKit, CoreData Description Simple IOS notes app

Aplikasi iOS To Do List dengan Storyboard & Local CoreData (Database Xcode)
Aplikasi iOS To Do List dengan Storyboard & Local CoreData (Database Xcode)

ToDoList Aplikasi iOS ToDoList adalah sebuah aplikasi CRUD sederhana berbasis iOS yang digunakan untuk membuat sebuah list item. Aplikasi ini dibuat m

Super awesome Swift minion for Core Data (iOS, macOS, tvOS)

⚠️ Since this repository is going to be archived soon, I suggest migrating to NSPersistentContainer instead (available since iOS 10). For other conven

A powerful and elegant Core Data framework for Swift.
A powerful and elegant Core Data framework for Swift.

A powerful and elegant Core Data framework for Swift. Usage Beta version. New docs soon... Simple do that: let query = persistentContainer.viewContext

CloudCore is a framework that manages syncing between iCloud (CloudKit) and Core Data written on native Swift.
CloudCore is a framework that manages syncing between iCloud (CloudKit) and Core Data written on native Swift.

CloudCore CloudCore is a framework that manages syncing between iCloud (CloudKit) and Core Data written on native Swift. Features Leveraging NSPersist

 Unleashing the real power of Core Data with the elegance and safety of Swift
Unleashing the real power of Core Data with the elegance and safety of Swift

Unleashing the real power of Core Data with the elegance and safety of Swift Dependency managers Contact Swift 5.4: iOS 11+ / macOS 10.13+ / watchOS 4

Swift client library to interact with Supabase Storage
Swift client library to interact with Supabase Storage

storage-swift Swift Client library to interact with Supabase Storage.

HitList is a Swift App shows the implementation of Core Data.
HitList is a Swift App shows the implementation of Core Data.

HitList HitList is a Swift App shows the implementation of Core Data. It is the demo app of Ray Wenderlich's tech blog. For details please reference G

A type-safe, fluent Swift library for working with Core Data
A type-safe, fluent Swift library for working with Core Data

Core Data Query Interface (CDQI) is a type-safe, fluent, intuitive library for working with Core Data in Swift. CDQI tremendously reduces the amount o

Owner
iMamad
iOS Developer
iMamad
CoreData based Swift ORM

Swift ORM Features Pure swift objects - no more subclasses of NSManagedObject Extensible attribute system - store any type in CoreData storage by impl

Prisma Labs 89 Dec 29, 2022
A Swift framework that wraps CoreData, hides context complexity, and helps facilitate best practices.

Cadmium is a Core Data framework for Swift that enforces best practices and raises exceptions for common Core Data pitfalls exactly where you make the

Jason Fieldman 123 Oct 18, 2022
🎯 PredicateKit allows Swift developers to write expressive and type-safe predicates for CoreData using key-paths, comparisons and logical operators, literal values, and functions.

?? PredicateKit PredicateKit is an alternative to NSPredicate allowing you to write expressive and type-safe predicates for CoreData using key-paths,

Faiçal Tchirou 352 Jan 3, 2023
A small set of utilities to make working with CoreData and Swift a bit easier.

SuperRecord =================== SUPPORTS SWIFT 2.0 from Version >= 1.4 ** SUPPORTS SWIFT 1.2 from Version <= 1.3 Both iOS and WatchOS A Swift CoreData

Michael Armstrong 372 Jul 19, 2022
A Swift framework that wraps CoreData, hides context complexity, and helps facilitate best practices.

Cadmium is a Core Data framework for Swift that enforces best practices and raises exceptions for common Core Data pitfalls exactly where you make them.

Jason Fieldman 123 Oct 18, 2022
DataKernel is a minimalistic wrapper around CoreData stack to ease persistence operations.

DataKernel What is DataKernel? DataKernel is a minimalistic wrapper around CoreData stack to ease persistence operations. It is heavily inspired by Su

Denis 16 Jun 2, 2022
SugarRecord is a persistence wrapper designed to make working with persistence solutions like CoreData in a much easier way.

What is SugarRecord? SugarRecord is a persistence wrapper designed to make working with persistence solutions like CoreData in a much easier way. Than

Modo 2.1k Dec 29, 2022
App agenda with CoreData

iOS Agenda App with CORE DATA Ejemplo de código para una aplicación de agenda, gestionando el modelo de datos con CoreData. Built using XCode 13.0 (Sw

Manu Martinez 1 Oct 19, 2021
Domain Specific Language to safely build predicates and requests to fetch a CoreData store

SafeFetching This library offers a DSL (Domain Specific Language) to safely build predicates and requests to fetch a CoreData store. Also a wrapper ar

Alexis Bridoux 13 Sep 13, 2022
iOS app built with UIKit and programatic auto-layouts to learn and apply knowledge. Offline storage using CoreData and Caching

PurpleImage Search Pixabay for images and save them offline to share and view To use: Clone the GitHub project, build and run in Xcode. The API is com

Frederico Kückelhaus 0 May 10, 2022