Learning JavaScript, for beginners

Some good links to get started with JavaScript:

Try not to use W3Schools!

Modernizer’s documentation gives really good context to why certain things are done today. I was just reading it yesterday and it got me thinking quite a bit. Skim through though! It only is meaningful when you encounter the cases before.

Don’t leave windows broken

Don’t leave broken windows (bad designs, wrong decisions, or poor code) unrepaired. Fix each one as soon as it is discovered. If there is insufficient time to fix it properly, then board it up. Perhaps you can comment out the offending code, or display a “Not Implemented” message, or substitute dummy data instead. Take some action to prevent further damage to show that you’re on top of the situation.
— The Pragmatic Programmer: From Journeyman to Master

I can’t reiterate this more.

Every time I see a pixel off, a indentation wrong, a word mispelt, I just correct it. I couldn’t just watch things continue to be wrong when I know I can fix it.

And once everything looks tidied, your peers do want to make a positive contribution too. And hopefully, just hopefully, they perform a similar level of upkeep after a while.

The broken windows theory is a criminological theory of the norm-setting and signaling effect of urban disorder and vandalism on additional crime and anti-social behavior. The theory states that maintaining and monitoring urban environments in a well-ordered condition may stop furthervandalism and escalation into more serious crime.
— Wikipedia

Singapore hires a lot of cleaners to sweep up our road sides. It’s quite the same idea, the theory is that once there is litter, people would mind lesser adding more litter to the roads.

And therefore, if you want clean code to look at, why not start with yourself.

It’s just really simple

I was reading this post by Michelle Bu and it really resonated with me.

When I was starting do go into programming from doing freelancing on design, my morale is probably at the lowest. It’s been the most discouraging year perhaps. Everybody would go how simple it really is, just do this and this. Some would give suggestion of some super big framework that totally addresses your problem and more.

But. No one, no one, showed me how to do it. No one has any intention to. Perhaps it’s too simple, perhaps it will take too long of their time.

The dirty secret

There’s a vast difference between being able to imagine how to code something and actually making use of the tool to code it. Great programmers can imagine the intricacies of the task and have a good plan how to attack it. Helpful programmers can lead you to completion.

Most programmers underestimated the task at hand and trivialize the task. Why? Because they want to get the feeling of having conquered the problem in their minds without actually doing it. You get the same elated feeling when you do that. Not knowing what you cannot do will make you less disappointed with yourself. Programmers trivialize things to make themselves feel better.

Some programmers want to use your asking for help as a platform to show off how well-read they are too. They tell of a library you never heard of and claim how easy it is to get things done there but not how to achieve that for your task at hand.

Explain your rejection

In many ways, if you are a programmer and you do that, what you are doing is rejecting to help someone. If so, say it directly. I sometimes have to say this is a laborious task and I don’t have the time to guide you through. If there’s a tutorial that I can easily find, I send it to the person to get started too. I think people appreciate the truth. Either help them all the way or lead them to get help from some other source. Be encouraging. I won some friends this way.

Never say it’s really simple.

Tools of the trade

This is a quick update of the tools I used these days. I am a web user interface developer now so some of these tools might be kinda niche!

  • Text editor: SublimeText 2, because it loads fast and I swear by its open by file name feature
  • Computer: MacBook Air 13″, a decent screen size with good portability. I like working at cafés and this gadget fits my lifestyle.
  • Browser: Chrome 25. I lost track of Chrome’s version, comes with Chrome is the excellent debugger I cannot live without.
  • CSS generator: Less, because Less can be compiled by JavaScript on the client side. It’s easy to get started developing.
  • Revision control: Git or SVN. My vote is to Git but my company is on SVN.
  • Image editor: Photoshop. We use Photoshop for general slicing.
  • Programming and markup languages: Mainly JavaScript, HTML and CSS. We have quite a bit of Handlebars.js stuff as well. We use JavaScript extensively these days.
  • JavaScript framework: Backbone.js and Marionette.
  • Web server: Apache Tomcat. We have a Java stack.
  • Page profiling: Just Chrome.
  • Automation: Ruby Guard and Grunt.js. There’s a bit of LiveReload as well, but only when I develop on a Mac.
  • Quality checks: JShint and Chrome Audit in the console.

I can see what I use previously as a more general web developer.

Tools of the trade

