Tuesday, January 7, 2014

How to create a remarkable career in Software Development

Step one: you should buy and read "The Passionate Programmer: Creating a Remarkable Career in Software Development". I just finished reading this book in the last winter break; it was probably the best way to start a new year. If you haven't read it (you should!), I found a fairly good summary entry here; having read this book, the next step is doing things. "just being good isn't enough. You have to be doing." It is nothing more important than actually doing it. I would like to go over some of the points that this book covered and planning to execute this year.

Be a generalist. Learn lots of things.
At work, I am working on an Android project right now; in spare time, I am going to learn something new. I don't know what yet, it doesn't even have to be programming related. It could be a business thing, finance, or even cooking; an important point is, be open to learn new things.

Be a specialist.
I am working on an Android app at work, so be a specialist on Android framework. It is going to be a focus of this year. Go deep into the framework, have a deep understanding of its technology. Pick a library and dive into the code. I need to develop a strong understanding of a particular topic. Android itself is still vague; a lesson is that when I am working on something, try to develop a deep understanding of subject; for example, try to look into source code and understand how things actually work.

Learn the business rules of your organization.
I need to pay more attentions to the market we (as a company) are in and know more about its business. Pay more attention to how the business works and be aware of the market I am in. I bought a book that is recommended in the book, The Ten-Day MBA. It is a step forward to understand how businesses run and knowing how companies operate.

Have a mentor.
Mentors are living examples and it is a lot easier to learn by example. I am not quite sure how I can find mentors, but I will start by talking to people that I admire and try to have a regular catch up with people in town that are working on great things.

A good way to learn things is to teach it to others. This is an advantage that comes with mentoring.
Teaching a subject to others is going to be a key point this year. At my company, we do lunch and learn where a developer talks about stuff that he is working on, or tips that they can share with others. It is a great place to start this. And we also plan to have a monthly info exchange night with other development companies in town, sharing lessons and talk about technologies that we are working on. These places will be a great learning experience and it will be a great opportunity to have a deeper understanding of a subject.

"Do not work more than 8 hours a day. But you should work so relentlessly that there is no way that you could continue longer than eight hours."

This year, my big goal is become a opensource contributor. I have not picked a particular project that I would like to contribute to, but I can start by reporting issues, fixing known bugs, or adding tests to existing code. I would like to become more active in opensource community and if I can get a patch accepted in some of the major opensource libraries, that is a big accomplishment :)

"Try to be known outside of your company for your excellence. Write blogs, give presentations at local technical meetings and even better in large conferences."
I will be more active in local tech meetups and I would like to give few talks at local meetups. This blog will also play an important role. It is a place to demonstrate my skills and show expertise on subjects. It is also a place to exercise my writing skills and communication skills, which will be an important skill to develop.

wow, that is a long list of things that I want to do this year. Don't be lazy; remember, "you have to be doing".

This year is going to be a great year. I look forward to this.

Hello, 2014.

Wednesday, November 6, 2013

How to configure a custom gson object to Retrofit's RestAdapter

From the previous post, I decided to go with Retrofit for our sync framework for our Android app. There are few reasons behind this. Retrofit offers significantly simple syntax to let us do http GET, POST, PUT, DELETE, and HEAD operations, handles mapping of JSON to Java objects and vice versa, active community and maturer than other alternatives; the fact that Jake Wharton from Square is actively developing on this makes me feel comfortable to go with them as well.

In this post, I am trying to demonstrate how you can use Retrofit to hook up with a modern API service and configure few global mapping definitions. One thing I find in Android community is a lack of intro, how to get started type of articles. Since myself is a newbie to Android development, I would like to document as much as I can to build an Android app with using whatever tools we find the best to work with (any suggestions are welcome!).

Disclaimer: I don't know what I'm doing (yet). I started an Android development literally few weeks ago, so a code sample here is not necessarily the way it should be implemented. Just keep that in mind, and I will make improvement as I get better at it.

How to install Retrofit
We use gradle for a build tool, which works nicely once it sets up correctly.
just add
 compile 'com.squareup.retrofit:retrofit:1.2.2'  
in dependencies.

