
Open sourcing our Android and iOS apps - mecredis
https://kickstarter.engineering/open-sourcing-our-android-and-ios-apps-6891be909fcd#.9bls0yl69
======
unsoundInput
Kudos to them. Compared to the web it's rather cumbersome to poke into
packaged and released mobile apps, so I really appreciate access to the source
of a real world app for learning and comparison.

The Android codebase looks very modern and well structured. I think it makes
great use of many of the goodies (gradle, rxjava, retrofit, dagger, android
support lib, ...) and learnings (bring your own MV*; use Fragments when you
need them, stick to Activities if you can) that is state of the art in Android
development. I think it's a great thing to skim through if you are interested
in developing for Android or to compare it to you own app.

I can only assume that the same is true for I iOS. I'll certainly check it out
should I start developing for that platform.

~~~
V-2
Yeah, they sort of rolled out their own MVVM implementation, based on RxJava
and RxLifecycle.

On Android MVVM is more difficult than MVP in my opinion (the most popular
choice, not counting spaghetti projects), mostly because the platform doesn't
provide the "glue" needed to bind viewmodels to the UI layer. At first glance
it looks like they did it without overengineering, which is another trap as
far as these matters go.

Clearly a work of very good experts

~~~
Plaastix
That "glue" can be Android's Databinding library. I've used it to bind
ViewModel data to views. Works really well.

~~~
V-2
I'm aware of it, but last I checked it didn't seem production-ready and lacked
features. I believe they updated it at some point, but other than some talk at
Google IO not much came out of it - even the docs didn't reflect it back then.
Perhaps it's up to the task now, I admit I'm not looking it up regularly.

~~~
Plaastix
It is definitely production ready now.

------
120bits
I'm not a mobile app developer by profession. But I always wanted to start
learning and developing real world apps. The problem I always ran into the
tutorials and demos, that they are mostly limited(i.e not close to solving
real world problems). I think browsing their code, will give me a good start.
And I would know how it's done right! Thank You!

~~~
nodamage
Having looked through this project I would not recommend using it as a basis
for learning how an iOS app is "done right", as they've deviated from standard
iOS/Swift paradigms significantly. In particular, the use of ReactiveCocoa and
MVVM creates an app that is structured completely differently from a
"traditional" iOS app. They've also used (abused?) Swift's ability to define
custom operators which results in a lot of code like this:

    
    
        self.youLabel
          |> authorBadgeLabelStyle
          |> UILabel.lens.textColor .~ .whiteColor()
          |> UILabel.lens.text %~ { _ in Strings.update_comments_you() }
    

Which again is very different from regular iOS/Swift code.

That said, I think this project is interesting to look at from the perspective
of "this is what it would look like to go all-in with ReactiveCocoa and MVVM".
It's kinda like Twisted in Python: Twisted code looks very different from
normal Python code, cause once you start using Twisted, it becomes Twisted all
the way down.

------
tthbalazs
I had a chance to see Brandon from Kickstarter talk about their functional
approach at the Functional Swift Conference in Budapest. I highly recommend
watching it!

