If you're adding a new index with a release, be careful as the index must be built before it can be used.
You can watch the index build progress in the Admin Console -> Data Store Index screen. When complete you can switch to your new deployment.
Or you'll get:-
com.google.appengine.api.datastore.DatastoreNeedIndexException: The index for this query is not ready to serve. See the Datastore Indexes page in the Admin Console.
This blog is used for testing my PubSubHubBub service. The posts are related to the project, but a short and updated a lot because I'm usually trying to test something.
Sunday, 19 December 2010
Thursday, 16 December 2010
Commands and Selections
I'm turning my commands outside in.
I say it this way as they were the wrong way around.
I was passing Selections into Commands, when it should really be the other way around.
The selection should apply the command to itself. In this way it can traverse its internal collection in its own way. E.g. if the selection has a cursor on a database instead of an in memory collection.
Why am I calling them Selection instead of Collections? Well it's because I don't want to expose a whole Collection interface. Think of a Selection as the model for a multi select list box. It has a collection of items, and a collection of which of which items are selected.
I think Commands should only operate on the selected items in the Selection. I'm breaking that rule at the moment!
I say it this way as they were the wrong way around.
I was passing Selections into Commands, when it should really be the other way around.
The selection should apply the command to itself. In this way it can traverse its internal collection in its own way. E.g. if the selection has a cursor on a database instead of an in memory collection.
Why am I calling them Selection instead of Collections? Well it's because I don't want to expose a whole Collection interface. Think of a Selection as the model for a multi select list box. It has a collection of items, and a collection of which of which items are selected.
I think Commands should only operate on the selected items in the Selection. I'm breaking that rule at the moment!
Saturday, 11 December 2010
Cache and Tickle
Started experimenting with Google MemCache.
The Task Queue maximum task size was limiting the amount of data I could post to a Queue.
So I moved to putting the data in the Data Store then sending a tickler to the Queue handler.
However this produced several data store errors with contention for the records I was updating.
I'm trying to solve this by transporting the data using MemCache.
It's not absolutely crucial that the data be there.
The Task Queue maximum task size was limiting the amount of data I could post to a Queue.
So I moved to putting the data in the Data Store then sending a tickler to the Queue handler.
However this produced several data store errors with contention for the records I was updating.
I'm trying to solve this by transporting the data using MemCache.
It's not absolutely crucial that the data be there.
Thursday, 2 December 2010
Feed Me Headlines Via PubSubHubBub
Feed Me is a new Android PubSubHubBub client.
I got 20 more registrations when I placed C2DM in the description.
The other reason could be that this places me in the new category again.
They appear to be mainly Chinese.
173 now!
177 !
I got 20 more registrations when I placed C2DM in the description.
The other reason could be that this places me in the new category again.
They appear to be mainly Chinese.
173 now!
177 !
Sunday, 28 November 2010
Protocol Buffers In Android Databases
I've got a self contained structure that I want to store in each row in a database.
Rather than normalising everything out into tables, I want to have the flexibility to add fields and relations, without having to perform database migrations for each client.
So I've stored my structure in a Protocol buffer. Since this structure is simply plucked out of a parent protobuf then this is simple.
I've reused the Base64 trick as storing a byte array didn't seem to work.
Rather than normalising everything out into tables, I want to have the flexibility to add fields and relations, without having to perform database migrations for each client.
So I've stored my structure in a Protocol buffer. Since this structure is simply plucked out of a parent protobuf then this is simple.
I've reused the Base64 trick as storing a byte array didn't seem to work.
Saturday, 27 November 2010
Base 64 Encoding Protocol Buffers
I need to fit a message inside a strict 1024 byte envelope. I've not had this kind of restriction since working on embedded devices back in the late 80's and early 90's.
I have warmed to XML having learnt hard lessons about changing on the wire formats for messages, between version skewed participants. So XML has been great for server side in banking where much of our data is already in XML and JVMs have 4Gb of physical RAM. On the transaction side of banking, XML parsing speed has always been dwarfed by RDBS transaction times. These statements are not so true on the market data side.
I'm back in the mobile device world and XML is too verbose. There are already mechanisms for reducing the size, for example WBXML, aimed at old WAP browsers. However WBXML required much hand crafting of code pages and analysis of occurrences for new message types. I shiver at the thought of all the hand coded parsers I've seen.
I had read about the Google protobuf library, and decided it was trying to address the exact problem I had, which is mainly about space. I therefore needed in binary encoding.
The downside is that the web is my wire, so I have to character encode the binary.
I'm using the Apache Commons Codec libraries for this.
I couldn't use the latest Apache Codec on android, as it appears to have a repackaged version that exists already.
Since my input content is never more than 1024 bytes, I'm using the Base64 class.
A great feature are the Base65.URL_SAFE and Base64.NO_WRAP flags which give me exactly what I need to be able to use my encoded string as a HTTP parameter.
Perfect.
I have warmed to XML having learnt hard lessons about changing on the wire formats for messages, between version skewed participants. So XML has been great for server side in banking where much of our data is already in XML and JVMs have 4Gb of physical RAM. On the transaction side of banking, XML parsing speed has always been dwarfed by RDBS transaction times. These statements are not so true on the market data side.
I'm back in the mobile device world and XML is too verbose. There are already mechanisms for reducing the size, for example WBXML, aimed at old WAP browsers. However WBXML required much hand crafting of code pages and analysis of occurrences for new message types. I shiver at the thought of all the hand coded parsers I've seen.
I had read about the Google protobuf library, and decided it was trying to address the exact problem I had, which is mainly about space. I therefore needed in binary encoding.
The downside is that the web is my wire, so I have to character encode the binary.
I'm using the Apache Commons Codec libraries for this.
I couldn't use the latest Apache Codec on android, as it appears to have a repackaged version that exists already.
11-27 15:48:42.551: DEBUG/dalvikvm(479): DexOpt: 'Lorg/apache/commons/codec/binary/Base64;' has an earlier definition; blocking outI also could not get the Base64OutputStream and Base64InputStream to create content correctly.
Since my input content is never more than 1024 bytes, I'm using the Base64 class.
A great feature are the Base65.URL_SAFE and Base64.NO_WRAP flags which give me exactly what I need to be able to use my encoded string as a HTTP parameter.
Perfect.
Tuesday, 23 November 2010
Use SL4J To Isolate Code From Customers And Test Frameworks
If you're writing libraries that other people will use and you use logging, then you may have a problem.
There are so many logging frameworks out there, you're bound to have customers who use different logging libraries.
I use SL4J to solve this issue. It is the 'Simple Logging Facade For Java' and has a plugin jar for each target logging environment. This allows your library to play nicely with the logging system in the target environment without you knowing what it is.
There are so many logging frameworks out there, you're bound to have customers who use different logging libraries.
I use SL4J to solve this issue. It is the 'Simple Logging Facade For Java' and has a plugin jar for each target logging environment. This allows your library to play nicely with the logging system in the target environment without you knowing what it is.
Sunday, 21 November 2010
JPA Field Names Break Encapsulation
I've made this mistake a couple of times.
When writing JPA queries I must remember to use the private field name not the bean property name.
This is annoying and leads to mistakes writing setters. I usually prefix field names with and underscore "_" or "m" (depending on the convention in the code base). If I don't do this I sometimes end up assigning the field to itself in the setter.
This detail has to be exposed to the JPA. So I tend to name the field without a prefix in JPA persistent classes.
I suppose I could always do query by example or some JPA annotation to hide the difference.
When writing JPA queries I must remember to use the private field name not the bean property name.
This is annoying and leads to mistakes writing setters. I usually prefix field names with and underscore "_" or "m" (depending on the convention in the code base). If I don't do this I sometimes end up assigning the field to itself in the setter.
This detail has to be exposed to the JPA. So I tend to name the field without a prefix in JPA persistent classes.
I suppose I could always do query by example or some JPA annotation to hide the difference.
Tuesday, 16 November 2010
Android Icons SVG to PNG
Inkscape I love you. It was a real pleasure to work with shapes instead of pixels for making icons.
Gimp, you were great too, if only to nicely resample and render my SVG into little Icon sized PNG.
Here are some references.
h1. Android Branding
http://www.android.com/branding.html
Can be used, reproduced, and modified freely in marketing communications. Our standard color value for print is PMS 376C. Our online hex color is #A4C639.
When using the Android Robot or any modification of it, proper attribution is required under the terms of the Creative Commons Attribution license.
http://code.google.com/policies.html#attribution
h1. UI Design
http://developer.android.com/guide/practices/ui_guidelines/index.html
h3. Icon Design
http://developer.android.com/guide/practices/ui_guidelines/icon_design.html#menuapx
h3. Icon Sizes
http://developer.android.com/guide/practices/ui_guidelines/icon_design.html#screens-table
Icon Type Standard Asset Sizes (in Pixels), for Generalized Screen Densities
(ldpi) (mdpi) (hdpi)
Launcher 36 x 36 px 48 x 48 px 72 x 72 px
Menu 36 x 36 px 48 x 48 px 72 x 72 px
Status Bar 24 x 24 px 32 x 32 px 48 x 48 px
Tab 24 x 24 px 32 x 32 px 48 x 48 px
Dialog 24 x 24 px 32 x 32 px 48 x 48 px
List View 24 x 24 px 32 x 32 px 48 x 48 px
Gimp, you were great too, if only to nicely resample and render my SVG into little Icon sized PNG.
Here are some references.
h1. Android Branding
http://www.android.com/branding.html
Can be used, reproduced, and modified freely in marketing communications. Our standard color value for print is PMS 376C. Our online hex color is #A4C639.
When using the Android Robot or any modification of it, proper attribution is required under the terms of the Creative Commons Attribution license.
http://code.google.com/policies.html#attribution
h1. UI Design
http://developer.android.com/guide/practices/ui_guidelines/index.html
h3. Icon Design
http://developer.android.com/guide/practices/ui_guidelines/icon_design.html#menuapx
h3. Icon Sizes
http://developer.android.com/guide/practices/ui_guidelines/icon_design.html#screens-table
Icon Type Standard Asset Sizes (in Pixels), for Generalized Screen Densities
(ldpi) (mdpi) (hdpi)
Launcher 36 x 36 px 48 x 48 px 72 x 72 px
Menu 36 x 36 px 48 x 48 px 72 x 72 px
Status Bar 24 x 24 px 32 x 32 px 48 x 48 px
Tab 24 x 24 px 32 x 32 px 48 x 48 px
Dialog 24 x 24 px 32 x 32 px 48 x 48 px
List View 24 x 24 px 32 x 32 px 48 x 48 px
Saturday, 13 November 2010
MVP With No GUI Editor Sucks
I'm looking back at my old boiler plate servlets now, and thinking, they were a lot easier to write than this MVP stuff!
I imagine the pattern grew up as part of building a GUI designer. You need to be able to layout the views without them being wired up to their presenters. The two phase construction of the presenters allows this.
1) Normal class construction phase
2) Wiring phase, where the views are wired to their presenters and will start delivering interactions.
In Dolphin Smalltalk, you layout presenters (only slightly counter intuitive) they show using their default view. You can change the view they use if you wish.
Without this GUI designer, I have an extra chore of mapping my view classes to named items in the webpage. This is tedious and without the visual reference I'm getting a little lost.
The next time I attempt this, I'll try and work it into some JSP designer. I've never had great experiences with them.
I imagine the pattern grew up as part of building a GUI designer. You need to be able to layout the views without them being wired up to their presenters. The two phase construction of the presenters allows this.
1) Normal class construction phase
2) Wiring phase, where the views are wired to their presenters and will start delivering interactions.
In Dolphin Smalltalk, you layout presenters (only slightly counter intuitive) they show using their default view. You can change the view they use if you wish.
Without this GUI designer, I have an extra chore of mapping my view classes to named items in the webpage. This is tedious and without the visual reference I'm getting a little lost.
The next time I attempt this, I'll try and work it into some JSP designer. I've never had great experiences with them.
Saturday, 6 November 2010
Wednesday, 3 November 2010
Most Valuable Pattern
I first came across the Model View Presenter pattern in Dolphin Smalltalk. Of all the patterns I've learnt over the years it remains enigmatic, beautiful and In my opinion misunderstood. Last night I implemented the MVP pattern again on a home brew project and I was struck again by the following elegant that can result, after your rewire your head.
Rewiring your head is painful and unnerving, but it's clearly something that Andy and Blair did when writing Dolphin Smalltalk. I remember the child like fascination as I traced through the very small amounts of code, wondering where the code that did anything was. When you check back and see the small collection of components. You begin to realise that it's the different composition of these components and the same pattern repeated down and down like a fractal that give rise to complex emergent properties.
What I mean by this, is that Models can themselves contain MVP patterns, as can Views and Presenters. Indeed in Dolphin Views can even act as their own default Presenters.
There's a problem though. The pattern is so loose, so decoupled so self similar and holonic that it's very easy to get lost. This isn't such a problem in Dolphin which has a great GUI designer, because the view hierarchy gives you a visual reference to which layer you're dealing with.
This being the second or third time that I've had a crack at making a simple MVP framework for the Web, and the second or third time I've tried to do it test first, I realised that that M, V & P are names for spaces that you need to fill in yourself. Having Interfaces or class hierarchies is a hindrance. The secret stars of the show, outlined in the original Taligent paper are to my mind Commands, Selections, Notifications and Interactions (or Interactors as the paper has them).
Commands, Selections, Notifications and Interactions are easy to unit test using mock objects. However Presenters appear to be largely about wiring.
I want to write some more about the circular feedback around from input view, through presenter to model and back to view.
I also want to write about the asynchronous nature of the different event or action types in MVP.
Back to the code it's too good to leave this long
Rewiring your head is painful and unnerving, but it's clearly something that Andy and Blair did when writing Dolphin Smalltalk. I remember the child like fascination as I traced through the very small amounts of code, wondering where the code that did anything was. When you check back and see the small collection of components. You begin to realise that it's the different composition of these components and the same pattern repeated down and down like a fractal that give rise to complex emergent properties.
What I mean by this, is that Models can themselves contain MVP patterns, as can Views and Presenters. Indeed in Dolphin Views can even act as their own default Presenters.
There's a problem though. The pattern is so loose, so decoupled so self similar and holonic that it's very easy to get lost. This isn't such a problem in Dolphin which has a great GUI designer, because the view hierarchy gives you a visual reference to which layer you're dealing with.
This being the second or third time that I've had a crack at making a simple MVP framework for the Web, and the second or third time I've tried to do it test first, I realised that that M, V & P are names for spaces that you need to fill in yourself. Having Interfaces or class hierarchies is a hindrance. The secret stars of the show, outlined in the original Taligent paper are to my mind Commands, Selections, Notifications and Interactions (or Interactors as the paper has them).
Commands, Selections, Notifications and Interactions are easy to unit test using mock objects. However Presenters appear to be largely about wiring.
I want to write some more about the circular feedback around from input view, through presenter to model and back to view.
I also want to write about the asynchronous nature of the different event or action types in MVP.
Back to the code it's too good to leave this long
Wednesday, 27 October 2010
First Post
So many ways to log the passing of time, but is Blogger one of them?
- I can edit posts after publication
- Changes are pushed via PubSubHubBub in under 5 seconds
Subscribe to:
Comments (Atom)