Tuesday, March 30, 2010

Social Networking

I am now on Twitter, Facebook, TechHui, and Blogger. I have no idea what to do with them all. How do I utilize them and for what purpose? Facebook asks "What's on your mind?" Twitter asks "What's happening?" TechHui asks "What brings you here?" Are random thoughts alright? It seems like the way to keep friends and family up to date. I guess I'm still trying to find my voice. What do I want to say?

Friday, February 19, 2010

Practicing Hacking

I am a big believer in deliberate practice. I've done my research and understand the concept. It is "activities designed, typically by a teacher, for the sole purpose of effectively improving specific aspects of an individual's performance (Anders Ericsson)." It's designed to improve performance, it's repeated a lot, feedback on results is continuously available, it's highly demanding mentally, it's difficult, and it requires specific goals.

Integrating Deliberate Practice

Deliberate practice seems straightforward, but I'm having a difficult time integrating it with learning a programming language. I have no problem implementing deliberate practice with sports or playing a musical instrument. These fields have better rules and objectives when measuring success. It is clear to me on how to improve performance for these fields.

If I wanted to improve my dribbling in basketball I would practice with one hand at a time standing still then while moving slow then by moving fast. After I improve I would increase difficulty.

If I wanted to improve in playing the guitar I would practice each chord individually and then practice transitioning from one chord to another.

Knowledge Work

The previous fields are more on the physical side. Learning a programming language is more knowledge work. How do you optimize performance on knowledge work? I'm trying to figure out a systematic approach for building a deliberate practice strategy for learning a programming language.

My Current Process

I am in the process of learning Ruby on Rails. I want to build web applications. I've been hacking on my application getting things done and figuring stuff out but I do not feel I'm becoming a expert Rails programmer. As soon as I solve my task I have forgotten the process I used to figure it out. I see the finished code but cannot quite remember what searches I did that yielded results and what searches didn't. I also wonder how to repeat the process to deliberately practice that new solution. And if my solution is the correct way to do it.

Will building applications and continuous hacking create an expert programmer?

Saturday, January 9, 2010

Self learning

Self learning has been challenging. Building my blog website application from scratch has been fun but has not been the smoothest experience. I know what I want to implement and need to work to implement the features. The problem is that the work schedule is in my head and not written down. My focus is jumping from one thing to another thing. I'll be working on the layout of the comments and notice something in the comment form I want to improve and switch jobs. And neither one gets fixed. I will be figuring out a schedule of work to do and follow it.

Tuesday, January 5, 2010

Adding Date and Time to my Rails Blog App

For my blog posts and comments I wanted to display the date and time. Fortunately, the models automatically add the attribute created_at of datetime during the migration to the database. This allows me to just call the created_at attribute from the posts and comments table to display them after they have been created.


I got my first problem when I added it to my view. It appeared as 2009-12-14 08:25:51-1000. That's not what I wanted. I wanted December 14th, 2009 8:25AM. And this gave me another problem, the time was 10 hours off. I wanted Hawaii time so it should have been 2009-12-13 22:25:51-1000.


After a lot of searching I was able to piece together a solution. I have rails 2.3.3.


To format date and time I modified config/enviroment.rb. Looking at this file I found config.time_zone = 'UTC'. I didn't know what UTC was but above it had Run "rake -D time" for a list of tasks for finding time zone names. So I ran 'rake -D time' in my terminal and was given 'rake time:zones:local' which I ran and was given Hawaii as my time zone. So I changed config.time_zone = 'UTC' to config.time_zone = 'Hawaii'. This gave me my date and time but not the right format.


I wanted December 14th, 2009 8:25AM. To get this I had to create my format. I eventually found rails module for conversions. I then had to figure out what %Y-%m-%d meant. When I found the meaning I wrote the code below to display my date and time format. I also found to get 1 to display as 1st, 2 as 2nd, 14 as 14th, 23 as 23rd I had to add ordinalize to the day.


ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS.merge!(

:time => '%I:%M%p',

:date => lambda { |time| time.strftime("%B #{time.day.ordinalize}, %Y") }

)


Format Meaning