Setting up Retrofit
RestAdapter is an interface to a REST API. You want to create a singleton instance for a REST API that you want to talk to.

 sRestAdapter = new RestAdapter.Builder().setRequestInterceptor(new RequestInterceptor() {  
       public void intercept(RequestFacade requestFacade) {  
         requestFacade.addHeader("Authorization", "Bearer yourToken");  
I want to add a header with an authentication token for every request we make. so the above line with RequestInterceptor accomplishes that. Set the server URL and you're good.

This will be enough to get you started. But I needed to add few more global wide customization to RestAdapter. I want to add a global mapping rule so that JSON keys with snake_case should be mapped to camelCase keys in Java objects and vice versa. Another customization I wanted to make is I need to correctly map date and date time values to Java objects. Bit tricky thing is that we need to handle two types of dates. One with only date and the other is with time. We can accomplish these customizations by creating our own Gson object (Gson does actual mapping).

This is how I constructed a Gson object to meet the needs above.

 Gson gson = new GsonBuilder()  
           .registerTypeAdapter(Date.class, new DateDeserializer())  
private static final String[] DATE_FORMATS = new String[] {  
private static class DateDeserializer implements JsonDeserializer<Date> {  
  public Date deserialize(JsonElement jsonElement, Type typeOF,  
              JsonDeserializationContext context) throws JsonParseException {  
    for (String format : DATE_FORMATS) {  
      try {  
        return new SimpleDateFormat(format, Locale.US).parse(jsonElement.getAsString());  
      } catch (ParseException e) {  
    throw new JsonParseException("Unparseable date: \"" + jsonElement.getAsString()  
        + "\". Supported formats: " + Arrays.toString(DATE_FORMATS));  
and you add this gson object to the restAdapter by
 setConverter(new GsonConverter(gson))  

There you go. Now every JSON conversion will follow the rules defined above.
Making a http GET request is slightly simple and the official documentation does fairly good job of describing steps. So I won't go over that here.

Next up is setting up a database system and store the java objects after it's been mapped. I hope to address that soon.
Happy Android coding:)

Thursday, October 31, 2013

Sync framework for Android

Background: I work for Clio, we make a web-based practice management software for lawyers (and we are hiring!). We recently launched an iPhone app which I was a part of (more about the experience I had with iOS development and the project in general, here is the blog post). And we recently started to work on Android app for that. I am new to Android development, so for the past few weeks, it is all about learning Android development and researching things. One of things I am researching on right now is deciding what framework we should use for syncing.

Clio is a data-heavy app. For the iOS app, we use RestKit and CoreData as a persistent storage system. I am looking for an equivalent of RestKit in Android. I have few acceptance criteria for this. It should work well with Clio's REST API, and should be flexible enough to work with the nested attributes and polymorphic associations. And it should support JSON, and have a good community, well used, well tested by apps of similar complexity to Clio.

This post is a summary of my findings today and a conclusion I am about to make. If you have any suggestions or comment, you are more than welcome :)

I am new to Android, so if you have experience with this field, please share your experience with me. I would love to talk. Find me on Twitter at @naoyamakino.

it looks like yet another HTTP client for Android. Nothing much beyond that.

“Spring's RestTemplate is a robust, popular Java-based REST client. The Spring for Android RestTemplate Module provides a version of RestTemplate that works in an Android environment.”

“RestTemplate's behavior is customized by providing callback methods and configuring the HttpMessageConverter used to marshal objects into the HTTP request body and to unmarshal any response back into an object.”

HTTP Client: used default ClientHttpRequestFactory,  when you create a new RestTemplate instance. (the standard J2SE facilities)
Google recommends to use the J2SE facilities on Gingerbread (Version 2.3) and newer, while previous versions should use the HttpComponents HttpClient.
RestTemplate supports sending and receiving data encoded with gzip compression.
Libraries that are used for JSON mapping: Jackson JSON Processor, Jackson 2.x, and Google Gson.
RestTemplate provides higher level methods that correspond to each of the six main HTTP methods. These methods make it easy to invoke many RESTful services and enforce REST best practices. For example, the method getForObject() will perform a GET, convert the HTTP response into an object type of your choice and return that object. The method postForLocation() will do a POST, converting the given object into a HTTP request and return the response HTTP Location header where the newly created object can be found.
Objects passed to and returned from the methods getForObject(), getForEntity(), postForLocation(), postForObject() and put() are converted to HTTP requests and from HTTP responses by HttpMessageConverter instances.
You can also write your own converter and register it via the messageConverters property (customizable)
RoboSpice is a modular android library that makes writing asynchronous long running tasks easy. It is specialized in network requests, supports caching and offers REST requests out-of-the box using extension modules.
- executes network requests asynchronously (in a background AndroidService)

RestTemplate from Spring seems to accommodate most of my needs. it handles HTPP requets/response, and do a mapping from JSON to Java objects and vice versa. It looks pretty cool. I haven't tried it yet, but I like it so far from the readings I've done. If you have any suggestions or things I might want to know, please let me know.

Journey with Android development continues..

Monday, September 2, 2013

Absolute Insanity @ #BurningMan2013

When it comes to Burning Man, insanity means it really means it. I've been thinking about how I could describe the experience in Burning Man to others. I could say nothing but insane. It is as if you flip a coin, everything is flipped to opposite; normal becomes abnormal, real becomes unreal, and sane becomes insane. There is no single sober person in that city, everything you see is insane; art, architecture, food, drink, buses, everything.

It was my first trip to Burning Man, a week-long celebration of art, music and general mayhem. Burning Man participants share ten principles. I was amazed how well it was executed, applied to every corner in Black Rock City. We instantly faced welcomes from everyone in the city a second after we stepped in, and it took me while to adapt norm of radical self-expression.

In Black Rock City, we gift everything. Wake up in the morning, drop by a next door and grab a coffee, wander around the city with a mug, poured beer at a themed bar, exchange a costume. Everything happens without exchange of currency.

As an attempt of gifting, I volunteered as a temple guardian. It was freezing cold after midnight but worth an experience with other volunteers and shared one of the most memorable moments, seeing sunrise.

Wandering in a city myself one night, I felt I am still not a part of this big project yet. I am taking too much and not enough of gifting. This is something that I need to work on for a next visit, if that day ever comes again.

One of takeaways.
If you think you are crazy, you are probably not crazy enough.

here are few photos I took at Burning Man.

Thursday, June 13, 2013

"Whatever you do will be insignificant, but it is very important that you do it." via Mahatma Gandhi

"Don't let life randomly kick you into the adult you don't want to become." via Chris Hadfield

“Well, folks, it’s a good life if you don’t break too many guitar strings. And it’s pretty good life if you do." via Simon Whitfield

"Life can be much broader once you discover one simple fact: Everything around you that you call life was made up by people that were no smarter than you and you can change it, you can influence it, you can build your own things that other people can use." Steve Jobs

Thursday, May 2, 2013

RailsConf 2013

I just wrapped up my first RailsConf in Portland. Overall, it was a great experience with a lot of learnings, mingling with whole bunch of people and getting good beers every night.
here are my notes on the lectures that were worth sharing. the orders are by my best interests.

there are quite few good talks about APIs and gave me few useful tips that we could add to our API.
- How to Write Documentation for People That Don't Read Kevin Burke
tips about writing good documentations for both internally and publicly. Kevin is from Twilio and an engineer of their API. There are good examples from various API docs that we can take good practices (eg: error reference page, breaking up the contents by verbs..) Highly recommended to check the note and the slides.

- "Designing great APIs: Learning from Jony Ive, Orwell, and the Kano" via @jondahl
another API engineer from Twilio. API is an interface. looking from an API user perspective, he talked about how API can delight users. some suggestions are API wrapper, request logs, sandbox API, API builder (Zencoder API Builder). None of them are necessities, but having things like those will differentiate from other APIs and will delight API users. 

- Using Elastic Search with rails app via Brian Gugliemetti
Search is hard, how can we make our search less suck? this is worth checking.

- How Shopify Scales Rails via @JohnDuff
Moved away from DelayedJob to Resque, use of Redis, MySQL tuning, caching gems etc. (presentation video link attached in the end of the note)

- Rails vs. The Client

- Dissecting Ruby with Ruby - Richard Schneeman
described few tipis on how to debug through rails code and potentially become a bug reporter to bug fixer!

- Building Extractable Libraries in Rails via Patrick Robertson

- Testing HTTP APIs in Ruby

The word of the conference was from James Duncan Davidson's keynote.
"Create more value than you capture" via Tim O'Reilly. 
He emphasized the importance of contributing to OpenSource communities and help make a world better place. 

The whole conference was surrounded by very positive atmosphere and felt a lot of open source community love, which was different from Goolge I/O that I attended last year.

Last not least, witnessing Aaron merging one of our teammates' pull requests to rails/rails was one of the most memorable moments of this week.

Time to go enjoy a last night with Portland beer.

Saturday, April 27, 2013

RailsConf 2013 Pre day

I am so stoked to attend this year's RailsConf in Portland. This is my very first RailsConf and the second time attending this type of big developer conferences, since Google I/O last year.

Here is my tentative plan for all talks I am thinking of attending: yup, there are so many talks! Four days of all good talks, mingling and learning all kinds of stuff. Can't be more exciting than this.

Mon 4/29
11:30: How Shopify Scales Rails John Duff
12:20pm: Nobody will Train You but You Zach Briggs
2:00pm: Testing HTTP APIs in Ruby Shai Rosenfeld
2:50pm: Front-end Testing for Skeptics Luke Francl
4:00pm: Real-Time Rails Brian Cardarella
4:50pm: Building Extractable Libraries in Rails Patrick Robertson

Tue 4/30
11:30am: Rails Vs. The Client Side Noel Rappin
12:20pm: Cache = Cash! Stefan Wintermeyer
2:00pm: Introducing Brainstem, your companion for rich Rails APIs Andrew Cantino
2:50pm: Designing great APIs: Learning from Jony Ive, Orwell, and the Kano Jon Dahl
4:00pm: Data Storage: NoSQL Toasters and a Cloud of Kitchen Sinks Casey Rosenthal
4:50pm: How to Write Documentation for People That Don't Read Kevin Burke

Wed 5/01
11:30am: Using Elasticsearch with Rails Apps Brian Gugliemetti
12:20pm: Creating Mountable Engines Patrick Peak
2:00pm: Zero-downtime payment platforms Prem Sichanugrist and Ryan Twomey
2:50pm: Keeping the lights on: Application monitoring with Sensu and BatsD Aaron Pfeifer

Thurs 5/02
10:30am: Datomic, from Ruby, from Rails Yoko Harada
11:20am: TDDing iOS Apps for fun and profit with RubyMotion Brian Sam-Bodden

 Portland, I hope to have few spare time to browse around the city and get good few beers.