Archive
You are currently browsing the Miles Per Hour blog archives
for February, 2009.
By mike@mike-miles.com
I thought I would take a moment and talk about some of the other aspects of web development (and any development for that matter). management and clients. Not that I know a whole lot about these areas, but I feel that as a developer it’s important to have an understanding of these types of things.
Management
Unless you’re a freelance developer you most likely report to a PM (Project Manager) and/or Dev Lead (Sometimes these roles can be one in the same). Some people I know regard their PM’s as strictly management, someone who just bosses you around. That’s the wrong way to think. A PM to a developer is like a handler to a spy. A handler is a spy’s contact, who then relates everything to the agency/government that spy works for, they are the spy’s go to guy. That how you should think of your PM, he’s your contact to the other side of development. If you have a problem with a clients demands, or with upper management your PM should be the guy (or gal) you talk to, its their job to make sure everything runs smoothly, and for that to happen they need to keep you (the developer) happy. Thats not to say they wont kick your butt when they need to (stuff does need to get done after all).
Just as you’ll confuse your PM with programming terms and talk, they most likely will confuse you with management terms, like ‘agile practices’ or ‘gant chart’, ‘serial requirements’, ‘scope document’. It’s important that you two meet on some level playing ground (especially for that last term, oh boy). So I suggest as a developer you brush up on a bit of your management knowledge because it can make work less stressful, and easier for you to communicate your ideas and needs better.
I for example follow a blog by a Joshua Milane (http://mittechnical.com) he’s a PM with alot of experince, and seems to write about the topic in an easy to understand method.
Clients
They people who cause you all your headaches by demanding ridiculous ideas that they expect to be done ASAP. No developer likes talking with clients (at least any that I’ve met) plus that’s one of the reasons why you have a PM (see above). But sometimes the inevitable happens, and you have to deal with clients directly. My approach for dealing with and talking to clients is the same as my programming method, K.I.S.S. No not the band (thou, they do kick ass) I’m talking about Keep It Simple Stupid. If you start getting to technical with a client your going to confuse them, confused clients are unhappy clients and unhappy clients dont pay. So Always try to explain things in a simple form (if you have to explain yourself) and be honest with clients. If you cant build something for them, don’t lie about it. Sure you may lose the client, but they may come back to you in the future with other projects because of how you handled them.
Ok its time to go back to what I know, I have a few functions to build.
By mike@mike-miles.com
Back in December I was working on a project that needed to show progress bars. They progress bars had to show the progress of multiple items, and it was explained to me that they should resemble the percentage bars in iTunes that show how full your ipod / iphone is, like so;
Not a problem I thought to myself, all I needed was a few images and the ever useful PHP GD library . If you’ve never used the PHP GD library before, a brief overview: It’s a graphics library that allows you to create dynamic graphics. (Told you it was brief).
Of course the great thing about PHP is that it is open source, so anything you need todo has already practaclly been done. After googling I found this percentage bar code created by netlobo.com, as well as this progress/percentage bar WebAppers (theirs was in javascript but it gave me a starting point). Both of these were close to what I wanted to do, I just needed to tweak and combine them.
I should note, that since I did use code from both those websites (which are covered under the Creative Commons license and GNU General Public License) this code covers the same licensing.
The Process
My thought process for creating this was pretty straight forward from the get-go.
- Get percents of the items that will be on the bar
- Create a “bucket” image
- for each percent, fill part of the bucket with a color
- Output the whole bar.
And that’s pretty much the route I followed. It was pretty simple actually.
Sorry to say, this code has been removed for legal reasons
but, please check out the sources I used when developing my code (they are mentioned above)
By mike@mike-miles.com
So this post is mainly just to gloat.
I’ve finished my iPhone app, PointsWatcher! (www.PointsWatcher.com) In case you havent checked out my projects page, here is a quick run down of the app for you.
Recently I started doing WeightWatchers with my girlfriend (moral support and what not), but being the technophile that I am I wanted to incorporate my iPhone with it. The result was PointsWatcher. PointsWatcher allows you to keep track of your daily ww Points and an inventory of the food you eat, it also features a points calculator!
So basically it takes alot of the effort out of figuring out point values for your food (and allows you to store point values for future use).
It’s web based, so you can access it from anywhere, but the interface is formatted for use on the iPhone.
You can read the full description about this project here , or check out pointwatcher at its site www.PointsWatcher.com
By mike@mike-miles.com
Recently I started looking into learning some new programming languages (Like many programmers I know, I’m always looking for a new challenge). The languages I’m interested in are Cocoa (Apple’s Objective-C based programming environment, for making an iPhone app) and Ruby (a language I’ve been wanting to pick up for a while). Since I’m in the process of learning these languages, I’d thought I would share my practices for learning new languages.
First I always find it is important to figure out why you want to learn that language. For example, I want to learn Cocoa so that I can build an actual, non-web based iPhone application. Then read up on the language, learn the terminology, the structure, syntax, ect. After that I believe in ‘learn by doing’, as in start developing with that language. Here is the process of developing I usually follow for new languages.
Hello World
This is most likely the first piece of code you ever wrote, a simple piece of code that outputs the words ‘Hello World’ to the screen. I like to keep up this tradition with every language I learn. It’s basic, simple and produces something you can see.
Fibonacci Numbers
Next up, I try and output the fibonacci numbers (1,1,2,3,5,8,…). It’s a simple sequence that involves using a for or while loop. Agan basic, simple yet a step up from ‘Hello World’.
FizzBuzz
Another classic programming example. If you dont know for fizzbuzz you output every number between 1-n (what ever you want your delimiter to be). for every number that is a multiple of 3 you output ‘Fizz’, for every number that is a multiple of 5 you output ‘Buzz’, and every number that is a multiple of 3 and 5 you output ‘FizzBuzz’. A more complex piece of code, that gives you practice with the languages if statments, loops and output, yet still simple enough to be easy to write.
Functions
Next up I take the last three examples and make them into functions. First functions that have take no parameters (just to test function calls). Then into functions that take parameters (to test variable passing). And then finally functions that take user input.After those simple practices my methodoligy changes depending on the language, for example if it’s an object oriented language I’ll go ahead and try writing classes and objects. If not oo I’ll try writing more complex functions (recursive, sorting, ect).
Those practices usually give me enough practice with a language where I can start building simple programs, which I can then build upon and develop. I also try to find online communities where I can find tutorial, examples and tips.
By mike@mike-miles.com
In case you don’t know (or didnt realize) web languages (like php, javascript, ect…) have evolved a long way from their first verisons (duh, mike). With that eveloution they have developed into languages just as complex as standard application languages (java, c++, ect). With the complexity comes the wonderful availability for OOP programming.
The thing is most web programmers are not OOP programmers, the standard for the web has been to be a functional programmer (just writing functions) so a straight up web developer might not be very familiar with OOP programming. OOP programming (creating objects and classes) can be a great resource when writing complex applications. This post is not about how to create an OOP web application (though, writing one might be handy). I wanted to write a post that describes my thought process of when to be OOP, because there are times when it’ll benefit you as a developer and times when it’s just unnecessary overhead.
Rule of thumb – functions
Now we all know that functions are a nessecity, reduces redundent code, automates things, makes your life easier (Side note: I had a few friends in one CS course during college who went the whole semester never writing functions just straight up code. The class was a bioinformatics course using perl so I have no idea why they wanted to do this.) I have a general rule of thumb before writing a function. For me to place code into a function it’s got to meet at least one of these requirments;
- Will I end up writing this code more then twice
- Is this code going to be utterly complex, and long (will break into multiple functions)
- Can I use this anywhere else
If the code matches one of those then I’ll put it into a function. If not I might even still put it in a function. The key is reusability.
Rule of thumb – classes/objects
Now my rule of thumb for creating a class and doing some OOP is almost like my rule of thumb for creating functions, except it deals with functions not just code;
- Will I need to reuse these functions multiple times? (and together)
- Would it benefit to prevent user from accessing these functions (using OOP ‘private’)
- Could I use these functions together in the future
So if a group of functions meets any of those requirements, I’ll rewrite them to be a class. For example, in PHP I have a general Email class that I can put into any project that needs e-mail capabilities. and to use it I just need to include it and invoke the object.
It makes it simple for me to add e-mail to any project, and reduces the code I would have to rewrite. This increases my time for further development.
OOP in web development is also a great plus because you can keep classes and objects independent from each project, allowing you to build up a library that you can use in any project (again reusability!). this reduces the time you have to take to rebuild something you’ve done in a previous project and gives you more time to produce richer, fuller web applications.
By mike@mike-miles.com
Gone are the days where you have to write extensive, ugly javascript code to manipulate page elements and DOM. Thanks to the development of some really great javascript frameworks you can do more with less (that sounds like a line out of a Walmart commercial). The big three libraries are jQuery, Prototype (with or with-out script.tac.ulous) and mooTools. Each has its advantages and disadvantages (A major disadvantage to all three is that it’s very difficult to work with more than one at a time). Just like shopping for a new car or deli sandwich, how do you know which one is right for you?
The debate on which javascript framework to use is an even bigger then the DIV vs TABLE debate (another article for another time), and plenty of opinions have been voiced. For example, Glenn Vanderburg who runs the blog Relevance recently wrote an article (on my birthday no less) about how he prefers Prototype over jQuery.
jQuery is a very nice piece of work, and makes some common tasks easier than their Prototype equivalents. Where it’s good, it’s very good indeed. But its design is uneven, and its scope is limited. For me, at least, Prototype is still the tool of choice. I think it’s a richer, more thorough, and overall better designed library.
In his artcle (I’m not going to post the whole thing, that would be plagerism) he explains many great points for both jQuery and Prototype, along with code examples to show his opinion;
So while jQuery might be easier to get started with, Prototype grows with you better. Most web developers get started with JavaScript by doing relatively simple DOM manipulation, and jQuery really excels there. But as you get more comfortable and begin trying to do more, you may find that jQuery doesn’t help you as much. Prototype makes JavaScript programming lots of fun even in circumstances where jQuery feels constraining.
Basically he explains that jQuery is nice framework, its more for programmers who are beginner / intemediate DOM manipulators, and Prototype is for more hardcore stuff. An opinion that I can agree with having both used jQuery and Prototype in projects. For example, in my senior year of College I was part of a development team and we were building a Project Management System. We had disxcussed that we wanted it to be ajax based, and as the lead developer/programmer it was my duty to make it function smoothly. At the time I had barely any experience with major DOM manipulation except for straight up javasript. The Team leader opened me up to jQuery, which I was able to pickup fairly quickly and easily.
In another blog by Trent Richardson (trents blog) he compares jQuery and MooTools ;
Mootools has previously been known for its silky smooth effects and great dom utilities, but they also have performance on their side as well. jQuery on the other had has to have the friendliest syntax ever with chaining and selectors, with just enough effects to make you hungry for more.
MooTools does in fact have the best preformance out of the bunch, Peter Velichkov over at his blog did alot of speedtesting for each of the major frameworks (it originally inspired me to write this article) which showed across the bored mootools was the fastest preformer.
So which framework is the best?
The true answer (which you’ll probably hate) is there isnt a best one. It’s all based on circumstance, for example if you wanted something lightweight and easy to use I’d go with jQuery. If you wanted something robust and powerful I’d go with Prototype, or if you wanted something really fast I’d pick MooTools.
Another factor is ease of use. You have to figure out which is best for you depending on your programming level. jQuery (easy), Prototype (intermediate/hard), MooTools (intermediate/hard). The more comfortable you feel with the tools your using, the overall better product you’ll produce.
I personally, prefere to use jQuery simpley for its ease of use. I can write powerful javascript functions very simply and fast alowing me to get more done in a shorter amount of time.