Every web developer uses his/her set of preferred tools. Here’s mine:

  • Text editor: SublimeText 2, because it loads fast and I swear by its open by file name feature
  • Computer: MacBook Air 13″, a decent screen size with good portability. I like working at cafés and this gadget fits my lifestyle.
  • Browser: Chrome 18 or 19. I lost track of Chrome’s version, comes with Chrome is the excellent debugger I cannot live without.
  • CSS generator: Less, because Less can be compiled by JavaScript on the client side. It’s easy to get started developing.
  • Database engine: MySQL InnoDB.
  • Database browser: Sequel Pro, never found a replacement for this. I’ve been using this for 3 years, by far the best.
  • Revision control: Git or SVN. My vote is to Git but my company is still on SVN.
  • Image editor: Photoshop. Embarrassingly I am one of those that will just launch Photoshop to make PNGs with alpha-transparency. There are probably better tools out there but I can’t get used to them.
  • Programming languages: PHP for web development. JavaScript or Ruby on scripting automation. I still use Expect for a bunch of server-side tasks, I cannot move away from that still.
  • Web server: Apache for development. It’s all because of PHP’s xdebug. My colleagues use .htaccess often too. I use nginx for production usually.
  • Load profiling: Seige, it’s simple and reliable.

Other tools include:

  • LiveReload 2 has been extremely convenient and it has been part of my workflow for months. I never looked back.
  • Bash alias lets me quickly navigate through the trenches of my messy directories. I also use it to pull for Git quickly.

On debugging

As we put more and more into programs, debugging becomes time consuming. This quote is particularly true:

As soon as we started programming, we found to our surprise that it wasn’t as easy to get programs right as we had thought. Debugging had to be discovered. I can remember the exact instant when I realized that a large part of my life from then on was going to be spent in finding mistakes in my own programs.

— Sir Maurice Wilkes

Web programmer may be executed in Iran

This is just not sensible to me. This is, perhaps, a result of an overly-conservative interpretation of religious doctrines.

Execution of web programmer in Iran may be imminent

A computer programmer from Canada faces imminent execution in Iran for the actions of another person, which he had no control over, a human rights group says.

Saeed Malekpour wrote a program to upload photos to the Internet, an accomplishment that could cost him his life, Amnesty International reported Friday. Authorities in the Islamic Republic claimed his program was used by someone else to upload pornography and charged him with “insulting and desecrating Islam.”

Source: CNN

Perhaps as a web programmer I feel more for him.

Review: CakePHP Application Development

I have done a few projects using CakePHP the past couple of years. CakePHP has grown to become one of the more popular PHP web frameworks, think of CakePHP as Rails-inspired PHP framework.

CakePHP Application Development

If you’re interested in CakePHP, you may like to check out CakePHP Application Development by Packt Publishing. This book covers lots of beginner topics such as installation and configuration. It is a good book to get started on CakePHP, it has a step-by-step guide that can be useful for starters. The book targets CakePHP 1.2 however, the book is written before CakePHP 1.2 is released so it does not have updated screenshots in it.

Generally the book’s concept is correct. The explanations are written as if someone is talking to you. If you do not like that style of learning, best you avoid this title. CakePHP Application Development covers a creation of a sample app — Quickwall — at the end of the book. Unlike typical tutorials that teaches you how to create a blog with XX framework, this goes into more depth on how best to use the inbuilt features of CakePHP.

My major grip on this book is its numerous errors in code, and a couple of quite unforgiving ones too. The books could have been better edited. Some of the codes did not appear to run and you have to look around to check for syntax errors. It isn’t often, still it’s a bad impression. The codes in the book are badly indented too. This makes the codes hard to read. It’s a good book to learn, but can be better.

Find out more about CakePHP Application Development here, you can also have a look at the book’s Table of Contents here.

The problem with object-oriented languages

Joe Armstrong, the principal inventor of Erlang, is quoted as saying:

“The problem with object-oriented languages is they’ve got all this implicit environment that they carry around with them. You wanted a banana but what you got was a gorilla holding the banana and the entire jungle.”

[via Wikipedia]

Quite true about OOP.

The “interesting things”

I haven’t exactly thought of programming as a chore. And I am always quick to admit that I am not a good programmer, it just so happened to be what I do better in.

Lately, programming has been turning into a tiny chore and I hope it doesn’t enlarge itself. I overcome it partially by adding interesting things to do into the project so it felt a little more fun and probably can gain myself a little more satisfaction. I define “interesting things” to be something I never done before and have a high chance of getting it right. However, these “interesting things” aren’t good for me because I ended up having to maintain these interesting things.

My work generally involves – development, maintaining. I think I am supposed to squeeze testing and planning in somewhere in the steps but I don’t give a crap about those management level definitions.

Development is always the more fun part. You make something in 10 hours and watch it work. However you may end up watching it work for 10 days leaving your eleventh day in front of the computer debugging for the next 5 hours. This process typically recurs and the base case is the termination of product.

I don’t have a good solution for it but I need a constant feed of “interesting things”. So during maintenance, I added in those “interesting things” which is really just a curse. These “interesting things” come back and haunt me; and I end up having to maintain these “interesting things”. And during the maintenance of these “interesting things”, I added…