4 ms·
I haven't done any iOS development before but is there any real reason why a tiny app with what seems to be ~100 lines of code needs to be split into several sm
by userbinator 11y ago
I haven't done any iOS development before but is there any real reason why a tiny app with what seems to be ~100 lines of code needs to be split into several small files with even fewer lines in them?
https://github.com/WDUK/A9ChipSource/tree/master/A9ChipSource https://github.com/WDUK/A9ChipSource/tree/master/A9ChipSourc...
As far as I can see, the actual work is performed by around 5 lines of code in this file, which reads a configuration value, performs two string comparisons, and outputs to 2 text fields:
https://github.com/WDUK/A9ChipSource/blob/master/A9ChipSource/ViewController.m https://github.com/WDUK/A9ChipSource/blob/master/A9ChipSourc...
In other words, is this level of verbosity/"fluff" typical of iOS apps?
- melling 11y agoAppDelegate.m and main.m are boilerplate. They are generated by Xcode when you create a new project. Often you don't change them. The ViewController is where you should start examining the code. Of course, you have the .h files too. With Swift these go away so there's fewer files. Finally, you can do scripting that doesn't have any boilerplate: http://www.h4labs.com/dev/ios/swift.html?age=10000&q=scripting http://www.h4labs.com/dev/ios/swift.html?age=10000&q=scripti...
- mfkp 11y agoMost of what you see is the boilerplate of generating a new iOS app. You're right, all of the interesting code is in ViewController.m, and if this were extracted to a library it would be much smaller. I think the point of this repo is a demo app that you can build and run on your phone to find out which chip manufacturer you have.
- ctdonath 11y agoThat's not much verbosity/fluff. It's the typical default auto-generated code files; basically the author said "new project" and filled in a few lines. No need to hand-optimize this into minimum files. ETA: With some cut-and-paste & removing stubs, and preserving the storyboards, the whole thing can be reduced to 20 lines in just main.m, smaller if you shift into "obfuscated objective-c" mode.
- WDUK 11y agoExactly, I spent less than half an hour writing this up, and wasn't aiming for the lowest LOC possible. This is all mostly boilerplate.
- deleted 11y ago[deleted]
- mnem 11y agoA quick port to Swift: https://github.com/mnem/SwiftA9ChipSource https://github.com/mnem/SwiftA9ChipSource. The functional bit is in https://github.com/WDUK/A9ChipSource/blob/master/A9ChipSource/ViewController.m https://github.com/WDUK/A9ChipSource/blob/master/A9ChipSourc.... Objective-C isn't too bad. I've certainly had more boilerplate to deal with on various other platforms. In terms of names, it is verbose though. It's one of the things I really like about it.
- phire 11y agoI should have come to the comments before trying to work out which file the functional code was in.