Monday, July 12, 2010

5 Good Habits That Will Make You a Better Coder

5 Good Habits That Will Make You a Better Coder

We all want to grow in the things we do, and in the field of web development, one of the main areas that we spend a lot of time on is our code. This could include HTML, CSS, JavaScript, PHP, Python, ActionScript or any other language that you may choose to use for building websites.

In this article, I’ll share some practical steps that you can take to expand your skill set and become a better coder. I would like to propose five different habits that you can adapt in order to help yourself become more excellent at what you do.

1. Focus on One Type of Language at a Time

If you are designing and developing for the web, there are often numerous different languages that you will need to familiarize yourself with, and it can be tempting to try to learn them all at once, especially considering how interconnected they all are.

I suppose that, to some degree, this is inevitable. But if you really want to improve quickly, I recommend focusing on one particular area of expertise. Do you want to get better at using CSS? Put your focus on that. Try using a single HMTL document and creating various layouts using nothing but styles. The CSS Zen Garden is a great example of how incredibly different your web page can become for the same markup. You can also focus your efforts by finding a list of elements and working through them. For instance, if you are comfortable with CSS2, but want to improve your understanding of what is possible with CSS3, you could study CSS3 properties and start working through them one by one. You can read the current CSS3 specifications. You can experiment with each module to see what it can (and cannot) do on what browsers.

You could use a similar approach to scripting languages like JavaScript and PHP, though trying to work through all of their functions methodically might be a little tedious. Another option would be to work through a number of tutorials specifically on these languages, preferably in the specific area that you work in the most.

Do you need to become better at WordPress development? There is a ton of tutorials about that. Want to learn more about server-side image manipulation? There are tutorials for that too. Find them, bookmark them, and work through them — just don’t do it while you are also going through tutorials about CSS, HTML5, or any other web language so that you’re not spreading yourself too thinly.

Pick one and stick to it until you master it, then move on to the next.

2. Write Your Logic through Comments

When it comes to coding, there are many tenants and ideas I stand by. One of this is that code is 95% logic. Another is that logic doesn’t change when translated from human language into a programming language.

What this means is that if you can write it in code, you can write it in a spoken language like English or French.

For example, suppose that I wanted to write a function that would either lock or unlock something based on the time of day (for what reason, I’m not sure). Instead of just jumping into coding the function, I could step back and write the logic in plain English as comments.

Example

// FUNCTION: Lock On Time
// This function will accept two time values, indicating the range
through
// which it should return an unlocked status.

// Create a new data object

// Using the data object, get the current time

// IF the current time falls within the range passed to the function

// Return false – meaning that we are currently unlocked

// ELSE

// Return true – meaning that we are currently locked.

// ENDIF

// END FUNCTION

Here, we have the complete logic structure for our function, which is almost analogous to a blueprint in building a house. From here, I can then start adding in the actual code, allowing the comments to guide the process.

Obviously, this is a very simplistic example, but I do use this technique on a regular basis when I need to build a function that is notably more complex. This way, I can think through the full logic and try to iron out the wrinkles before I actually get into writing the code. I’ve found this to be an incredibly valuable habit that tends to result in fewer bugs.

As a bonus, since I will rarely actually delete the comments, writing the logic through comments also means that my code will already be documented, making it easier for others to follow my logic if they ever have to work on it, or even just for myself, if I have to come back to it several months or years down the road!

3. Study Templates, Plugins, and Open Source Code

The web is an incredibly accessible and open place, especially in the design a development communities. This disposition of the web can be a valuable resource for anyone wanting to become a better coder.

For example, if you’re really just getting started with HTML, you could download any of the innumerable free templates that exist out there on the internet, or study your favorite site’s markup. Because these templates are typically just plain HTML (and CSS, and maybe JavaScript), they’re able to work locally, giving you the opportunity to open up the source and start digging around. Play around with tags and structure to understand them better. Move things around. See what happens when you modify a style rule.

Of course, I would highly recommend coupling this experimentation with reading some solid resources about standards and best practices. After all, you don’t want to find yourself getting into bad coding habits.

