Git Product home page Git Product logo

mvvm-template-generator's Introduction


Visits Badge

Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.


Are you new to MVVM Design Pattern? Want to Learn it But feel overwhelmed of all the files you have to create?

What kind of files the template will generate?

This template generates all files that you need to create a new MVVM module. All generated code is Swift 4.2 compatible. The UIView have a TableView implemented to demonastrate the data flow, you can either keep the TableView or replace with your own design.

File Name Acts As Description
YourFileNameUI.swift UIView This is where your design layout should be.
YourFileNameView.swift View If you use Storyboard, Link this to it and delete UI file.
YourFileNameViewModel.swift ViewModel This is what will communicate with the Datasource & View.
YourFileName.swift Model This is where to write your Model.

How to install

Using script (easy)

Download the Repo to your computer, open the folder in Terminal, execute this command:

sudo swift install.swift

If all it's ok you now could find your template in Xcode.

Useage

Make Sure to initialize your viewModel and DataSource and set them to their designated variables.
Do not Import UIKit to the viewModel.

Manual Installation

Go to Application folder, browse to the Xcode application icon. Right-click it and choose 'Show Package Contents'. Then browse to: Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates/Project Templates/iOS/Application and add "MVVM Module.xctemplate" file. Now you can find your template in Xcode.

How it works?

Open xcode, Create a new group in your project for your module and named it e.g. Profile Module then create a new file inside that folder and select MVVM Module, type the name, and your files will be generated.

MVVM diagram overview

Preview

What is MVVM?

MVVM is not a framework but an approach to iOS application architecture, which stands for:

View

The view consists of views and view controllers. It is responsible to receive user interactions and pass them to presenters for decision making. To keep the view simple, it shouldn’t contain any view logics. This is where to define how the view looks like, and nothing beyond this.

View Model

The ViewModel defines the view logics, e.g. when to show a warning message or highlight a button. It is responsible to prepare content for the view to display. Whenever data is required, the view model requests data from the DataSource or the Model.

Model

A Model is responsible for exposing data in a way that is easily consumable.

Why MVVM?

After using MVVM, I've found it to be very beneficial in many ways. Let’s get back to the list of things we set out to accomplish when architecting our app to see if MVVM addresses them.

  • Single responsibility principles applied.
  • Easy to iterate on.
  • Collaboration friendly.
  • Separated out concerns.
  • Spec-ability.
  • Testability.

References

Authors

mvvm-template-generator's People

Contributors

kaakati avatar mehmetbaykar 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.