Random Musings of a Coffee Technologist

Month

October 2011

49 posts

Android App Progress 2011-10-31

I’ve been sick lately which interferes with the motivation to do much of anything, so while progress has been slow I have been plugging along little by little. Today I finished writing and debugging yet another activity with about a half dozen left to go. If I ever modify this to work on smaller form factor devices there will be even more activities as many of these consist of multiple fragments (the one I was working on today used three fragments). I worry that I’m perhaps making things a little bit too complex with all of these different activities, but I think that as long as the functionality is exposed in an obvious fashion everything should be fine. I might put some feelers out to see if anybody else using Typica has an Android 3+ tablet and runs the sort of business that this app would be useful in and see if I can get some feedback once 1.0 is finished.

Things learned:

1. The example code that I’ve seen on the use of the Spinner widget all use an ArrayAdapter<CharSequence> created through a call to ArrayAdapter.createFromResource(). This works fine when dealing with a pre-determined set of values, but doesn’t work so well if the values are coming from a database query. Calls to add() throw an UnsupportedOperationException. The solution is to create the object with one of the many available constructors instead. For example:

new ArrayAdapter<CharSequence>(context,
     android.R.layout.simple_spinner_dropdown_item,
     new ArrayList<CharSequence>())

This results in the adapter using a proper list type (which supports add and remove operations) internally which is apparently not the case when using createFromResource().

2. Code analysis in Eclipse doesn’t always provide the most helpful message for diagnosing errors. Today I had an inner class object (a listener) where the bulk of the required functionality was needed in another function as well, so I took the stuff common to both and wrote that in a private (outer) class method. The inner class method would call out to that, but the message I got seemed to indicate that I couldn’t do that. I, still not completely fluent in Java, thought, “really? I thought I could do that,” quick Googling to find that indeed I should be able to do that. The true problem, which the error message provided no hint to, was that I had just left off the return type specifier for the function I was trying to call. Oops. Simple mistake to fix, I didn’t spend that much time figuring out where my error was, and I didn’t resort to just having the same code in there twice.

Oct 31, 201121 notes
#programming #Java #Android #error
Oct 31, 20112,152 notes
“Java is C++ without the guns, knives or clubs.” —

James Gosling.

(but guns, knives, and clubs [or instances of classes derived from these] are all very useful tools in certain circumstances)

Oct 28, 201110 notes
#Java #C++ #programming #quote #James Gosling
Oct 26, 201117 notes
#coffee #zombie
Language Fluency

A while back I posted a photo of some programming books I had purchased with the intent of gaining a better understanding of Java. Knowing that some of you reading this had already gone down that path I asked for some feedback in the hopes that if there was one key book that would better serve me it would be mentioned. Several answers came in, mostly encouraging, but with no recommendations for further reading. One answer, however, I don’t understand at all.

I think you bought too many books. Learn the syntax and coding schemes then head over to Oracle’s Java API online

The reason I find this advice so strange is simply that it describes precisely where I was before getting any of the books. There’s some merit to this approach. I learned the basics of Java when the language was still new and the bits that were new or poorly remembered were easy enough to grasp reading code others had written. Syntax was not my problem. Indeed, I had made considerable progress on a small but not completely trivial application learning what I needed as I went using as my primary sources the API documentation and the debugger. I have no doubt that I could have finished writing the program in such a way. I also have no doubt that the program would be more difficult to maintain and extend than it needs to be, that it would have more bugs hidden in it, that the code would have lacked clarity at some points, and that it would likely have other flaws as well. I know from experience with related projects that I’ll be living with this code for a long time.

The problem I had wasn’t so much that I didn’t know the language but that I lacked fluency in the language. Imagine, if you will, a small child who has lived long enough that they’ve assimilated the basics of English. She might not always know the best words to use, but can generally express herself and while she doesn’t fully grasp every nuance of what others say, some basic comprehension is there. She’s learned how to form letters on a page and understands how to use a dictionary. Now have her sit down with a stack of lined paper, a pencil, and a dictionary and have her write a story. If she has an interest in it, she will certainly succeed in writing something. You might have to spend some effort deciphering the intent behind the rough lettering, creative spellings, and unusual choices of punctuation and capitalization. The story isn’t going to win any literary awards. Indeed, an evaluation of the work performed without knowing anything about the author would likely conclude that the story sucks in nearly every way one can, but the story will still have been written.