This technique is probably even more useful for programmatic coding like JavaScript or PHP, which are quite a bit more complex than HTML or CSS in terms of scope and logic.

For instance, a content management system like WordPress is built almost entirely upon a foundation of various PHP scripts that all work together to establish the core functionalities. The publishing platform also supports a vast and powerful architecture for extending that core functionality, allowing you to download and install plugins that do all sorts of cool (and sometimes entirely mundane) things.

The benefit of all this is that WordPress and its plugins are entirely open source, meaning that you have complete access to all the code. So, go ahead and take advantage of this fact by digging into the plugins and poking around the code. Again, this is a great opportunity to try things and experiment.

One last word of advice on this habit: Never take the techniques or structures that you find in other people’s code as definitive (or "gospel") — be sure that you’re also trying to understand what’s going on and not just mimicking someone else’s code. Always ask why things are the way they are. Always try to consider the code as it relates to the accepted processes and standards for that particular language. Again, this will help keep you from slipping into some bad habits.

4. Read Books

While there is a ton of awesome information on various blogs out here on the web (like right here on Six Revisions), there is still nothing quite like reading a good book on a subject. Blogs are great for articles and tutorials on specific subjects and can work wonders for quick tips, but in my view, nothing beats a good book for helping to build a strong foundational understanding of a larger subject.

This has never been made clearer to me than when I finally grew tired of the table-based layouts that I had been creating in the late 90s and into the early 21st century. At that time, I finally realized that it was time for me to switch over to best practices (divs).

However, up to that point, I only had moderate success trying to teach myself how to use proper markup. I didn’t fully understand CSS selector syntax, which is such a huge part of grokking div-based layouts. As such, I really didn’t get pseudo-classes either (such as :hover), and the whole concept of specificity and inheritance meant nothing to me. The same was true of positioning and floats.

Now, I could probably have learned the language slowly, piecing together bits of information from various blogs (of which there were far fewer at the time, I might add) to form a more comprehensive picture of CSS as a whole. That would have taken a lot of time and I had jobs to do, and so I was looking for a more expedient solution.

So, I went out and bought Stylin’ With CSS by Charles Wyke-Smith. It was a revelation. In just a few short chapters, I had the basic concepts of CSS down. All those things that I didn’t even know existed were made known to me in a well-paced and organized fashion, with each chapter building on the one before. In about a day’s worth of reading, I gained the same amount of knowledge that would have taken me weeks and months to pull out of a wide assortment of articles and blog entries.

Stylin CSS

Of course, I’ve learned a lot more since then, but this single book was really the foundation of my CSS knowledge, and I still keep it on my shelf as a reference (it has a really handy appendix).

If you need to dig into a new technology from scratch, a good book is one of the best ways of going about it!

5. Experiment

The last thing that I would suggest you should get in the habit of is to just have fun. Sit down, experiment and see what you can come up with on your own.

Currently, this is a popular trend with CSS3, as different coders try to push the technology and techniques in order to discover what it is truly capable of.

Here are just a few examples of such experiments.

CSS3 Transforms & @font-face Experiment

CSS3 Transforms & @font-face Experiment

This is a really cool experiment that creates a poster-like typographical design using the @font-face CSS property, along with some shadows and the amazing rotate transform, which, when fully supported by all browsers, will open all kinds of amazing new possibilities in web design.

CSS Posters

CSS Posters

In this article over at Design Informer, Jad Limcaco experiments on creating a number of different poster designs using nothing but CSS.

Pure CSS Line Graph

Pure CSS Line Graph

There are tons of different tutorials out there that demonstrate how to create bar graphs using CSS. This one uses a different approach to visualizing data by using an actual line graph. Depending on your point of view, you might not think it’s "pure" CSS since it makes use of a giant sprite, but it’s still pretty darned cool.

CSS3 Leopard-style Stacks

CSS3 Leopard-style Stacks

This article illustrates an excellent attempt at trying to recreate a non-web effect using CSS by visually emulating one behavior from the Mac operating system. It’s pretty well done too, so check it out to be inspired.

