Friday, January 13, 2012

Stop SOPA!

This issue is too important to ignore so I've been trying to build a post that explains what SOPA is and why it is not the answer.  Turns out that Tim O'Reilly has recently given an interview about why SOPA isn't needed and should be stopped.  As a publisher who benefits from copyright, he explains in a clear and concise manner why SOPA is not needed.  Read the full interview at GigaOM.

Monday, December 12, 2011

iAutoCalc 1.3.1 Released!

Version 1.3.1 of iAutoCalc was approved by Apple and released this morning.

For the next few days iAutoCalc will be offered at the sale price of 99c.

Change list:

  • Fixed total interest paid calculation bug.
  • iOS 5 tested
  • Code cleanup

Wednesday, December 7, 2011

iAutoCalc Bug and Fix

**Update**
Version 1.3.1 of iAutoCalc has been submitted to the app store for review.  It should be available again in a few days.
****

I want to say thanks to the kind reviewer who suggested I learn how to add.  In fact the bug subtracted the down payment from the price twice so adding isn't really my problem ;-)

I'll make sure to let my QA department know they missed a bug and to work harder next time!

Joking aside, the bug is fixed and a new version will be sent to Apple for review and included into the app store shortly.  I have recently cleaned up some other parts of the code and want to do some additional testing before the next release.

Tuesday, December 6, 2011

Emacs Org-Mode

As a vi and vim user I had never come across emacs org-mode until yesterday.  I've spent the last couple days fitting it into my project and task workflow and must say that I am really impressed.  Traditionally whenever I have tried to use project management or task tracking software it would always get in the way of how I wanted to do things.  This inevitably would lead me back to a text file list on my desktop, a piece of paper with notes, and recently a google doc that looks a lot like my desktop text file.  Org-mode has opened my eyes to how project management should be done.

First off, since I'm not an emacs user yet, some of the key binding issues have slowed me down.  Out of the gate I have set up my projects in a simple, and I think, logical fashion.  I've read about other people maintaining a single .org file with their entire life in it, but that seems a bit too unwieldy to me.  Perhaps that's my lack of emacs skills showing through though.

In my initial setup, I have a .org file for each project.  Projects that are work related are simply named work_.org in addition to a catchall project called work_general.org.  The general project is a place to put quick TODOs that popup out of meetings or conversations that are not really projects.  Overall, it's a nice easy way to keep everything work related together and grouped by project.  Now, this does mean I have to add each .org file to my .emacs to have it show up in my global TODO list, but that's actually a good thing since I want my global TODO list to only show work items.

For my non-work life I have a life.org file.  I keep this file out of the global TODO list and use it stand alone for everything from what needs to be done from things with the house to buying gifts to whatever ("TODO cancel XBOX live subscription" is on there).

Finally, personal projects have their own file, projects.org.

The beauty of org-mode is that it's just text files.  At any point and time while taking notes on a project I can type "TODO" and the line becomes part of the global TODO list.  The list lets me jump right to the TODO line and see the context of the notes that caused the TODO to come about.  Something so simple, yet at the same time completely awesome.

This is the first time in a long time I've been excited about something like project management.  I'm not really surprised that emacs contained org-mode (isn't emacs it's own self hosting OS by now?), but at the same time I never thought to look.  The org-mode website mentions converting vi users to emacs.  I can't say that will happen, but hopefully learning both vi and emacs to a sufficient level will not be like crossing the streams.

Resting and Working