[https://www.youtube.com/watch?v=A0VaIKK2ijM](https://www.youtube.com/watch?v=A0VaIKK2ijM)

~~~
goblin89
Thanks for the link. Watching so far, many of the points Brandon makes vaguely
resonate with how I approach structuring my code, but knowing the common
vocabulary (f.ex. the term ‘co-effect’) enables me to communicate how and why
I do things, and ultimately to improve.

Out of curiosity, how much were the tickets and how early was it sold out? I
was in Budapest right at that time to attend our remote team meeting, and I’m
cursing myself for not knowing about this conference.

------
ohstopitu
Last year when I was working on a startup's mobile app for Android, it was
almost impossible to find good quality code that was open sourced.

I am really happy that Kickstarter has released their android app as open
source - would definitely be a great learning experience!

~~~
Plaastix
There are quite a few "sample" open source projects that demonstrate best
practices and various Android architectures. However, they are not fully
fledged production applications like the Kickstarter app.

~~~
ohstopitu
That's the entire issue, I've seen quite a lot of "sample" apps that do one
thing (like nav bar, or fragments, or animations etc.)

But each of htem brings their own libraries, and don't explain what what's
necessary and it's left to the user ot decide to how stitch all of this
together.

Don't get me wrong...I'm happy for the demo apps (they had made my life a lot
easier), but a production grade app is a whole different ballgame.

~~~
dublinben
F-Droid is full of "real" apps that are completely open source. You can look
at any of them to see how they work.

------
dblock
For anyone reading their post, we're so humbled by Kickstarter mentioning the
tiny Artsy for having inspired some of this work. If you're interested in the
open-source by default conversation and need some ammo to bring this to your
team, start at [http://code.dblock.org/2015/02/09/becoming-open-source-by-
de...](http://code.dblock.org/2015/02/09/becoming-open-source-by-default.html)

------
melling
They use Swift Playgrounds to do a lot of development:

"Swift Playgrounds for iterative development and styling. Most major screens
in the app get a corresponding playground where we can see a wide variety of
devices, languages, and data in real time."

[https://github.com/kickstarter/ios-
oss/tree/master/Kickstart...](https://github.com/kickstarter/ios-
oss/tree/master/Kickstarter-iOS.playground/Pages)

I've recently bought into this development method too. It's not quite what
Bret Victor dreamed up, but it's a big step in the right direction.

~~~
j_s
Is this similar to Xamarin Workbooks?

[https://developer.xamarin.com/guides/cross-
platform/workbook...](https://developer.xamarin.com/guides/cross-
platform/workbooks/)

------
ocdtrekkie
This is pretty awesome. Just because an app connects to a single
website/service doesn't mean there isn't a benefit to being open! It's good to
be able to trust (and verify) the software running on our devices.

~~~
IgorPartola
This. There is really no downside to doing this, and lots of potential upside.
I honestly think most companies could do this with zero effect to their bottom
line.

~~~
wmichelin
If your code is bad, then there's risk of making security vulnerabilities more
visible. Not that that's a good reason to avoid open sourcing, but it's a
reason.

~~~
IgorPartola
Which is also a good reason to open your code and let those that know better
help you fix it.

~~~
Alupis
> Which is also a good reason to open your code and let those that know better
> help you fix it.

This is a fantastic mentality, but unfortunately doesn't really play out in
reality.

I'm a huge Open Source fanboy, but we need to be "real". How many people are
really going to read every line of every open source program? Very-few-to-none
is the real answer. Massively popular software gets eyeballs, but few others
do.

Most of us just use the software and trust/hope someone else reviewed it for
security et al.

The problem with that is, we are all trusting/hoping someone else did a
review, but that someone else is trusting/hoping someone else did a review.

~~~
IgorPartola
How many of the people that do review your code would exploit it vs reporting
it to you? Combine it with a bounty program, and chances are you will get
useful feedback at a fraction of the cost of a full on audit.

~~~
Alupis
I agree with the sentiment of your post, however I believe it is based on an
ideal world, which we don't live in.

> How many of the people that do review your code would exploit it vs
> reporting it to you

By nature, attackers would be reviewing your code as well.

> Combine it with a bounty program

The overwhelming majority of Open Source software was created-by and is
curated-by a single person who makes negative profit by working on the
software for free in their spare time. Even some of the most popular projects
are still total losses for their curators. You're not going to get bug bounty
programs here.

For example, take a look at Crosstool-ng[1] (a popular project used to build
cross-compilers for various architectures). Companies and individuals are all
using this project to build cross-compilers that they trust to build other
software with. A bug in Crosstool-ng could propagate into bugs in the compiled
software it produces. Bryan Hundven does most of the heavy lifting on this
project by himself, and as far as I know, he's paid nothing for it. You're not
going to get a bug bounty program here either.

Heck, it's doubtful even a project as large as the Linux Kernel would be able
to afford an ongoing bug bounty program. They're trying with the Linux
Foundation and the Core Infrastructure program, but how many years before did
it have none of that?

Essentially, these programs only work for commercially-backed software, which
is only a small sliver of open source software.

[1] [https://github.com/crosstool-ng/crosstool-
ng](https://github.com/crosstool-ng/crosstool-ng)

~~~
IgorPartola
But I am specifically talking about companies with closed source apps and
services open sourcing them, not tools that are already open. Examples are
Uber, AirBnB, and Groupon, not gpg or OpenSSL.

~~~
Alupis
> But I am specifically talking about companies with closed source apps and
> services open sourcing them

Ah, I see. I misunderstood. Yes, I think we are in agreement then, although I
have my doubts most companies want their "secret sauce" or code-indiscretions
flapping in the wild.

~~~
IgorPartola
I think it depends. The exact PageRank algorithm, or the process that Uber
uses to route drivers: probably not. The UI to any of that: why not? I think
there is very little secret sauce out there and most of the stuff is just bog
standard code that would do no harm being in the open.

~~~
Alupis
Couldn't agree more.

I think the largest hurdle for getting more stuff open sourced is two-fold.

1) A large amount of software is sub-par, and likely commits many atrocities
including having business logic in the UI.

2) Companies are afraid they'll be embarrassed by their code, and would rather
not take the risk of being branded as a company that doesn't do things right.

For number 1, there are potential solutions by hiring better engineers etc...
but number 2 is always a (perceived) risk, even if their codebase is
"perfect".

------
krschultz
This is very exciting. There simply aren't a lot of open source "full scale"
Android apps. Most of what you find are quick sample apps which simply don't
show the complexity inherent in most professional apps. The largest other ones
I'm aware of are Github, Google I/O, and some of the AOSP apps.

------
rezashirazian
The iOS app looks like a treasure trove, I can't wait to download it and
dissect it. It'll be interesting to see how they integrated playgrounds into
their development cycle.

I just wish they had upgraded to Swift 3.0

------
john_gaucho
This is great. I hope they also provided good documentation / commenting. This
can be a fantastic learning tool for programmers at all stages.

Kudos to kickstarter.

------
alexashka
iOS Project does not build - Xcode 8.2... There is a guard statement with no
else clause, that's the first error I got. I didn't bother looking further
because... a guard without an else could never compile, so what am I looking
at?

I'm getting flashbacks from my last workplace where people merged in code that
didn't compile and then went 'oh really? let me fix that real quick'...

Code wouldn't compile in master but the codebase... everything had to be
clever. We can't just have a model, a network request to fetch/update for it,
a view controller and view cells. A few storyboards and of course no bloody
tests - it's a phone app.

No, we need protocols everywhere we can fit them, third party libraries - ones
that haven't been out a few years (Reactive whatever), a third party library
to make a basic GET request (Alamofire looking at you), a CSS styling library,
a JSON to Model library, list goes on.

What we don't need is folder structure that lets you know this is the initial
VC, the two folders beneath it are the 2 possible places you can go, the sub-
folders in there are the places you can go from that VC and on and on.

Let's just dump all VCs in one folder, all cells in another. Nevermind that in
90% of the cases, that one cell is only ever used in that one tableview - no
need to group those together.

I don't know - maybe it's just me - I'd rather I download a zip, open the
project, click that triangle and it runs - this thing makes me jump through
hoops, and it still doesn't work... And nothing makes sense, unless you go
learn reactive cocoa - based on the amount of files/code, a clear waste of
time.

~~~
perfmode
> Download the Xcode 7.3.1 release.

The app requires a different version.

[https://github.com/kickstarter/ios-
oss/blob/master/README.md](https://github.com/kickstarter/ios-
oss/blob/master/README.md)

I concede. There are issues getting the dev environment configured.

------
perfmode
What's the purpose of Android's ApplicationGraph interface?

[https://github.com/kickstarter/android-
oss/blob/888a37468358...](https://github.com/kickstarter/android-
oss/blob/888a3746835835016fc1a1bb32d8e2a90b8bffce/app/src/main/java/com/kickstarter/ApplicationGraph.java)

~~~
adhil
Looks like they're using Dagger2
([https://google.github.io/dagger/](https://google.github.io/dagger/)) for
dependency injection.

------
shmerl
Good! I try to avoid closed applications on my mobile devices if possible.

------
mwcampbell
I wonder if they've considered using something like React Native or Xamarin so
they can share some of that functional-style code between the two platforms.

------
afro88
This is a really great example of how to do it right when it comes to Swift,
MVVM, Reactive Cocoa, Testing, CI etc. Lovely code and architecture!

------
SimonSelg
This is awesome! Open source production apps are always useful.

------
EGreg
Does this mean we can clone it now or does the license prohibit that?

------
stirner
Open sourcing a client is pretty useless when the bulk of the logic happens
inside a company's server somewhere.

