Office Hours — Today, July 6

Thursday, July 1

Mark M.
has entered the room
Mark M.
turned on guest access
Jul 6
8:00 PM
Bonnie
has entered the room
Bonnie
Hi :)
Mark M.
howdy, Bonnie!
Bonnie
How are you doing?
Mark M.
under the weather
otherwise, OK -- and you?
Bonnie
Oh, that's too bad
I'm ok
I'm going to upload a screenshot because I have a question.
Mark M.
you're wondering why the EditTexts get short
right?
Bonnie
I copied the XML layout file word for word.
Yeah
Mark M.
bug in Android
Bonnie
Oh, ok
Mark M.
I have an outstanding issue on it in b.android.com
Bonnie
Ok I just had to make sure
Mark M.
I don't remember seeing it in 2.2, so perhaps it is fixed now
Bonnie
Ok
Also, near the end of the layout file, I wonder if there is a typo.
I see this: android:layout_above="@id/details"
And there is no + after the @
Is that a typo or does it mean something different?
Mark M.
because @+id/details appears earlier in the file, IIRC
8:05 PM
Bonnie
Usually it's @+id
8:05 PM
Mark M.
you only need the + if it is the first time you use the ID
Bonnie
Ok
I see. Thanks :)
Mark M.
second and subsequent times, you can drop it
Bonnie
Ok
Mark M.
any other questions?
Bonnie
One more thing
I'm on page 41 of the Busy Coder's book
It describes a new and easier way of linking OnClick to a button
instead of using the anonymous inner class
Mark M.
android:onClick="..."
Bonnie
Yeah
I was wondering if you had a full code sample for the entire application for that.
I have two code fragments, but I'm a beginner.
Mark M.
not in that book
Bonnie
It helps if I get the whole thing.
Mark M.
however...
That is a short example from my Advanced Android book that uses this technique
8:10 PM
Mark M.
Just kinda ignore everything else in the sample :-)
Bonnie
Ok, perfect
Ok :)
I looked at the main.xml file and can't find the android:onClick="..." part. Is it in another file?
Mark M.
hold on
8:15 PM
Mark M.
whoops, sorry, wrong example
Bonnie
ok
Mark M.
Bonnie
Thanks, I see it now
Back to my first question. Everytime there is a bug in Android, how do you work around it, or are you just forced to avoid using that layout until a new version is released?
for bugs in general, I mean
Mark M.
that's impossible to answer in the abstract
Bonnie
Yeah, I guess it is pretty broad
Mark M.
in the case of having a TableLayout and ListView as siblings in the same parent, you'd just have to come up with a different UI
Bonnie
ok
Mark M.
for example, this problem goes away in a tutorial or two, when you split those into separate tabs
Bonnie
I see
Jere_Jones
has entered the room
Mark M.
howdy, Jere_Jones!
Jere_Jones
Howdy!
Bonnie
Hi :)
8:20 PM
Jere_Jones
Friendly room today! :) Hi Bonnie!
Mark M.
what can I do for you this evening?
Jere_Jones
My original intent was to lurk but I'm glad to grill you if no one else is.
Bonnie
I'm done with asking my questions for now
Mark M.
small crowd on the day after a holiday, I suppose
hence, grill away
though if you break out a bottle of A-1 Steak Sauce, I'm outta here
:-)
Jere_Jones
Cool. What kind of thoughts do you have on testing? Particularly unit tests and activity simulations.
Mark M.
On Android, it drives me up a wall
Jere_Jones
My specific problem area is how to test without having to constantly reset the db.
Mark M.
uh, well, JUnit-style testing tends to want you to start from a clean slate on each test method
Jere_Jones
Extracting that dependency is what I would do in C#. In Java/Android, eh, I'm less organized I guess.
Mark M.
I think there are ways around that, though I'm fuzzy on the details
Personally, I'd try to test as much as possible outside of Anroid
er, Android
whatever business logic you can keep in a separate JAR and test however you want, the better
that doesn't tend to work out too often in practice, though
Jere_Jones
I have noticed that testing on the emulator is dog slow.
Mark M.
it helps if you choose the right test case class
depending on what you're testing
8:25 PM
Jere_Jones
I'm using AndroidTestCase for behind the scenes stuff and AndroidInstrumentationTestCase2 for ui interaction testing
Mark M.
yup, that's about the right answer
if any "behind the scenes stuff" doesn't interact with Android much, you may be able to just use TestCase
Jere_Jones
It is the ui stuff that is just SLOW. 5-10 seconds per test.
Mark M.
yup
did I mention that testing on Android drives me up a wall?
Jere_Jones
I don't have any pure calculation testing to do. So I'm either dealing with the database or the ui. Ugh.
Robotium is really helpful for ui testing, but still slow.
Gotta test though. Irritating or not. I hate regression bugs.
Mark M.
haven't had a chance to play with Robotium yet
Jere_Jones
Oh! Concrete question!
Mark M.
but if they have Cucumber integration the way their home page says, I gotta give it a shot
Jere_Jones
I have an AVD that was specified to mimic my EVO. But sometimes it shows up as HDPI and sometimes as MDPI. I don't get why it would change? Any idea?
Mark M.
what do you mean by "shows up as HDPI"?
and concrete "is a construction material composed of cement (commonly Portland cement) and other cementitious materials such as fly ash and slag cement, aggregate (generally a coarse aggregate made of gravels or crushed rocks such as limestone, or granite, plus a fine aggregate such as sand), water, and chemical admixtures"
Jere_Jones
It's like sometimes it thinks it is 480x800. Other times it thinks it is 320x480.
Mark M.
:-)
Jere_Jones
Concrete vs Abstract. :)
Mark M.
that behavior is really strange
that's in an AVD config file
it should not fluctuate
8:30 PM
Jere_Jones
That's what I thought. I get the same behavior whether Eclipse kicks off the emulator or IntelliJ IDEA.
Mark M.
you might post that one to [android-developers] -- Xav Ducrohet is responding to a reasonable number of tools questions
Jere_Jones
Ok.
Bonnie
Question - where do you learn about testing as a beginner? I haven't gotten there yet. I'm self-teaching myself without a Comp Sci. degree.
Jere_Jones
Philosophy? Technique? Syntax?
Mark M.
lots of books, both language-specific and general
Bonnie
Technique to start, I suppose
Ok
Mark M.
for Android, a book on JUnit would be a likely starting point
Bonnie
Yeah, JUnit sounds familiar.
The other stuff you two discussed was Greek to me.
Mark M.
unfortunately, this is one of those things where Java's book peak was several years ago
8:35 PM
Mark M.
JUnit Recipes: Practical Methods for Programmer Testing and Pragmatic Unit Testing in Java with JUnit are solid choices based on Amazon reviews
Jere_Jones
There are (that I know of) three primary techniques to testing. AAA, Record and Replay, and Behavior. I'm a big AAA (Arrange, Act, Assert) guy myself. Just makes more sense. And JUnit is set up just for that. Cucumber, which Mark mentioned earlier, is a Behavior type. I don't know of anything that is Record and Replay in Java.
Mark M.
but they were for 2004, so there will be some places where they are out of date with respect to where JUnit progressed
Bonnie
Ok
I'll make a note of that, thanks
Mark M.
you can find some record-and-replay tools for Swing, but it would take firmware mods to do it in Android
Jere_Jones
It is probably still good. JUnit has a fairly stable syntax.
I think AAA is the easiest to get started with. Would you think so Mark?
Mark M.
when I learned software testing, we were doing it with flint axes
hence, AAA and Behavior are a wee bit newer than I tend to think :-)
Jere_Jones
I started as a C++ programmer where unit tests are fancy dancy things that managed programmers do. :)
Mark M.
a well-done Behavior framework can simplify things greatly...but an incomplete one would be frustrating as all get out
AAA is probably the most straight-forward approach
and it's what Android is set up to do
if it weren't for that teensy performance issue
Jere_Jones
You would probably have the performance issue regardless of technique, wouldn't you?
8:40 PM
Mark M.
it certainly won't be fast
but JUnit wants to flush everything and rebuild it all on each test method
that's what makes the UI testing so slow
so, take the Test Monkey -- it is fairly snappy, but it is effectively write-only
(other than exceptions the random input raises)
Jere_Jones
Bonnie, my favorite beginner testing book has been the Art of Unit Testing. The examples are in C# but the syntax is very close to Java and the ideas are language agnostic.
Bonnie
Ok
Jere_Jones
I still haven't tried Monkey.
Mark M.
it's really easy to run
and always good for a laugh
Bonnie
Just curious, do you both have degrees or are self-taught?
Mark M.
I have degrees, but not in computer science
Jere_Jones
I'm self taught.
Bonnie
Ok :)
Awesome
How long did it take until you felt confident?
Mark M.
confident in what?
Bonnie
I took one C++ course at a community college after doing a degree in something else and I'm learning the rest on my own.
In general, as a programmer.
Mark M.
:: shrug ::
Bonnie
on par with someone with a degree.
Jere_Jones
My favorite quote: "Computer Science is as much about programming as Astronomy is about telescopes"
Mark M.
I learned programming by writing BASIC code on pieces of paper, bringing it to my local Radio Shack, and entering it on a TRS-80 Model I they had on display
Bonnie
Haha :)
Jere_Jones
Don't feel inferior to those with degrees.
Bonnie
Ok
Mark M.
yeah, seriously
Bonnie
That's good to know
8:45 PM
Mark M.
there are tons of self-taught developers
Jere_Jones
Very few of the best programmers I know have CS degrees. They are more likely to have liberal arts degrees.
Mark M.
particularly on newer technologies
Jere_Jones
Or no degrees.
Bonnie
Ok. I guess the job ads are misleading.
They always seem to require degrees, but the ads are probably written by non-programmers.
Mark M.
ah, well, hiring managers will ask for the sun, moon, and stars
then, it's a question of how urgent the need is
Jere_Jones
They will (sometimes) also say "or equivalent experience"
Mark M.
nowadays, I'd focus on building up a portfolio demonstrating your ability -- blog posts, open source apps, contributions to open source projects, etc.
Jere_Jones
In my experience it doesn't take much experience to be equivalent to a CS Bachelors unless the job is math/algorithm heavy.
Bonnie
True, I see that a lot too
Ah, no wonder. I look at game industry postings a lot.
Mark M.
whether you got that ability from a CS degree, a bunch of books, or a Vulcan mind-meld won't matter if they can see the ability
Bonnie
Haha ok :)
Jere_Jones
Right!
Mark M.
game industry used to be a bit more difficult to get into, but I haven't paid much attention in the past, oh, 15 years or so... :-)
Bonnie
I decided to become an indie game developer for Android
Jere_Jones
IMHO, the best way to improve as a programmer is to program. Read lots of code. Write lots of code.
Bonnie
Yeah
Mark's tutorial book is helping a lot. My other Android books have lots of prose but only a few lines of code here and there.
8:50 PM
Mark M.
yeah, that's why I'm big on fully-runnable sample projects
and lots of small ones, outside of the Tutorials
Bonnie
It's a fantastic way to learn
Jere_Jones
Mark, relatively simple question: What is the difference between a Service and an IntentService other than the self included thread in an IntentService?
Mark M.
IntentService will automatically call stopSelf() if, after onHandleIntent() completes work on the background thread, there is no more work to be done (i.e., no startService() calls in the meantime)
so, IntentService is a great "fire and forget" way of doing something in the background and not worrying about it taking up memory for an extended period
other than that, it's a pretty thin class
Jere_Jones
Is there a way to look at the "queue" for IntentService?
Mark M.
it doesn't even know how to keep the phone awake, which is why I've been steadily refining my WakefulIntentService
Jere_Jones
Which I love!
Mark M.
there are no public methods to examine the queue
rephrase that -- there are no SDK methods to examine the queue
8:55 PM
Jere_Jones
I'm thinking along the lines of a download queue.
At the end of downloading one thing, it would call startService for the next download. But I wouldn't want to do that if the download was already in the "queue"
Mark M.
the problem is that IntentService has a single thread, not a thread pool like AsyncTask
oh, you'd need to track that yourself
Jere_Jones
AsyncTask vs IntentService? Both are "fire and forget". When to use one or the other?
Mark M.
just override onStart() or onStartCommand(), keep tabs on the pending downloads, and chain to the superclass
I don't know that you can answer that question in the abstract
Jere_Jones
"chain to the superclass"? super.whatever()?
Mark M.
super.onStart() or super.onStartCommand(), whichever you overrode
that way, the normal IntentService logic continues
but, you got notified of the item being added to the queue, so you can track it
Jere_Jones
Well, lets see. AsyncTask gives you an easy way to get back on the ui thread. But you could do that in IntentService with runOnUiThread, right?
Mark M.
runOnUiThread() is a method on Activity
Jere_Jones
I'm thinking about asynctask vs intentservice
Mark M.
AsyncTask onPostExecute(), in theory, is on the main application thread
however, you have to create it on the main application thread, so you would use that in a regular Service, not in onHandleIntent() of an IntentService
Jere_Jones
Yeah, because there may not be an activity around while IntentService is running, right? Of course the same could be said about an asynctask.
9:00 PM
Jere_Jones
Well, I've got 9pm here. I appreciate the time you share Mark! Your books are great and I'm looking very forward to the NDK book.
Bonnie
Thanks, Mark :)
And you too, Jere, for your input
Mark M.
gadzooks! the time flies when you're looking forward to getting doped up on NyQuil!
I hates colds
Bonnie
Hahaha
Jere_Jones
Get better. Coding with a cold sucks.
Mark M.
thanks!
have a pleasant evening, all!
Bonnie
has left the room
Jere_Jones
has left the room
Mark M.
turned off guest access

Thursday, July 1

 

Office Hours

People in this transcript

  • Bonnie
  • Jere_Jones
  • Mark Murphy

Files in this transcript