About Me ● Wrote 1st mobile app in grad school at UPenn (2010) ● Hewlett-Packard (2010 - 2011) ○ Android WebOS & Computer Vision Engineer - Small codebase (R&D) ● Edmodo (2011 - 2013) ○ Android & iOS Development - Large codebase (Production > 1M users) ● Independent contractor (2014) ○ Android Development - Many small codebases (Production 100 - 100,000+ users) ● Operator (2015) ○ Android, iOS, Python, and Javascript - Large codebase (Beta 1000+ users)
● Have design/architecture discussions early and talk to your team ● Easy to find flaws early, hard and time-consuming to fix later ● Critique thoroughly ● “Pseudocode-Driven Development” ● Hammock-Driven Development ○ Talk given by Rich Hickey, creator or Clojure (on YouTube). Design Early
Don’t Over Optimize ● Optimizing code takes a lot of time ● Optimize for performance later ● ...but optimize for readability and understandability early
● e.g. a base class for displaying a list of groups public abstract class GroupsListFragment { // TODO: Currently both MyGroupsListFragment and JoinedGroupsListFragment are // making the same request and then filtering the results. We could optimize by // having those classes implement this method to return only the groups they care // about if the server API supported it. @Override protected NetworkRequest createRequest(NetworkCallback> callback) { return (new GroupsRequest(callback)); } } Don’t Over Optimize
DRY ● Duplication requires more lines of code ● Duplication is error prone ● Solve duplication through abstraction ○ Create a method or a class ● Example: https://gist.github.com/arriolac/b8fb810dd152848ff11d
Think Small ● Write small files, methods, and classes ● Smaller components are easier to test, swap, and change ● Smaller files usually means good encapsulation
Think Small (e.g.) function getScaledBitmapThatFitsWithinBoundsAndHasQualityAndDoFixRotation(sourceFilePath, boundsWidth, boundsHeight, fixRotation) { // Do stuff… return image; }
Recommended Reading ● “The Pragmatic Programmer” by Andy Hunt and Dave Thomas ● “Design Patterns—Elements of Reusable Object-Oriented Software” by Erich Gamma, Richard Helm. Ralph Johnson and John Vlissides ● “Refactoring” by Martin Fowler