People who write software are using their creativity to solve problems.  I compare it to writing using a very precise language and grammar to express a story to the user.  I came across this video over at the 99%.  In it Tony Schwartz, author of "The Way We're Working Isn't Working", relates athletic performance to creative performance.  One thing athletes have known for years is that the rest between workouts is just as important as the workout itself.  While it seems intuitive that it would work the same way with mental work, many creative professionals skip the rest part in order to squeeze in more work.  This additional work is usually lower quality and eventually the lack of rest becomes detrimental to creativity.
(It's a flash player, so if you have flash block on click the whitespace below to make it load.)

Friday, December 2, 2011

UITextField Format For Currency Revisited

Since my first post on formatting a UITextField with proper currency symbols and separators I think I have learned a lot more about objective-c and more importantly the UI components provided by Apple.  In this article I will revisit how to format a UITextField with the correct currency symbol and grouping separators.

The original goal was to create a text field that would update in real time both with the currency symbol and grouping separators as numbers were typed in.  The first working solution can be found here, but it had some short comings particularly in code complexity.  The main problem was that I was trying to keep the string formatting correct so that I could decode the string to an NSNumber using a currency formatter and then encode the string again to an NSString.  This was needless complicating the code when dealing with inputting characters. The original code:


Instead it was much easier to just strip out the currency symbol and group separators and then use a basic number formatter to turn the string into a NSNumber.  I was able to remove an entire section of code:


Finally, take the newly formed NSNumber and run it through the currency formatter to create the desired output.  The entire new method is below:


First thing to notice is the cleanup of the code between lines 19 and 21. There is no more special case, and thus reduced complexity. Line 32 is what allowed the removal of the special case. Instead of trying to work with symbols and groupings they are now ignored completely and removed before being added back in. The variable clean_string will end up a string with only numbers and will be easily parsed into an NSNumber by a basic NSNumberFormatter.

There are a few class instance variables that need to be set. The init and associated dealloc is below even though they are not necessarily related to the optimizations above.

Formatters is a custom class that contains various class methods to return ready to use formatters. In the next article I will show how it is setup. In the meantime two new NSNumberFormatters could have just been declared inline. See the Apple reference documentation for NSNumberFormatter.
The above improvement cut out some code that was not needed, but most of all made the logic easier to follow.  Instead of having to worry about special cases with currency symbols when inserting new characters, they can now just be ignored.  The formatters do all of the heavy lifting as they should.

Tuesday, November 29, 2011

The Lazy Programmer: Language Selection

When I was in graduate school one of my fellow students was a C++ fanatic.  To him, every software problem was best solved by C++.  To his credit he probably could solve any problem using C++, but was that really the best use of his time?  By assuming C++ as the best language choice for every problem was he being lazy or simply over working himself?

The common adage to describe the scenario above is "when all you have is a hammer, every problem looks like a nail."  Of course you need a hammer because there are a lot of nails in the world, but there are also a lot of other types of problems.  C++ is well suited to a large (and shrinking, depending on who you talk to) problem domain, but is it really best language to use to develop a web site?  How about loading data into a database, parsing text files, or creating CRUD GUI interfaces?

Each of the problems I listed above have programming languages that fit the problem domain better than any other language.  It may take some time up front to learn a new language, but that time spent is well worth the effort of a simpler to develop to solution.

The lazy programmer, instead of letting tools drive solutions, lets the solutions drive the tools.

Monday, November 28, 2011

Hello World Version 2.0

What a crazy year.  So the blog kind of fell off as work got really busy along with life.  Now that I have gotten life back to a normal pace I plan to resume writing both the blog and some new iPhone apps.  I have a few ideas kicking around and will be working on them as I have time.

iAutoCalc is on my list of TODOs that needs to get updated to the iOS 5.  I have ran it under each version of iOS and it appears to be working fine, but the code will not compile on anything past iOS 3 right now.  Thus, some of my older posts on objective-c unable to compile in some instances.  I'm hoping to get it cleaned up soon.

Monday, July 5, 2010

iAutoCalc 5 Digit Bug!

**UPDATE**
Version 1.3.0 has been released to the app store.
**********

iOS4 changed the API that iAutoCalc uses to format the numerical data in the application. This change leads to iAutoCalc malfunctioning when attempting to enter more than 5 digits into any of the fields.

The fix was a simple 1 line code change and the app has been waiting for Apple to review it since June 29th. I apologize to any customers who have downloaded the app onto iOS4 as it is not very useful in its current state.

This situation has been frustrating for me since customers are leaving bad reviews of iAutoCalc, and even though I have fixed the issue I am waiting on Apple to approve the fix and release the fixed version onto the app store.

Thank you for your patience.

Thursday, May 20, 2010

What Language To Learn First?

When looking at various programming forums I see this question over and over. Many responders usually jump in suggesting languages from C to Java to Ruby to Lisp. Well, maybe not Lisp but you get the point. The problem with so quickly answering the above question is that I think the answer is:
  • dependent on the individual
  • learning a SINGLE language should not be the goal
Personally, I learn by seeing the details. I don't have any problem working at an abstract level (or with infamous car analogies), but before I'm completely comfortable at any given level I need to see the details of what is going on behind the scenes. An example of my personal learning style comes from my first compsci class in college where Turbo Pascal was used to teach object oriented programming. As an aside, the school soon after moved to Java, but at the time teaching object oriented programming so early on in a curriculum was fairly progressive. A key part to any compsci curriculum is the teaching of pointers. Pointers are generally considered a complicated topic, so instead of just explaining what they were in detail the professor instead built these odd analogies. Today I don't exactly remember the analogies, but I still remember them more confusing that helpful even after fully understanding pointers. I do recall though that they had something to with houses and phone lines. :)

After struggling for days trying to understand the analogies that were being used I asked one of my professors to explain in detail just what is a pointer. My professor proceeded to draw a diagram on the whiteboard similar to the one in this wiki article, to which I immediately asked, "that's it?!" All of the methods that my professors to shield me from the details in an effort to help me understand the topic were actually getting in the way of how I learned. I needed to see the details, and at that point my understanding was immediate. Because of my need to see the details in order to understand the whole, I would consider myself a person who learns from the bottom up.

For a person who learns from the bottom up and wants to take things apart and see the details of how it works before understanding the whole, a language like C is the perfect language to start with. C has a concise, fairly simple syntax and hides very little of what is happening on the hardware underneath.

Now, contrast this with a person learns from the top down. This person needs to see the entire picture before looking at the details. This person may never look at the details unless they are forced. This person may also be perfectly content to stay at higher levels of abstraction and often doesn't care what is going on behind the scenes as long as the abstractions work. In essence this person is a top down learner. He wants to understand the entire picture before delving into the details and then only delving as far as absolutely necessary.

For a top down learner, starting with a language like Ruby is a great choice. Using Ruby, the top down learner can see immediate results and hide a lot of the details of what is going on behind the scenes. The person can learn to create programs early on without being bothered to understand the nuances of what is happening on the computer hardware to make the programs work.

At this point I want to state that I'm not saying one type of learning is better than the other. In my opinion both types of students need to learn the same languages, but it is important to realize that people have different learning styles that should be accommodated. This brings me to my second point, that the question should not be about what single language to learn first, but what set of languages to learn and in what order.

I've made the case above that some people learn from the bottom up and some from the top down. This does not mean that they should end up learning different languages though, and at some point should be equally proficient in a similar set of languages. A person who learns from the bottom up when it comes to a single language should apply the same strategy to a set of languages. This means that this student should learn C, then a language like Java or C#, and then move onto the higher level languages like Ruby and Python (then onto functional languages, but I consider those beyond the scope of this article). This person ends up applying their single language learning strategy to the larger problem of learning to program in general.

For the person who learns from a top down approach they would simply flip the order of languages. Start with Ruby, then move to C#, and finally move to C making sure to understand how each level decomposes from the level above or below the current level.

Whether a student goes from the top down or bottom up, both should pay special attention what each abstraction level brings to the table. Where are the leaks in the abstraction? How are they solved? What problems are best solved by each level of abstraction? What are the shortcomings of each language? Advantages? How are the languages the same and different? By researching and answering questions like these the student will gain a much deeper understanding of all the languages they learn.  Each time the student learns a new language they will see new ideas and concepts in languages they thought they already knew.

I hope the next time someone asks what programming language to learn first I can point them to this article because the answer isn't as simple as C/C++/Ruby/Java/Perl/Python/....