Earlier than we start speaking about methods to construct high quality software program let’s first outline it. High quality software program is strong, maintainable, has minimal bugs, and gives a great UX.
Many of the commentary beneath are normal ideas that apply to software program growth; nonetheless, a few of it applies extra particularly to Android growth.
Placing a big preliminary deal with high quality massively pays dividends down the road. With improved code high quality, you possibly can improve developer throughput, improve capability, and reduce lead time which in flip offers you extra time to mirror/enhance your individual course of.
These are issues to bear in mind everytime you write code. These rules assist make your code maintainable which is extraordinarily worthwhile in the long term.
Having a “strong” understanding of all of the rules will show to be very worthwhile.
When engaged on a big function, take ample time wanted to suppose by way of methods to architect the function successfully. Take into consideration how all of the elements will talk.
Are there any current design patterns which have already solved the identical/comparable drawback? If this function wants to alter sooner or later, how can I construct it such that change is quick and straightforward? I.e., minimal ripple results when making change.
When constructing a medium-large function generally I’ll take round 4 hours to plan out the structure. If it’s a really giant function I could even take a whole day or extra simply to plan out a strong design.
The 2 most important methods to arrange code are package deal by layer and package deal by function. With package deal by layer, you basically place lessons within the architectural layer that they belong to. For instance, you may put all of your customized view lessons in a single package deal, all of your repository lessons in one other package deal, all of your mannequin lessons in one other package deal, and many others.
With package deal by function you place all of the lessons which might be required for a function in the identical package deal. This has so many advantages! Decrease complexity, larger class cohesion, decrease coupling between packages. Must replace a function or perhaps take away a function? Every thing you want is in a single place — no want to search around for all of the lessons that represent the function!
This additionally makes the challenge extra maintainable as a result of future builders may even have a neater time working with the function as a result of, once more, all the pieces is in a single place.
There are, after all, issues like normal utility lessons which may be higher suited exterior a function package deal.
For instance, if you happen to create a customized view for function A it’s usually finest if you happen to don’t reuse that customized view for function B even when it wants an analogous (or the identical) view.
Right here’s why. Let’s say you create a customized card view that’s utilized by a listing on 4 totally different screens (function A, B, C, and D). Immediately all the cardboard views on the 4 totally different screens present the identical info. What if the necessities change sooner or later for less than options A and B? What’s going to you do then? Often certainly one of two issues:
- Add some circumstances to the customized view and/or extra properties in order that it will possibly accommodate all necessities for all screens.
- Break off the function and create a brand new customized view with the modified necessities.
The primary selection is probably a nasty determination as a result of doing so will improve complexity of the customized view. In case you hold doing this, over time, you’ll find yourself with a monolithic class that’s tightly coupled to totally different options. Now if you wish to refactor that class it’s going to take a very long time due to the tight coupling to so many options and elevated complexity. You may break one thing in one of many options. Additionally, remember that with elevated complexity comes decreased developer throughput.
The second selection is the higher selection, though, it could not have been mandatory within the first place if you happen to would have created separate views for every function.
There’s one caveat. If there’s a very small customized view that I’m extremely sure is not going to change, I could put it in a standard view package deal and use it throughout options. This could be one thing like a small, customized person picture view that’s used inside every card view. In distinction, the cardboard view could include every kind of data which makes it extra prone to be modified.
Take the time upfront to suppose by way of all edge instances as you’re employed by way of options. It is best to have an understanding of what can go unsuitable with every a part of the code that you simply work on.
For instance, are API errors correctly dealt with? What occurs if a person is on their cellphone they usually lose community connectivity? What if a person kills the app in the course of a long-running operation after which resumes later? What if a person faucets a button that makes an API request actually quick and repeatedly?
In case you can not deal with the sting instances instantly then you’ll want to hold monitor of them in some way. For instance, you possibly can go away a TODO remark. Make sure to deal with the sting case earlier than you take into account the function full although!
Android Studio/IntelliJ IDEA has a pleasant function the place you possibly can see all TODO feedback inside a package deal. See this SO post for methods to view TODO feedback in Android Studio.
Live Templates are a function in Android Studio/IntelliJ IDEA that lets you shortly insert boilerplate code. That is an extremely highly effective function that may improve your productiveness (in addition to cut back copy/paste bugs).
For instance, you need to use this when performing repetitive duties like creating customized views, establishing view binding, writing unit assessments, and many others. Stay templates are customizable utilizing variables.
See this post for many particulars.
Usually, builders work on tickets created by product managers. The ticket would have the main points for a given function that you simply’re engaged on (together with the acceptance standards).
When engaged on these function tickets it’s finest to make clear something that’s not clear throughout the ticket. Don’t assume. You’ll save time by doing this. The very last thing we wish to do is make the unsuitable assumption after which have to redo one thing that might have been clarified earlier.
At my present group, we’ve all written communication for a selected function taking place in a selected subject channel inside Slack. The related individuals for that function can be a part of the Slack channel (backend engineers, frontend engineers, product managers, and many others).
To remain organized, what I usually do is put up all questions I’ve a few specific ticket as a separate remark. Every query can then be answered in a thread for that specific query. I exploit Slack emoji responses to point whether or not the query has been answered or not. If there are any remaining unresolved questions I exploit❓to point this. If the query has been absolutely answered then I exploit ✅ to point that standing.
Irrespective of how essential the function is, it’s essential to take one step at a time and suppose all the pieces by way of. Even if you happen to’re “behind” don’t let it get to you. In case you’re attempting to run as quick as you possibly can, chances are high you’ll go away some bugs behind or miss an edge case that might have been prevented.
Despite the fact that you’re “going quick” it’ll take extra general time to come back again to repair the problems and the corners you narrow. Remaining calm and taking the time that you simply want will save time in the long term. It’s cheaper to do issues appropriately the primary time relatively than fixing it 5 occasions after some bugs are found.
In case you’re feeling pressured, take a break or go for a stroll.
Even when there’s a important bug in manufacturing you continue to have to take one step at a time and perceive what is occurring earlier than you possibly can deal with the issue. If it’ll take you too lengthy to repair the difficulty then you possibly can roll again to the earlier model when you work on a repair.
Say you wish to shortly begin a brand new exercise you’re engaged on to check it out or perhaps you wish to simulate some sort of non permanent situation in code.
Irrespective of how small the quantity of code is that you simply wish to write, if it’s not meant to stay within the code then it ought to be remoted to its personal technique. In any other case, it would mix in with different code and also you may neglect about it! No less than with an remoted technique will probably be simpler to establish.
The combination factors are one instance of a possible blocker. Suppose you’re engaged on a brand new consumer facet function that requires API integration. Assume that it’s going to take someday to finish the API and 5 days to finish the consumer facet work. It’s a good suggestion to check the API very early on within the course of (like as quickly because it’s prepared) even when you have not completed constructing the UI.
In case you wait to check the API till you’re fully performed constructing the function or, worse, don’t take a look at it in any respect and easily throw a construct over the fence to QA, you might be risking extending the lead time of the function. By staying in shut communication with the backend staff and serving to to check out the API earlier than you end constructing the function, you’re serving to to cut back the general lead time.
While you’re performed constructing the function you need to attempt to break it. Do a few of your individual handbook developer testing to be sure to didn’t miss any edge instances and issues work as you’d count on. This may assist shorten the suggestions loop.
Think about for a minute that we fully skip doing our personal developer assessments and easily throw the construct over the fence to QA. Then QA finds one bug after which sends it again so that you can repair. In the meantime, you may have already switched context to a different ticket. Then you definately return and repair the bug present in QA. Think about this occurs for yet another spherical between QA and also you.
Are you able to see how this sort of factor may simply lengthen the event time for a ticket by a number of days (context switching + spending extra time on the identical ticket)? Though doing a little handbook developer testing earlier than passing a construct over to QA could appear tedious, it’ll prevent time in the long term.
Ideally, each function that you simply construct ought to have unit assessments. If the code will not be testable then it must be improved in order that it’s testable.
Even higher in case your unit assessments run on each decide to your develop/grasp branches by way of steady integration.
Commonplace code evaluations are one other nice option to catch errors and potential enhancements. A radical code overview is way more worthwhile than merely clicking the approve button.
Maintaining a detailed eye on crash experiences proper after a launch can show to be useful. It’s an amazing feeling when you possibly can establish and repair errors earlier than they get too giant.
Tagging the commits that you simply launch will make your life simple if/when it’s worthwhile to roll again to a earlier model. I exploit tags like
launch/1.2.3–456 that point out the discharge quantity.
When it’s worthwhile to roll again you possibly can then simply take a look at the tagged commit, bump the model, and launch the construct. This technique works even when your challenge makes use of submodules.