Pure CSS Twitter Fail Whale

Pure CSS Twitter Fail Whale

Not all CSS experiments are entirely practical, of course, and this one is probably the least practical of all as it actually recreates the well-known Twitter fail whale illustration using nothing but CSS. Is it time-consuming? Yes. Is it practical? No. But it’s certainly fun and is a proof of concept of how powerful CSS is.

All of these experiments do compelling things with CSS. Some have more real-world applications than others, but I’m sure that all of their creators actually took something away from their exploration of CSS; perhaps a better understanding of the particular CSS properties they were working with or a few techniques that they will be able to apply to actual site designs.

What kind of coding experiment can you undertake? It can be a fun and effective way to learn.

Some Parting Words

So there you have it: five different habits to take on to improve your coding expertise. Not all of these will be relevant to everyone, but I hope that you will be able to find at least one habit that appeals to you.

Remember that this place called the internet is always growing and evolving. Being a great coder means a lifetime of learning and growing.

I hope you enjoy your journey.

When Designers And Developers Work Together

Even in today’s fluctuating job market, one rule that still remains constant and true is to always play to your strengths. Part of this comes from having a complete and firm grasp of your own capabilities and limitations, while part of it also comes from knowing the same about those you are working with. However, as we grow in our abilities we may begin entering a comfort zone wherein wearing every hat and attempting to take on the entire task by ourselves becomes more of a viable reality. And one that we may decide to run with.

Not saying that this is necessarily a bad thing, but there are benefits to come from specialising and allowing certain elements to be handled by others who have specialised in those areas. This dynamic is easily demonstrated with a look at the Designer and Developer. Two areas that go hand in hand, and that can be handled either as a solo effort or by pairing up with another and each taking charge of your individual roles. So if you do decide that it is in the best interests of the project to work with another in this area, then there are a few things to bare in mind so that the working relationship goes as smoothly as possible.

Headerhands in When Designers And Developers Work Together

Consider some of our previous posts:

Getting Started: Pick Your Partners Wisely

As with any work situation, there is always a certain amount of setup required to get things started and the Designer Developer partnership is not immune to this either. There are a couple of areas that will need to be addressed in order to get the project off on the right, hopefully most productive, foot. This brings us back to that old rule of thumb about playing to your strengths, and knowing those of the person or persons that you are teaming up with. If you have the say in the person you will end up tackling the project with, then you are going to want to choose them wisely to ensure the most compatible experience for you both and the overall project itself.

Not only does compatibility of character play a big part in the working relationship, but compatibility of skills also heavily ways in on the project. You want to choose this partner with great care so that both of your expectations are met and the project can have the greatest chance of success. If you are working with someone who cannot effectively accomplish through code what it is you have designed, or who cannot reasonably design a workable template to code from then the project is destined for failure. Not only that, but chances are there will be a headache or two in store for you both as well. So as you get started in this working relationship know where you are both coming from to keep the expectations reasonable and make sure they are met.

Pickpartners1 in When Designers And Developers Work Together

Communication Is Key

Overall, in any relationship in order for it to be sustainable and properly function, communication is beyond vital, and the Developer Designer ship is no exception here either. In order for it to sail correctly, the communication between the players is pivotal, and special attention should be paid to how well you are both engaging this tool. This is a make or break element in the working relationship and when speaking of the expectation levels being set and met, this element’s importance rears its head. If you are not effectively communicating with each other, then there are likely details that will be falling through the proverbial cracks before long.

Lots of developers believe that designers should have a basic understanding of code in order to keep things realistic, in fact, many believe that if you call yourself a web designer, you should know at least HTML and CSS, possibly even javascript. Thinking that at the end of the designer’s part they will be handing over completed PSD, HTML and CSS files. On the flip side, most designers expect that developers will have some basic knowledge of design theory so that when changes need to be made, they can clearly communicate them. So there is a give and take with regards to the expectations on both sides, and without being able to convey them on both sides, there is bound to be some ball droppage.

