Fast way to build a product
3 years ago, I had to learn Node.js and few server techniques to build my own product. Everything worked slowly. Learning to build is painful. I could make it work but couldn't deeply understand it. I was lost on knowing if it is the correct or best way to implement it.
Wouldn’t it be nice if we can build something without having a server? In other words, server less. Sounds great, right? But the question is, how do you implement it?
Luckily, I can share the experience I had and tell you about it. It is probably not the best practice, but it can work if you have a MVP to validate the market. It is better than spending money and putting a lot of effort for both server and mobile apps.
1. Choose a serverless service
So, first things first. Go and look out for a server less service. Here are some good services that you can definitely use for your project: Firebase, Parse, Back4App, and backendless.
Just keep in mind, each of them has their own advantages and disadvantages. So choose wisely.
To save some time, I am going to use Firebase since I am proficient in it.
2. Boost your serverless
Firebase and Parse both have powerful functions that uses Cloud functionality. In your project(s), you can add tools, actions, and triggers.
Here are some examples:
-
using the 3rd party framework, Stripe, where you can process payments.
-
Change the status of a database when it reaches a deadline
-
Update data from the user whenever they have added something from their mobile device.
Check this link out. You can read more from the Firebase Documentation or Cloud Functions samples.
3. Build flexible and easy-to-change mobile UI
It is always nice to make changes very easily. I am sure that you have UI changes several times. To save you some time, don’t focus on building fancy UI. Build the “skeleton” first then apply the “skin”. Try these articles:
- https://www.codementor.io/nguyentruongky33/implement-flexible-ui-with-uitableview-slww3uor5
- https://www.codementor.io/nguyentruongky33/make-super-fast-list-with-uitableview-szgo9vmui
4. Write centralized code
There will be a point where you will contain custom colors and fonts for your UI, so ask yourself, do you want to change it for every file? (Maybe you have 200 files and have to change it more than 1000 places. Yikes!)
Well you should know, that for myself, I don't like that. I'm pretty sure you don't either. So let's just get it from only one place
Try it!
extension UIFont {
enum knWeight: String {
case black = "Muli-Black"
case bold = "Muli-Bold"
case medium = "Muli-SemiBold"
case regular = "Muli-Regular"
}
static func main(_ weight: knWeight = .regular, size: CGFloat = 15) -> UIFont {
return font(weight.rawValue, size: size)
}
static func font(_ name: String, size: CGFloat) -> UIFont {
guard let font = UIFont(name: name, size: size) else { return UIFont.boldSystemFont(ofSize: size) }
return font
}
}
Now I don't want to use Muli family anymore, just change it here. That's it.
Or this one
extension UIColor {
static let main = UIColor.black
static let secondary = UIColor.darkGray
}
Don't give specific name like lightRed, alphaBlue, grayCyan… Ask your designer, if you have one, that can give you specific and generic names and that it can follow the basic guidelines and designs. When it comes to a point to change, now you know where to change it and it will not take a lot of time.
5. Write flexible code
At some point, you will change several things such as: 3rd party libraries, local database, or server less service in the future. It could happen any time. I am sure that you do not want to repeat yourself. i.e. (Login, register, forgot password, dashboard, updating user details).
**Using protocols is a life saver. It helps you to not write tight coupling code **
protocol Service {
func login(email: String, password: String, completion: (AnyObject) -> Void)
}
class FirebaseService: Service {
func login(email: String, password: String, completion: (AnyObject) -> Void) {
print("Do login with Firebase")
}
}
class NewService: Service {
func login(email: String, password: String, completion: (AnyObject) -> Void) {
print("Do login with New service")
}
}
var service: Service { return FirebaseService() } // put it somewhere globally or locally, depend on you.
// You will change to NewService() when you need to switch. That's all.
class LoginController {
func login() {
service.login(email: "nguyentruongky33@gmail.com", password: "AwesomeiOS", completion: { result in
print("Handle response here")
})
}
}
Conclusion
So there you go! Some of my tips of iOS Development. There are still topics to cover such as operations and paperwork. If you are interested, I will make another article about it in the near future. Again, I am sure that they are the perfect or best practices but this can be an idea.
There are awesome developers who would know better ways to do the implementation. If by any chance you’ve come across some, please share them with me on the comments below or send me a direct message!
Share to grow. Enjoy coding.