The goal of the day is practice writing clean code. Usually in our daily work we are trying to meet deadlines or otherwise don’t have the time to do things as well as we would like. We accomplish the task that we set out to do but then never go back to improve it. We discussed this before starting and some basic clean coding principles, based on Four Simple Design Rules.
Based on that description I expected the attendees to be mostly developers with many years of experience. Instead I found a lot of developers who had only been at the craft for a couple of years or less! Everyone was really supportive and excited to get a chance to learn from others and grow as developers. Everyone had something to learn and something to teach; it was an amazing thing to be a part of.
I had the opportunity guide some newer developers in the ways of TDD while also learning different methods of design from others. I had many great discussions throughout the day, especially about JavaScript and Vim.
My favorite challenge was where my pair and I alternatingly wrote tests for eachother but could not speak about design. Trying to move the system forward with only test code to guide us really made me rethink what kinds of information, both intended and not, that tests are capable of containing.
I can’t wait until the next Coderetreat, I definitely plan to continue attending.
]]>Starting in late 2011 I’ve been working primarily in Visual Studio. For the most part it is a great IDE with a lot of powerful features. Combined with the refactoring and productivity shortcuts available in CodeRush things still felt pretty nice. I tried using some vim keybinding addons but they were never as responsive as is necessary to work the vim way. In addition to no longer using vim at work my amount of personal development work had sharply declined. What little I did was done with Visual Studio. I started to forget how nice working in vim really was. Maybe it wasn’t really necessary, I thought. Especially not with tooling this powerful.
Then something changed. I decided to make a committed effort to learning web development. Instead of taking the obvious route of using ASP.NET I decided to go a completely different direction and use Ruby on Rails. I’m writing tons of code on in my free time and doing it all in vim. I’ve never been happer! The flexibility of Ruby is beautiful and expressive. And Rails, while sometimes confusing and magical, makes a lot of sense and helps you get things done. I’m working a ton in vim and loving it.
After being “lost” for so long vim has reminded me what a powerful really development environment is.
Big meaty IDEs lured me into thinking lots of features, integrated menus, and GUI tools were power. This is not to say that vim lacks features or power. It wants for neither.
Nothing else I have used has come close to vim. It has power that I have never had to pay for with my effectiveness or ability to express myself. Every time the big feature-rich IDE churns for a quarter second as it parses background files or does whatever the heck it thinks is more important than me typing I am jarred. Effectiveness drops. This aggregates over the day I find myself frustrated, distracted, and ineffective. Vim doesn’t do this to me.
Vim. I’ve missed you.
]]>Four years later, enter Ruby on Rails. I’m having a blast. The tools are great. The community is wonderful. And after spending every day for two years with my nose buried in Visual Studio I am thrilled to be back to vim. It is bliss.
I’m active on GitHub and attend several regular meetings and extra events with the Ruby community. I’ve made tons of new friends and enjoying all of it. I’ve hardly played a video game in months and I can hardly believe it. I’ve got motivation to work a full day and then another three or four every night. It’s all fun.
If you feel like you’re missing something in your life as a developer try to find a local group. It has made all of the difference.
]]>This challenge caught my interest with its unique combination of ease and depth. While my best submission has dropped to a roughly 60% win rate there are some truely clever programs submitted. I am certain I can improve greatly and develop a submission over the coming weeks that is able to achieve a 70% win rate.
I would encourage anyone who enjoys programming or problem solving to give it a go.
]]>I have taken a few shots at web development and it just doesn’t feel right. While it is such a visual and rewarding experience. I just can’t shake the feeling of it being the most phenomenal kludge.
It is easy to distribute and consume in an almost completely platform independent environment. I love being able to send a someone a link and say, “Hey, check this out!” and have them be greeted by a slick web app.
But despite all of this it still feels wrong.
Android offers you a much more consistent development platform while simultaneously keeping much of the ease of distribution alive.
I like how Android development feels like a merger between web accessibility and desktop consistency.
I do realize that Android has its own host of complexities such as the numerous possible devices, API versions, and the challenges of the application lifecycle.
It won’t say that it is perfect, but I am comfortable saying that it feels very right.
]]>Dialog
. You can easily find a number of ways to do this for an Activity
. You can also find one often repeated, but inadequate, method being proliferated for a Dialog
1 2 3 |
|
There are, however, several problems with this method. It does not…
There is however, a solution if you are targeting at least API Level 3 (Android 1.5). In your onPrepareDialog()
, or wherever you are displaying your dialog do the following:
1 2 |
|
This will have the same result on a Dialog
as setting android:windowSoftInputMode="stateVisible"
for an activity in your AndroidManifest.xml
RadioButtons
and figured I could answer so I decided to take the plunge.
To implement a custom styled RadioButton you can follow the below steps or look at the complete example source here.
Create the drawable resources for your custom RadioButton. You should have at least 4 icons:
Pressed | Checked | |
---|---|---|
True | True | |
True | False | |
False | True | |
False | False |
Place your images in res/drawable
or if if you have a version for each screen density place them in their corresponding res/drawable-ldpi
, res/drawable-mdpi
, and res/drawable-hdpi
folders.
Then create a selector
type XML file in res/drawable. Here is my res/drawable/button_radio.xml
1 2 3 4 5 6 7 8 9 10 |
|
Setup your RadioGroup like so:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
|
I have specified dimension of 50dp as the dimension of my drawables are 50px x 50px. Also notice I am setting android:button
and not android:background
.
Hopefully this can serve as a nice starting point for anyone looking to create some new and interesting effects with simple RadioButtons
.
To do this, you need to create a Spannable text object by using Html.fromHtml and then setting the MovementMethod of the TextView to a LinkMovementMethod. Here is an example using a dialog.
1 2 3 4 5 6 7 8 9 10 11 12 |
|
Or with resources:
1 2 3 4 5 6 7 8 |
|
To see the full context of this example please check out ScoreIt.java
]]>java.lang.IllegalStateException ... SQLiteDatabase created and never closed
Now these errors didn’t appear to have any adverse affects on my application but I certainly did not want to release an app that I knew was spewing errors. I wrestled with this for an evening searching and trying everything I could think of.
Some people suggested opening and closing the database around all accesses. Others suggested littering all of the lifecycle overrides with open and close statements. I found the former unreasonable and the latter inadequate. I needed to keep my database connections open as much as possible because I was working with ListView and ListActivity objects.
I managed to reduce the frequency of the errors but it was still happening consistently if I followed specific steps but I decided to throw in the towel for the time being.
The next day I decided to revisit the issue and make sure I had a better understanding of the problem. I stepped through my app, using a ridiculous number of breakpoints. It soon became clear that it was not a specific line of code that was causing the problem. This error was being generated by the database object when the garbage collector was hitting it.
I experimented a bit further and came up with a solution that seemed to eliminate all of my SQLite database errors.
In the Activities that maintained a database connection I put a close() statement in the Activity.OnDestroy() override:
1 2 3 4 5 |
|
In my database helper class, modeled after Notepad, I changed the open function from:
1 2 3 4 5 6 |
|
To the following:
1 2 3 4 5 6 7 8 |
|
This cleared up all the errors.
]]>