Tips for Effective Communication

  • Always be as concise as possible, so as to not confuse the issue.
  • Know the terminology from the opposite field, so neither of you is talking over the other’s head.
  • Always check that you are both on the same page about an issue before you move on to discussing something else. Never take understanding for granted.
  • Always be patient.
  • If you have questions, then ask them. Do not worry about how you may look asking for clarification. Better to know up front and do it right the first time.

Have A Grasp Of UX

When speaking of expectations, there is another important group who will also be placing a certain number of them on the project as well, beyond any client, and that is the end user. It is important that both the Designer and Developer have an understanding of UX, and keep that experience in mind as you proceed with your project. Those who will be interacting with the completed product and their satisfaction with the project are what matter most afterall. It is the feedback from this end of the experience that tends to determine the success or failure status of the project.

The users are the ones that the product is essentially being designed and developed for, so in the end, it is their experience that you are working to create and crafting so losing focus on this endgame for one moment during the process can have negative and lasting impacts. Beyond anything else, the UX is what will win the game or lose it for you, so when you partner with someone you will want to be sure that this understanding is part of their collective knowledge base as well. If this is not affixed to their arsenal or yours, then there are definitely some more prepatory steps that need to be taken before any serious work on the project begins.

UX Tips From the Blogosphere

Here are a few links to help you further your base on UX matters:

Learn The Value Of Compromise

Another thing to keep in focus when working with someone in this capacity is that the project, end user, and client are what ends up mattering over either the Designer or Developer and the potential ego that may be associated with them. Ego is not necessary in this process, and can act as a hindrance rather than a helper so as you take on a task with another you will want to check your ego at the door. This is not to say that you have to become any sort of doormat and allow your partner to walk all over you, making every critical call in the project, just that you should learn the value of compromise.

When you are working alone, compromise is generally not something we are used to until we show the project to the client. However, when you are working as a part of a team, the steps leading up the presentation to the client may be paved with compromises all along the way. If you are not great at handling them then there is a chance that things can sour early on, and the relationship will suffer, hence the project will in turn suffer. When we deal with the client, making that compromise is easier because they pay the bills, but still we make the case for why the client should bend to our will. So making that compromise in the Designer Developer relationship can be trickier to manage.

Compromising Tips

Even subtle concessions can go a long way in showing a willingness to work together, so below are a couple of ways that you can work at the compromsing element of the Designer Development relationship.

  • Keep the goal in mind as you work together to hammer out the details. If any questionable element does not recognizably serve the goal let it go.
  • Make sure that when choosing your project partner that it is someone who knows how to, not only compromise, but to approach the issue respectfully and tactfully. You should reciprocate this behavior.
  • Try to find a way to frame every compromise as a win/win scenario for the end product so it is less like someone is giving in and more like you are working together to raise the bar.
  • Be sure that you are open to the criticisms offered and compromises asked of you, and never let them put you in a defensive place, because then dialogs tend to degrade from there.

Final Thoughts

We will not always get to choose our coworkers, but when we can we should aim in these directions to make sure that our partner turns out to be as compatible as possible. We also want to be sure that we make adjustments to any lone wolf mentalities that we are bringing into the working relationship so that we are not the proverbial wrench gumming up the works.

Some Final Tips for the Road

  • Designers should use a wireframe to get going and then be sure to consult with the developer before moving on.
  • Designers need to be sure to create clean and organized PSD files so that the developer does not have to clean up your work before they can begin.

Further Resources

Below are some articles for further reading on the working relationships between developers and designers for your consideration.

Friday, July 9, 2010

Advanced CSS3 Box Shadow Techniques

We’re very close to the launch of Think Vitamin Membership, so I wanted to give you a preview of the kind of video courses that will be available.

Freeze frame from the intro of the video, showing a hand poking a  vitamin bottle

Here is a five minute video that will teach you some advanced CSS3 Box Shadow techniques. We will be adding 70+ videos like this per month to the Think Vitamin Membership Training Course Library.

As a little treat, the next 10 people to signup at membership.thinkvitamin.com will receive 50% off their first month. Yay!

screengrab from CSS3 Advanced Box Shadow video