Yeah! We know!
The title just sounds a little daunting! But, hear me out here…
So you have this really cool app that you have just started. Its gonna have the most beautiful UI that anyone has ever seen. So start with the launch screen. the usual Launchscreen .storyboard file is created. Its clean and concise.
Then you start working on the actual UI inside the Main.storyboard. And you start create a new ViewController put everything inside it. And then there's another. And soon they are all connected to each other with segues. And then soon it’s a spider-web of segues all over the place. The Storyboard file starts taking “forever” to load. And now there is no turning back. There are more than 20 screens that have already been created and you can’t do anything about it.
Oh God! This is Hell-On-Earth!
Yeah! Yeah! I hear you! I know you would say that I’ll be the smart guy. I split all the screens based on the modules. And each module has its own storyboard file. So my code is just as I want it.
Are you really sure that solve your problem?
Because soon, you’ll have screens are never shown. They are just dead weight that you app is caring. If that's not worse, you now have to keep a track of all the storyboard file names. The tests now take longer times. And it’s starts becoming a spaghetti code now matter how hard you try. Its the well known MASSIVE VIEW CONTROLLERS problem that we all want to run away from!
So, what is the solution?
Simple Answer -> Write MORE CODE.
The simple logic behind abandoning the storyboards and going in on “all code” is really simple.
The storyboard, at the end is just code. Yeah its XML, but still code. All we have to do is write the UI in some other language. But leaving the storyboard will empower you to do a lot of great stuffs.
1. You can collaborate with other users a lot better. Sharing and merging code through some VCS is much better than trying to resolve conflicts on a storyboard file. I have nothing else to say. Just try it out for yourself!
2. You will be able to reuse even the smallest of components. Let’s say, you have a rounded corner button that needs to be consistent throughout the app. You just simple write a subclass for UIButton and Done! Next time you want to edit the button, just go the class and change it. Its arguable easier than going through the storyboard.
3. When you are writing code, you are actually thinking to the most minutest detail. It’s about how the UI is going to be created? How it’s going to be loaded onto the memory? When will the object of required components be created and define its appropriate behaviors? You can alter the behaviors at run time! and the possibilities are limitless.
And there's a lot more… Just try it out once!
I’m not saying leave storyboards. Storyboard save a lot of time for micro projects or static screens. But if your project is going to evolve over time, you will have to switch to writing UI in code!