This is how I saw myself with Java. Perhaps a bit better off simply because I’ve been programming in and reading programs written in other languages for a long time, but I had the nagging suspicion that someone fluent in Java might read what I was writing and have it come across as when a Japanese song writer decides to use English and comes up with, “Missing truth and forever, kissing love and true your heart.”

The imaginary child is going to spend the next several years in school being taught the conventions of grammar, spelling, and punctuation. She’ll be compelled to read a variety of significant works and will be expected to produce examples of various literary forms which will be critiqued. This is the stage of learning that I hope to accelerate and just as even the OED with its numerous examples of how the words of the English language have been used is insufficient to produce a competent writer, I do not believe that API documentation is sufficient to produce a competent Java programmer.

Oct 26, 2011

I’ve never understood places that buy big signs of the sort that you can hang letters on and then don’t buy enough letters to spell out the messages they want. You can easily spot these by noting which establishments have signs that have been abbreviated to such an extent that the original message can no longer be deciphered. They may as well just take all of the letters down and stop paying people to rearrange them periodically. It’s not as if we know what they’re trying to say anyway.

Oct 24, 2011
Oct 24, 2011
#cones #orange #parking lot

eccentric-nucleus:

(you really don’t want to know to what degree all that code is copied and pasted between functions)

(but it’s about as bad as you might imagine)

(really this is C though, so there’s not really any kind of alternative unless you feel like doing something really clever with the preprocessor and i am not that clever)

The answer to that kind of problem is CWEB. It’s too bad literate programming never really caught on.

Oct 23, 201116 notes
Oct 23, 2011
#fish
Query Results View

One of the most common elements of the app I’ve been working on is a view that presents the results of a SQL query. There are three logical components to this: a table title that says what kind of information is in the table (for example, “Current packing items.”), a header that identifies each column of the query, and a scrollable (if needed) area where the data is displayed. Rows in these tables can be selected (and have that selection information passed out to interested listeners) and there are a few other behaviors that need to be possible. At this point I think I have a solid grasp of what I need for a more general purpose custom composite widget and I implemented that today.

Things learned along the way:

  • How to specify a class from my project in an XML layout.
  • How to define and use custom XML attributes with that class.

With this both the code and the XML layouts are much easier to read and the SLOC count is reduced considerably.

Oct 22, 201147 notes
#programming #Android #Java #XML #composite widget
Activity for the Day

Lots of stuff happened today.

First, it was on this date of 21 October in 1991 when Wilson’s Coffee & Tea (the coffee shop I work at) first opened. We’ve come a long way in these past 20 years and I’d like to think that we’ve helped move the specialty coffee industry forward during that time. We have a good track record of doing new things about two years before they start showing up in trade journals while avoiding things that these same journals cover enthusiastically but turn out to be fads that fail to gain mainstream acceptance (we skipped bubble tea, for example, but we were doing brew strength/extraction analysis with coffee brewing control charts to improve the quality of our brewed coffee well over a decade before coffee refractometers were developed). Thanks to the support of our customers we’ve been able to grow the business and bring much of what we do in house. This includes transitioning from a retailer to a roaster retailer by bringing in a coffee roaster (we have two now with a third being built) and roasting the coffee ourselves, adding a commercial kitchen where we produce baked goods from scratch every morning, developing and bottling our own brand of chai concentrate, and writing software that is now being used by several coffee firms throughout the world. I think there are still interesting times ahead for the coffee business and look forward to helping invent the next 20 years.

The reporter with the strange call was on to something yesterday. Tammy Baldwin was at the shop today along with most of our regular Democrat politicians and others I recognize as organizers for past political campaigns. We were asked to keep this quiet, which is why I didn’t know anything about it yesterday, but it drew a crowd anyway so I got to hear most of a campaign speech (I had work that needed to get done, so I was working while that was going on) and had a pleasant meet and greet with her afterward. I’m familiar with her previous political work and while I’ll certainly keep an open mind, realistically I’m almost certainly going to be voting for her and it won’t be one of those “least bad choice” votes. It will be a vote for one of those precious few candidates I believe will do what’s right for America.