%a The abbreviated weekday name (“Sun'’)

%A The full weekday name (“Sunday'’)

%b The abbreviated month name (“Jan'’)

%B The full month name (“January'’)

%c The preferred local date and time representation

%d Day of the month (01..31)

%H Hour of the day, 24-hour clock (00..23)

%I Hour of the day, 12-hour clock (01..12)

%j Day of the year (001..366)

%m Month of the year (01..12)

%M Minute of the hour (00..59)

%p Meridian indicator (“AM'’ or “PM'’)

%S Second of the minute (00..60)

%U Week number of the current year, starting with the first Sunday as the first day of the first week (00..53)

%W Week number of the current year, starting with the first Monday as the first day of the first week (00..53)

%w Day of the week (Sunday is 0, 0..6)

%x Preferred representation for the date alone, no time

%X Preferred representation for the time alone, no date

%y Year without a century (00..99)

%Y Year with century

%Z Time zone name

%% Literal “%'’ character



In my view I added:


%= comment.created_at.to_s(:date) %

%= comment.created_at.to_s(:time) %


Now every post and comment has a correct date and time.

Thursday, December 17, 2009

Keola's Blog Application

For the past 16 days I’ve been hacking away on my blog application. My goal is to go from development to production. I want to get version 1.0 online by February 1st. I’m not quite sure what’s involved in taking a website public, but I am going to find out.

The site will be a two-column layout containing a header, navigation, content, sidebar, and footer. The navigation bar will have a home, about, contact, and blog page.

The blog engine is similar to the “creating a weblog in 15 minutes with Rails 2” screencast with a few minor tweaks. I added a few more attributes to the comment model to get a name, email, and website.

I also am building this application without using the scaffold to generate things. I want to understand the Rails convention. I want to fill out the controllers, views, routes and whatever else is needed. It’s running, so I’ve been pretty good about adding what is needed.

The past couple weeks have been fun. I’ve gotten further along then I planned. Everything is flowing. Next I will share some things I discovered.

Tuesday, December 1, 2009

Taking Action - Start to Finish

Imagining something you might like to have or do is a dream. A dream written down and clearly visualized is a goal. A tangible, measurable step written down and committed to is an action. You will not achieve a dream if you don't systematically work through the actions that lead to the goals that lead to the dream.


It's easy to get passionate about setting goals. We all get excited about our dreams. Taking consistent action on them on a daily basis until they are done is another story. How do we stay motivated with the same passion and excitement to follow through on the everyday tasks required to achieve the goals? How do we overcome any obstacles that occur?


Whenever we conceive the goals we want to achieve, we each enter our own process to accomplish these goals. My process involves imagining my goal as a finished product, researching and planning by gathering information to be prepared to work on the goal, and taking action to achieve the goal while maintaining the passion and self-discipline to follow through to the end result.


I have noticed that I easily get distracted and stuck in the researching and planning phase. I'm always looking for more and more information, but rarely implement what I've already learned. I am acknowledging that there are profound barriers between reading and DOING. I know that the solution isn’t “more,” but actually using the knowledge I've gained. I need to get to the action phase sooner. FAILURE is OK! I'll be learning while doing.


After taking action there is always an obstacle or two that try deter you from reaching your goal. At this point it becomes difficult and the excitement fades. This is when the self-discipline needs to kick in. I use my ability to be resourceful and work on solving the obstacle. If I'm having trouble figuring out how to overcome the obstacle, I seek out help. Two people are better then one and three people are better then two.


Today is the day I begin taking action. I've been learning Rails for a couple months and am still researching and planning. All I've been doing is reading up on Rails, CSS, and XHTML as well as following a bunch of tutorials. I haven't even started my own application. I've worked on a store application which had a buyers side with a shopping cart and a sellers side to handle the products and sales. I worked on a digg like application where users could submit articles and vote on them and view the most popular ones. I've done many different blog applications. And many more tutorials. Today I start hacking on my applications and less on tutorials. Maybe even find someone else's and contribute to it.


My dream is to create a website with all my web applications. My first goal is to create a blog for my website similar to the ones I read everyday. My actions will be to build the blog beyond what the tutorials teach.

Wednesday, November 11, 2009

Rails MVC

Ruby on Rails is an MVC framework for web application development.

The Model View Controller principle divides the work of an application into three separate but closely cooperative subsystems.

The Model is responsible for maintaining the state of the application. When the state is transient, data will last a few transactions with a user. When the state is permanent, data will be stored using a database. A Model will maintain the data. The Model enforces all the business rules and logic that apply to the data. The Model acts as both a gatekeeper and a data store.

ActiveRecord plays the role of Model in Rails. It is the module for handling business logic and database communication. It maintains the relationship between object and database and handles validation, association, transactions, and more.

The View is responsible for generating a user interface, normally based on data in the Model. The View handles graphical user interface objects and presentation logic.

ActionView plays the role of View in Rails. It is the component that handles the presentation of pages to the client. A presentation of data in a particular format, triggered by a controller's decision to present the data. They are script based templating systems and very easy to integrate with AJAX technology.

The Controller orchestrates the application. The Controller receives events from the outside world (normally user input), interact with the Model, and display an appropriate View to the user. The Controller handles user interface and application logic.

ActionController plays the role of Controller in Rails. It is the component that handles browser requests and facilitates communication between the Model and the View. The facility within the application that directs traffic, on the one hand querying the models for specific data, and on the other hand organizing that data (searching, sorting, massaging it) into a form that fits the needs of a given view.

The MVC process:
  1. The browser, on the client, sends a request for a page to the controller on the server.
  2. The controller retrieves the data it needs from the model in order to respond to the request.
  3. The controller hands the retrieved data to the view.
  4. The view is rendered and sent back to the client for the browser to display.
Following a set of conventions and partitioning your functionality appropriately, code becomes easier to work with and your application becomes easier to extend and maintain.

Separating a software application into MVC:
  • improves scalability
  • make maintenance easier
  • promotes reuse
That's the simplistic overview of Rails and the MVC architecture pattern. Thats what MVC means, and thats how rails accomplishes it. Rails starts with the skeleton of an application already prepared. The configured skeleton application along with the MVC design creates a robust language.