Dec 19 | 3:55 PM |
Mark M. | has entered the room |
Mark M. | turned on guest access |
Kai H. | has entered the room |
Mark M. |
hello, Kai!
|
Mark M. |
how can I help you today?
|
Kai H. |
Hello Mark
|
Kai H. |
How are you?
|
Mark M. |
OK, and you?
|
Kai H. |
Ok ;-)
|
Kai H. |
Do you have a best practic for increasion versionCode automatically, eg. when using CI?
|
Mark M. |
I have not done that too much
|
Mark M. |
when I did, I had some Gradle code that uses a properties file to hold the version code
|
Mark M. |
that code would increment the value, update the properties file, and use that value in the build configuration
|
Kai H. |
I have read about that.
|
Mark M. |
and I doubt that will work in a CI environment
|
Kai H. |
And when would you upgrade? On commit? On push? On creating a tag?
|
Kai H. |
Yes, probably not.
|
Mark M. |
ah, I interpreted "automatically" as meaning "on every build", under the premise that you're not going to do 2 billion buids
|
Mark M. |
er, buildws
|
Mark M. |
er, builds
|
Mark M. |
(yeesh, can't type today...)
|
Dec 19 | 4:00 PM |
Kai H. |
What qualifies as a "build"?
|
Mark M. |
clicking "Run" in the IDE, or running the equivalent Gradle tasks
|
Mark M. |
I'm sure that there are patterns out there for deriving a version code from other values like git tags, or for using those as signals for an "increment the version code" -- personally, I have never done that
|
Mark M. |
and those sorts of build solutions are the sorts of things that I do not research much before I need them
|
Kai H. |
"On every build" would be waaay to often then.
|
Mark M. |
well, you are unlikely to run out of integers :-)
|
Kai H. |
That is true too. It still feels strange though.
|
Mark M. |
some places use a timestamp, as that too results in monotonically-increasing integers
|
Mark M. |
and you're unlikely to have two builds within a second of each other
|
Dec 19 | 4:05 PM |
Mark M. |
but, again, this is not something I have spent time on
|
Kai H. |
Ok
|
Kai H. |
In hour app we sometimes update Accounts by removing and adding them again. I was wondering if there could be any bad side effects or if Accounts in Android are pretty much only key value stores.
|
Mark M. |
"Accounts" as in AccountManager and the Accounts portion of the Settings app?
|
Kai H. |
Yes, as in AccountManager
|
Mark M. |
that too I have never used
|
Mark M. |
I read the documentation when it came out, cringed, and never bothered with it afterwards
|
Kai H. |
Why did you cringe? What did you use instead?
|
Mark M. |
what pretty much every other developer does: anything but AccountManager
|
Mark M. |
seriously, I think I have installed about 2-3 apps, ever, that have used it, at least in any user-visible fashion
|
Kai H. |
That's interesting, as you usually go for the standard way in Android.
|
Mark M. |
ummm... that's actually an interesting statement, as you'll find others who think that I "rock the boat" too much
|
Dec 19 | 4:10 PM |
Mark M. |
but the approach that every one of my customers has been to handle credentials themselves
|
Kai H. |
That's what I got from the chats we have. That you recommend going for the standard way first.
|
Mark M. |
it varies
|
Kai H. |
Ok, interesting. Could you outline the negatives of AccountManager?
|
Mark M. |
not off the top of my head -- this is probably the first I have thought about it in 3 years or so
|
Mark M. |
I rarely see it come up in developer discussions
|
Kai H. |
I only ask because I had to play around with it or rather around it.
|
Kai H. |
But it's interesting to know it so little used.
|
Dec 19 | 4:15 PM |
Kai H. |
Let's say you have to change accounts from different points in your app (could be loaded via a file on the device, could be loaded by MDM + RestrictionManager, could be input manually in a settings screen), what
|
Kai H. |
would your architecture around that look like?
|
Mark M. |
I have never worked with RestrictionsManager -- this is probably the first that I have heard of it since Android 5.0 shipped
|
Mark M. |
bear in mind that I'm not an enterprise app developer
|
Mark M. |
and so things like MDM are waaaaaaaaaaaaaaay outside my area of expertise
|
Kai H. |
The question should be more an architectural one.
|
Mark M. |
except that I haven't the foggiest notion of how MDM affects app development
|
Kai H. |
Right now we call some methods in various places and often the logic is in the place that the accounts get added or removed, which makes it rather hard to reason about how the app reacts and what happens when.
|
Mark M. |
yeah, the most complex I have ever had to deal with is "how to we clean things up when the user logs out?"
|
Kai H. |
So I was close to refactoring to an "Accounts" repository that would encapsulate all the logic and just expose a few distinct methods.
|
Dec 19 | 4:20 PM |
Mark M. |
off the cuff, that doesn't sound bad, but I cannot tell you how well it fits your needs
|
Kai H. |
With our app you can add several accounts at once, with rules like "set an account active if it was just added and there was not account prior", "don't set an account active if another account is already active" and so on.
|
Mark M. |
in my case, that sort of thing has always been handled by a server, or else there were no explicit accounts
|
Kai H. |
Maybe your remember me asking about how an Activity can be started from another Activity, this was actually the use case behind it.
|
Kai H. |
There is an activity that gets started when an account gets added from a file, and after being done with this the App should be shown as if it was started from the launcerh.
|
Kai H. |
In our case the accounts are used to connect to a server, so they need to be on the device.
|
Mark M. |
OK, I have skimmed our 15 December chat where you were discussing some of this
|
Dec 19 | 4:25 PM |
Mark M. |
that being said, I am not certain how I can help you
|
Kai H. |
I was hoping you'd have an architecture recommendation.
|
Kai H. |
For that use case.
|
Kai H. |
But it might be hard to tell from that far away.
|
Mark M. |
yeah, I don't know how you can decouple this from the rest of your app concerns
|
Mark M. |
at least, in terms of the level of advice that I could give
|
Mark M. |
so, other than "use dependency inversion to help with cleaning up singletons that might have per-account info", I am uncertain what to advise
|
Kai H. |
I have no idea how I would introduce DI in our app. That is a thing for another day.
|
Kai H. |
I just recently tried writing tests and was quite pleased with that.
|
Kai H. |
But found out that we do a lot of stuff in Activities and that is kinda hard to test.
|
Mark M. |
in the end, a lot of the modern Android architecture stuff has centered around trying to get code out of activities and fragments and into more-testable things
|
Mark M. |
because UI testing is... unpleasant
|
Kai H. |
And a lot of the time kinda unneeded, I guess.
|
Kai H. |
So if I REALLY wanted to test it, I'd probably refactor the code in question out of the Activity. Thought as much.
|
Dec 19 | 4:30 PM |
Kai H. |
Do you test Activity, as part of integration tests or something similar?
|
Mark M. |
that would depend on the customer -- and, in practice, that means "not much"
|
Kai H. |
Btw, you said you aren't doing enterprise development. Who do you then develop for?
|
Mark M. |
my past clients have all been delivering consumer apps
|
Kai H. |
Ofc.
|
Kai H. |
I was like "what is there besides app by enterprises", but of course there is b2b and b2c.
|
Dec 19 | 4:35 PM |
Kai H. |
That's all I have for today I guess :D
|
Mark M. |
OK, I am sorry that I was not of much use this time
|
Kai H. |
I guess those were kinda details questions anyway.
|
Kai H. |
And no unsovled problems, just things I wondered.
|
Mark M. |
mostly, you just hit a bunch of topics for which I have limited experience
|
Dec 19 | 4:40 PM |
Kai H. |
Thanks for your continuing book releases btw, I plan to go through "Exploring Android" soon, to continue my hobby app in Kotlin instead of Java.
|
Mark M. |
sounds good!
|
Mark M. |
let me know if you run into any problems with it that I can fix!
|
Kai H. |
And I have gone through your Kotlin book(s) and have used the other books as references, to look up different topics
|
Kai H. |
As you might have noticed I am not shy on that front ;-)
|
Dec 19 | 4:45 PM |
Kai H. |
Did you convert an App from Java to Kotlin somewhat recently?
|
Mark M. |
in 2018-2019 I helped two firms that were part-way through that conversion
|
Kai H. |
I was wondering how much of an architectural change might come with that.
|
Mark M. |
by default, zero
|
Mark M. |
I mean, Kotlin does not impose any architectural requirements
|
Mark M. |
nor does it require you to change the API of your classes
|
Kai H. |
Well, yes, you can do "convert Java to Kotlin" on a file, but afterwards you'd probably look at it and go "well, this can be done much nicer in Kotlin".
|
Mark M. |
yes, though a lot of that is below the level of what I would consider "architecture"
|
Kai H. |
Well, sure.
|
Mark M. |
the automatic conversion usually results in a faithful conversion, but the resulting Kotlin can use cleanup at minimum
|
Mark M. |
and there are a lot of tweaks that you can make beyond that
|
Kai H. |
I've made that experience, hence the question.
|
Kai H. |
And then there is AsyncTask vs Coroutines, Lazy Properties and so on and so forth.
|
Mark M. |
there may be cases where Kotlin makes you more inclined to *also* adopt other things that trigger architectural changes (e.g., DI)
|
Mark M. |
AsyncTask is another good example: there is nothing stopping you from having AsyncTasks written in Kotlin
|
Mark M. |
you might choose to move to something else
|
Dec 19 | 4:50 PM |
Kai H. |
I guess once we start using Kotlin, a lot of code that would have become AsyncTask with Java will instead become Coroutines.
|
Mark M. |
personally, I'd look at that as a multi-step code overhaul
|
Kai H. |
I don't like AsyncTask too much tbh. It's a lot of confusing jumping around in our code.
|
Mark M. |
IOW, until you're pretty comfortable with Kotlin, do not go in and simultaneously change language *and* change significant bits of the implementation
|
Kai H. |
Ok
|
Mark M. |
AsyncTask had its day and its uses, mostly for earlier, simpler apps
|
Kai H. |
Or for kinda big Apps like ours X) Where there are like 50 of them in total.
|
Kai H. |
And 5 level deep inheritance structures and whatnot.
|
Kai H. |
And lots of static nested classes to execute them.
|
Dec 19 | 4:55 PM |
Kai H. |
So go Kotlin first and then change architecture, or the other way around?
|
Mark M. |
that's a business decision, by and large
|
Mark M. |
to the extent that "change architecture" involves writing lots of new classes, though, write them in Kotlin
|
Mark M. |
the projects that I helped did not do a "OK, we're moving everything from Java to Kotlin" phase
|
Mark M. |
instead, new stuff was written in Kotlin, and developers were encouraged to convert Java to Kotlin as part of other minor cleanup work
|
Kai H. |
Sounds very reasonable.
|
Mark M. |
with an objective of eventually getting rid of all the Java, but only as part of ordinary work
|
Kai H. |
That would mean a lot of refactoring in the company, right?
|
Kai H. |
Otherwise there will always be some Java code left.
|
Mark M. |
sorry, I am not certain what you mean by that
|
Mark M. |
oh, I see
|
Kai H. |
If you don't look at your code regularly
|
Mark M. |
well, there was a steady stream of other work, such as beefing up test suites, that helped
|
Mark M. |
eventually, there would need to be some final "get rid of the lingering Java" task
|
Kai H. |
I see
|
Kai H. |
That feels so... unlikely for our App.
|
Kai H. |
Hard to imagine.
|
Mark M. |
OTOH, if the Java code is working, there is no huge rush to convert it to Kotlin
|
Mark M. |
it's not like users will be able to tell the difference
|
Dec 19 | 5:00 PM |
Kai H. |
Well, I'd like to one day not want to rip my eyes out when having to add a feature or find a bug ;-)
|
Mark M. |
Kotlin neither causes nor prevents blindness
|
Mark M. |
:-)
|
Kai H. |
I mean Java.
|
Kai H. |
In our App
|
Mark M. |
my point is that you are likely to want to rip your eyes out over some Kotlin sometime too
|
Kai H. |
Oh, sure. Yes
|
Kai H. |
That is not Java as such, more of an architecture thing
|
Mark M. |
ah
|
Kai H. |
Combined with no comments and no tests.
|
Kai H. |
And variable names like "d", "fnct" and so on
|
Mark M. |
that's OK -- in Kotlin, they will all be "it" :-)
|
Kai H. |
aaaaaaaaaaaaaahhhhhhhhhhhh
|
Mark M. |
and, with that, I'll wrap up today's chat
|
Kai H. |
X)
|
Kai H. |
8)
|
Kai H. |
Have a good time
|
Mark M. |
next one is *tomorrow*, same time, 4pm US Eastern
|
Kai H. |
And stay healthy
|
Mark M. |
you too!
|
Kai H. | has left the room |
Mark M. | turned off guest access |