Over the past few days, about 5,300 pounds of green coffee have come in so I’ve been busy figuring out how these are going to be roasted, adjusting blend recipes, and doing the other things that are needed to prepare for selling the coffee. A new Brazil Cerrado will be hitting the shelf soon that makes a really nice single origin espresso (and this coming from someone who is not a fan of the SOS, I’d be willing to drink that every day). The new Fair Trade Certified Peruvian coffee makes a nice Vienna Roast so that will be available (along with a lighter roast of that coffee that will be sold as a Peruvian coffee). I’ll have a writeup of all the new coffees on the shop’s web site once the new coffees are available for sale.

We signed papers to move forward on cutting out a couple layers of middlemen in our credit card processing and going with a company that hasn’t invented new fees to compensate for the Durbin Amendment to the Dodd-Frank Wall Street Reform and Consumer Protection Act of 2010. As credit and debit card transactions become an increasingly large proportion of sales, this will help in keeping our costs (and your prices) under control. I’m not going to say that prices will go down as this does nothing for rising costs of materials and labor, but it gives us a bigger cushion to increase prices more slowly (we don’t have any current plans to increase prices).

On the topic of firing companies we do business with, we’re going to have to find a replacement for the distributor that supplies us with a lot of our best candies. I could understand things being screwed up last year when the company we had been dealing with was acquired by another distributor (though if I were the new parent company I would have waited until after Christmas to start screwing around with the warehouses), but one year later the company is still screwed up. We got one of our big shipments that looked as if it had been packed by people practicing free throws, invoiced for items not shipped, mispicked items, and product spoiled by improper warehousing. They also have a unique interpretation of that standard “prices subject to change” line. With every other company I deal with, when I take a position on product for future delivery the price when I order is the price that I pay. If the price needs to change, they tell me that the price is going to be changing in advance. This company now seems to think it means that they can just put whatever down on the invoice (where whatever is nearly double the price listed in the catalog and the price on the order sheet). I am apparently not the only one who has complained about these things and our sales rep for that company (and several other companies that are not so dysfunctional) will also be looking for their replacement. This is the wrong time of year to mess with your retailers like that.

We’ll also be looking for a replacement ISP. AT&T wants to charge for use over what these days is a pathetically low cap and that’s just not going to work. Sorry, but see figure 1 (note the last three sentences in particular) isn’t going to fly.

Unfortunately, with all of this going on, I wrote a total of 0 lines of program code and I’m in a poor mental state to work on that now, so I’m going to fire up Space Invaders Infinity Gene and blow stuff up for a while.

Oct 21, 2011
I am also real. I get the same spam followers when I post to programming and development

Yes, you would be the other real person mentioned. (Oh look, another bot liked that post.) Thanks for reading. Glad I’m not the only one who noticed that.

Oct 20, 20111 note
Oct 20, 20112 notes
Strange Phone Call

Today the coffee shop I work at got a strange phone call from a reporter with the local newspaper. She wanted to know if a certain politician (in Congress) was going to be at our shop tomorrow and hoped to obtain an interview. There isn’t a scheduled event that we’ve been made aware of, but several politicians are regular customers (this is convenient for me as I can find out where best to direct complaints and it lets me stay in the loop on events of interest) and I would not be surprised if any decided to pop in to get a good cup of coffee or hold a meeting. Such things happen nearly every day. (also, I’m more likely to vote for politicians I see in person regularly, hint hint, vote for sale)

That said, I’m pretty sure that everybody in Congress has some sort of campaign office with people who know where events are being held and can arrange for interviews. Calling them might be a more productive line of inquiry than calling the coffee shop.

Oct 20, 201111 notes
#coffee #politics #journalism
Should I?

I wasn’t sure if I should put out another update or not regarding the ongoing development of my first Android app. Development is ongoing, but none of it has been terribly interesting.

Since I’m writing this app while giving myself a crash course in Java and the Android framework, I’ve been going at it slowly and doing incremental development, building things up one feature at a time, one activity at a time. There are several things that need to go in, but there’s also an obvious order to do things in. Today I thought I’d start on a new activity, happy with the state of the most recently finished one, but I noticed that the UI for one part of this next activity was going to be identical to one part from the previous one. Rather than enroll in the copy paste school of programming, I took that as a sign that I should rip that part out and turn it into a fragment that can be used in both. It was a simple enough thing to do, reduced the amount of code needed for the previous activity considerably, and will make the next activity easier to write.

There are some other cases where I’m going to need to rip out a lot of code and put common functionality into separate classes, but I’m going to put that off for a little while longer to have more time to think about what functionality I’m going to need there and to learn a little bit more about a couple aspects of the framework. With the rate I’ve been going through things I’ll probably decide to do that before I finish version 1.0 instead of waiting until I finish. The sooner I do it, the less code I’ll need to write.

As a side note, I’ve noticed that when I post Disgaea stuff I get likes and reblogs from cool people who post real stuff, but when I post Android development stuff I get likes and reblogs from bot scripts that want to drive up soft core porn advertisement impressions. Tumblr deletes the fraudulent notes within a day or two, but I thought the pattern was an interesting one. (note that I’ve got no problems with real people who post NSFW, I’m just not a fan of the robots)

Oct 19, 201148 notes
#programming #Android #Disgaea #porn #tumblr
Oct 18, 201137 notes
#hello world #programming #dart #javascript
Oct 17, 2011170 notes
Bigger Espresso Machine or Another Espresso Machine?

As a good coffee shop gains traction and starts to serve more drinks, it’s not uncommon that what was once a nice commercial espresso machine starts turning into a bottleneck. The machine just can’t produce the drinks fast enough to keep up with demand. The common response to this situation is to put in a bigger espresso machine with more groups, but there’s another option that is often overlooked which I believe is often the better choice: putting in another espresso machine.

There are some key advantages to running with multiple espresso machines.

  1. Reduced downtime. Espresso machines need periodic maintenance and sometimes they break unexpectedly. With two espresso machines, you can continue to operate at reduced capacity while one machine is down instead of being completely shut down.
  2. More steaming wands. Four group espresso machines often only have two or three steaming wands. A pair of two group espresso machines will usually have a combined total of four, allowing you to steam more things at once.
  3. More working space. With two machines, the working area can be spread out more than is reasonable with a single machine. If you have multiple people using the machines at once, a two machine setup provides a more comfortable working area where certain types of errors are less likely.

The disadvantage is that one person will not usually be able to effectively utilize both machines, so if you commonly get orders for eight shots of espresso in a single drink, this is not ideal. You might also be using some sort of command work flow where different people behind the bar have narrowly defined responsibilities for filling different parts of the order, and two espresso machines are a bit more difficult to manage in that case.

That last disadvantage might turn out to be a side benefit. One of the things that I do every so often (especially when I travel) is go around to various coffee shops, observe how the bar is being managed, how busy the establishment is, and measure how long it takes for orders to be filled. Some places have a single person who is responsible for an entire order from taking the order, to making the drinks, collecting the bakery, and charging the customer. There will usually be multiple people behind the bar who can each handle a customer. Other establishments have a more rigid structure where one person takes the order and charges the customer, another person provides instructions based on the order taken to other people, one responsible for making drinks, another responsible for bakery, and so on, perhaps with yet another person assembling the orders for the customer. It has been my observation that the former work flow is in practice more efficient except during exceptionally busy rushes (think line out the door and tables full all at once). If you have enough people to keep things running, a second espresso machine (and a second cash register/serving area) allows more customers to be handled in parallel, reducing waiting times, and making it less likely that a customer will see a long line and decide that a coffee is not worth the wait.

Oct 16, 201111 notes
#coffee #espresso #design
Play
Oct 15, 20115 notes
#coffee #roasting
Oct 15, 201144,657 notes
#Game Boy
Next page →
2012 2013
  • January 44
  • February 29
  • March 52
  • April 50
  • May 33
  • June 21
  • July
  • August
  • September
  • October
  • November
  • December
2011 2012 2013
  • January 62
  • February 42
  • March 49
  • April 43
  • May 74
  • June 42
  • July 74
  • August 70
  • September 40
  • October 130
  • November 66
  • December 52
2010 2011 2012
  • January 8
  • February 11
  • March 12
  • April 6
  • May 14
  • June 28
  • July 30
  • August 30
  • September 42
  • October 49
  • November 57
  • December 80
2010 2011
  • January
  • February
  • March
  • April
  • May
  • June
  • July
  • August
  • September
  • October
  • November
  • December 11