Every programmer has probably done code refactoring at least once in their lifetime. It's not something that they enjoy doing but it must be done in order to keep the program up-to-date or with new features being added. The best way to reduce the amount of refactoring is to write clean code. Doing it right the first time reduce the amount of work you will have to do in the future. It might take longer the first time to write clean code compare to sloppy code, but the extra time spent doing it will save countless hours of refactoring in the future.
As a student programmer, we tend to write quick sloppy codes that satisfy the requirements of the program. That's because we tend to have the mentality of writing the code once, get a passing grade, and we'll never have to look at it again. This practice is "okay" in an academic sense, but its a failure as a programmer in the real world. Codes produce in the real world are constantly being reviewed, reused, and refactored by yourself and others. So save yourself time, stress, and humiliation by doing it right the first time around.
If your a java programmer, I recommend getting or reading "The Elements of Java Styles". Its a great book that gives pointers on writing clean Java codes. I'm sure that there are similar books for other programming languages that you could read to improve on writing cleaner codes.
Wednesday, May 5, 2010
Friday, April 30, 2010
More than one way to skin a cat or webpage
If you haven't heard of the saying "More than one way to skin a cat", it pretty much means that there are more than one way to do something, or that there are several possible ways of achieving something. This saying cannot be more true in terms of web designs. Web designing methods are constantly changing as new languages and technologies come out. The once popular table layouts are quickly being replaced by the use of CSS.
Even within CSS, there are multiple ways of creating the same layout and style. This is mainly due to new implementations within the language. Majority of current CSS layout on the web are column-like created by using the "float" property in CSS2. With the development of CSS3, it introduces a new box model called "flexible box model". This new box model is optimized for fluid design. The children within the box are laid out either horizontally or vertically, and unused space can be assigned to a particular child or distributed among the children allowing for easy expansion.
The latest "skin"(theme) I made for my current CSS project is a UNLV (University of Las Vegas) theme. The layout that I followed was the one on their main page: www.unlv.edu. For this theme, instead of using the usual float property to create the layout, I used the flexible box model from CSS3. Because CSS3 is still in the development phase, this feature is still experimental and requires browser specific tags. Even with these tags, its still sometimes glitchy and requires you to refresh your browser a few times until you see the changes. And this feature is not supported at all with Internet Explorer, so if I can't get it to work atleast 100% on the other main browsers (Firefox, Safari, Chrome), I will probably change the layout back to using the stable float property.
Below is a screenshot of my UNLV theme for the Dorm Energy Competition.
If you want to find out more about the flexible box mode, check out these sites:
future of CSS: the flexible box model
flexible box model specifications on w3.org
Even within CSS, there are multiple ways of creating the same layout and style. This is mainly due to new implementations within the language. Majority of current CSS layout on the web are column-like created by using the "float" property in CSS2. With the development of CSS3, it introduces a new box model called "flexible box model". This new box model is optimized for fluid design. The children within the box are laid out either horizontally or vertically, and unused space can be assigned to a particular child or distributed among the children allowing for easy expansion.
The latest "skin"(theme) I made for my current CSS project is a UNLV (University of Las Vegas) theme. The layout that I followed was the one on their main page: www.unlv.edu. For this theme, instead of using the usual float property to create the layout, I used the flexible box model from CSS3. Because CSS3 is still in the development phase, this feature is still experimental and requires browser specific tags. Even with these tags, its still sometimes glitchy and requires you to refresh your browser a few times until you see the changes. And this feature is not supported at all with Internet Explorer, so if I can't get it to work atleast 100% on the other main browsers (Firefox, Safari, Chrome), I will probably change the layout back to using the stable float property.
Below is a screenshot of my UNLV theme for the Dorm Energy Competition.
If you want to find out more about the flexible box mode, check out these sites:
Wednesday, April 21, 2010
CSS+List=Easy Navigation
Have you ever gone to a website to find a specific information that you know is on that site, but was unsuccessful or took a very long time to find it due to poor site navigation? It's quite the shame when a website has a lot of useful information on it but has poor usability due to its navigation. Have designers forgotten that a successful website requires a good navigation menu?
Navigation menus are not that hard to make as one may think. One good and easy approach that I've found is to use a list. Yes, all you need to use is a plain old unordered list and a bit of CSS to make a simple yet effective navigation menu. You can even make advance menus such as multi-layer and drop-down menus using nested lists.
Using the simple HTML unordered list below:
you can create a horizontal or vertical navigation menu with some simple tweaks on the CSS scripts. This is called the "Suckerfish Drop-downs".
Rather than me explaining how this works, you can check out the original post on creating a Suckerfish Dropdowns. This post takes you step-by-step explaining what each step does. Any beginners can easily follow these steps to create their very own navigation menu.
So there you have it folks. There is absolutely no excuse for having poor navigation on any website.
Navigation menus are not that hard to make as one may think. One good and easy approach that I've found is to use a list. Yes, all you need to use is a plain old unordered list and a bit of CSS to make a simple yet effective navigation menu. You can even make advance menus such as multi-layer and drop-down menus using nested lists.
Using the simple HTML unordered list below:
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">Resources</a>
<ul>
<li><a href="#">Dorm Energy</a></li>
<li><a href="#">Energy Hub</a></li>
<li><a href="#">Have Fun</a></li>
</ul>
</li>
<li><a href="#">Energy Data</a>
<ul>
<li><a href="#">Real-Time</a></li>
<li><a href="#">Hour</a></li>
<li><a href="#">Day</a></li>
<li><a href="#">Week</a></li>
<li><a href="#">Month</a></li>
</ul>
</li>
<li><a href="#">Billboard</a></li>
<li><a href="#">About</a></li>
</ul>
you can create a horizontal or vertical navigation menu with some simple tweaks on the CSS scripts. This is called the "Suckerfish Drop-downs".
Rather than me explaining how this works, you can check out the original post on creating a Suckerfish Dropdowns. This post takes you step-by-step explaining what each step does. Any beginners can easily follow these steps to create their very own navigation menu.
So there you have it folks. There is absolutely no excuse for having poor navigation on any website.
Wednesday, April 14, 2010
CSS: Reaching a milestone of web design
For the last month, I've been working on a CSS project to create different themes for the Dorm Energy Competition webpage. CSS was fairly new to me and as I began to learn more about the language, I realize that this simple language is packed with powerful styling capabilities. As a person who learns best from hands-on experience, I jumped right into it to create my first theme, the "Dark" theme. I tried to apply what I've learned from the tutorials to create a theme that pleasing and reflects my creativity. Below is the outcome of my first attempt.
I was quite please with it until after I reviewed the design of a similar website for Saunders Hall Energy Competition. After seeing some of the design pitfalls on that website, I realized that my theme also contains similar pitfalls. I have always been a person that focus on function over form, but have I lost myself in this overwhelming power called CSS?
Luckily it was just a momentary lapse of judgement, so I quickly fixed the over sized menu images and background image to give more screen real estate for the content. Here final result of the dark theme. (There was an empty space so my creative side told me to add the door background image for more effect.)
Feeling that the Dark theme is presentable as is, I wanted to move on to my next theme. I decided to do a "Windmill" theme similar to the one for our T-shirt/button design, but for this design I wanted to incorporate a minimalist design. Something that looks clean and simple yet follows the theme. Here is the result of the Windmill design:
I am quite please with this theme and thought it looked a lot better than the Dark theme. It is clean and simple and everything played well together for the theme. I got pretty lucky finding images on the web to fit into the theme with very little editing of it. All editing was done using Paintbrush, a Mac version of MS Paint.
I realized that image editing plays a major role in CSS designs. In order to use CSS to its fullest, you will need to have right images or image editing skills to create such images. Many images on the web have copyright watermarks on them, making them unusable. Half of the time I spent was looking for and editing images.
For now I feel like I have reached a milestone as a web designer, graduating from a complete newbie to maybe an amateur/average designer. Thank you for following me on this first half of my journey and look forward to the second half.
I was quite please with it until after I reviewed the design of a similar website for Saunders Hall Energy Competition. After seeing some of the design pitfalls on that website, I realized that my theme also contains similar pitfalls. I have always been a person that focus on function over form, but have I lost myself in this overwhelming power called CSS?
Luckily it was just a momentary lapse of judgement, so I quickly fixed the over sized menu images and background image to give more screen real estate for the content. Here final result of the dark theme. (There was an empty space so my creative side told me to add the door background image for more effect.)
Feeling that the Dark theme is presentable as is, I wanted to move on to my next theme. I decided to do a "Windmill" theme similar to the one for our T-shirt/button design, but for this design I wanted to incorporate a minimalist design. Something that looks clean and simple yet follows the theme. Here is the result of the Windmill design:
I am quite please with this theme and thought it looked a lot better than the Dark theme. It is clean and simple and everything played well together for the theme. I got pretty lucky finding images on the web to fit into the theme with very little editing of it. All editing was done using Paintbrush, a Mac version of MS Paint.
I realized that image editing plays a major role in CSS designs. In order to use CSS to its fullest, you will need to have right images or image editing skills to create such images. Many images on the web have copyright watermarks on them, making them unusable. Half of the time I spent was looking for and editing images.
For now I feel like I have reached a milestone as a web designer, graduating from a complete newbie to maybe an amateur/average designer. Thank you for following me on this first half of my journey and look forward to the second half.
Wednesday, April 7, 2010
Background: Personalization and more...
Like most people, we like to personalize our own belongings to make it feel like "us". Something that will make it unique and distinguish it from the rest. What is the first thing you do to personalize your computer? Well, the first thing that most people and I tend to do is change the default wallpaper or background to personal picture or a picture that reflex us.
With personal home pages and social networking sites becoming so popular, everyone is jumping on the bandwagon. So is just changing the background on your page good enough to make it feel like you? Well, the answer is yes and no. If you just changing the background to a different image, it doesn't really speak much about you. But don't worry, with a bit of CSS, you can create multiple effects just by using the background.
One bad thing about web designing in the past was that everything we create has a boxy look, so web designers has gone to great lengths to create rounded-conrners. With CSS, rounded corners can be create by using rounded-corner images for the top heading and footer background. This method does the job but it was a painful because you will have to create the rounded-corner images to match the content and add nonsemantic markup to your code.
Another effect you can do using the background is to add the drop shadow effect. This method will need you to create a "drop shadow" image similar to the one below and using it as a background with its position set to "bottom right". Quite troublesome but it does the job.
Well, thanks to CSS3 you don't have to go through all that trouble just to create rounded-corners and drop shadows. The new "border-radius" property allows you to create rounded-corners just by setting the radius of the borders. But because it's still a new feature you will need to add add prefixes for browser-specific.
This can be done by adding " -moz-border-radius: 1em; -webkit-border-radius: 1em; border-radius: 1em; " to the CSS. And for the "drop shadow" effect, you can use the "box-shadow" property.
This can be done by adding " box-shadow: 3px 3px 6px #666;" to the CSS.
The last effect I want to go over is the Opacity property which can give your design an extra dimension. This can be done by adding "opacity: 0.8;" to the CSS where "0.8 = 80% opacity.
Below are some screenshot from my current project using these effect. It's still unfinished and I'll be making many changing to it to make it more "pleasing to the eyes".
In this screenshot, you can see that I used a dark image for background and a lightbulb as the background for each menu selection to go with the "dark" theme.
Here is another screenshot of the bottom of the page:
In this screenshot, you can see the use of the rounded corners and the drop shadow effect at the bottom of the content box. The background of content box also has an opacity effect on it so the background image of the webpage will not get covered when you resize the browser window.
It's currently not that great of a design so as i learn more about CSS and continue to work on this, I will show you the new changes.
Reference: "CSS Mastery Advanced Web Standards Solutions Second Edition"
With personal home pages and social networking sites becoming so popular, everyone is jumping on the bandwagon. So is just changing the background on your page good enough to make it feel like you? Well, the answer is yes and no. If you just changing the background to a different image, it doesn't really speak much about you. But don't worry, with a bit of CSS, you can create multiple effects just by using the background.
One bad thing about web designing in the past was that everything we create has a boxy look, so web designers has gone to great lengths to create rounded-conrners. With CSS, rounded corners can be create by using rounded-corner images for the top heading and footer background. This method does the job but it was a painful because you will have to create the rounded-corner images to match the content and add nonsemantic markup to your code.
Another effect you can do using the background is to add the drop shadow effect. This method will need you to create a "drop shadow" image similar to the one below and using it as a background with its position set to "bottom right". Quite troublesome but it does the job.
Well, thanks to CSS3 you don't have to go through all that trouble just to create rounded-corners and drop shadows. The new "border-radius" property allows you to create rounded-corners just by setting the radius of the borders. But because it's still a new feature you will need to add add prefixes for browser-specific.
This can be done by adding " -moz-border-radius: 1em; -webkit-border-radius: 1em; border-radius: 1em; " to the CSS. And for the "drop shadow" effect, you can use the "box-shadow" property.
This can be done by adding " box-shadow: 3px 3px 6px #666;" to the CSS.
The last effect I want to go over is the Opacity property which can give your design an extra dimension. This can be done by adding "opacity: 0.8;" to the CSS where "0.8 = 80% opacity.
Below are some screenshot from my current project using these effect. It's still unfinished and I'll be making many changing to it to make it more "pleasing to the eyes".
In this screenshot, you can see that I used a dark image for background and a lightbulb as the background for each menu selection to go with the "dark" theme.
Here is another screenshot of the bottom of the page:
In this screenshot, you can see the use of the rounded corners and the drop shadow effect at the bottom of the content box. The background of content box also has an opacity effect on it so the background image of the webpage will not get covered when you resize the browser window.
It's currently not that great of a design so as i learn more about CSS and continue to work on this, I will show you the new changes.
Reference: "CSS Mastery Advanced Web Standards Solutions Second Edition"
Tuesday, March 30, 2010
CSS: The Good And The Bad
If you didn't know by now, Cascading Style Sheet (CSS) is a very powerful tool for web design. So with any great power, comes great responsibilities. Sadly misuse and improper use of such power happens very often with beginners. So after going over some of the online tutorials and reading some of the tips and tricks of CSS, I want to share some of my findings with you, which will hopefully reduce some of the bad habits and instill some good ones.
Separate CSS from Code
First off, CSS can be use in three ways: Inline, embedded, and external. External CSS is the preferred choice because all pages in your website with similar elements can have the same style from one single CSS file. Embedded CSS is place in the head tag of the HTML file, and applies styling only to that page. Inline CSS is just like HTML styling where it's place inline with the element code. This method should be avoided because it only applies style to that one element. Inline CSS are typically used for testing.
Minimal Work
Writing less code reduces the amount of work and makes it easier to maintain. HTML should be marked up using the most appropriate tags for the content, reducing the use of "id" and "class". This in turn will minimize the amount of CSS need.
One way of minimizing CSS is to let the hierarchy do some of the work for you. Applying style to top level such as the body tag will let all content on that page inherit the styling. Another way is to group selectors that use the same style by putting them on one line using the same rule. Lastly, learning some CSS shorthand will reduce the amount of time and code needed.
Blast from the Past
Tables are the thing of the past and should not be use for design purpose. Rather than using tables, you should use div instead. If you are converting from table to div, you should know that div tag is a block-level element that defines a section, thus it should be use correctly and not overused.
Declaring font size by using pixels is still commonly used but should also be avoided because with the varieties of screen size and resolution being used today, having a fixed font size will different effects on different resolutions. Instead, try declaring font size using the em unit such as 1em or 1.5em. This practice allows easy changing of your entire site's font size by simply changing the BODY tag’s (or any other container tag’s) font-size property.
Validate your work
Last but not least, make sure you always validate your pages using both the HTML validator and the CSS validator. Using these validators will ensure you that you are following the standards.
Well, after browsing the web to find some good examples of CSS that I could use for my current project, Here are some sites that I think we all could get some ideas from:
www.ndesign-studio.com adds personality and flare while keeping it simple.
www.carbonica.org nicely incorporate images relating to the theme into the menu and links. Also divides the page into columns which I find to increase usability.
www.yellowstonepark.com contains drop-down sub menu when you hover over each main menu choice, which I feel that it makes navigating to a specific page much quicker and easier.
foxie.ru was list as a good design but after looking at the source code, I found that the site was done completely using tables, which in turns makes it a bad design. The artistic value is there but they completely threw usability and maintainability out the window.
Following these guidelines will not make you the best web designer, but will guide you down the right path....
Reference:
8 Common CSS Mistakes
How to Develop with CSS
15+ CSS Tips and Tricks
Table vs. Div
Separate CSS from Code
First off, CSS can be use in three ways: Inline, embedded, and external. External CSS is the preferred choice because all pages in your website with similar elements can have the same style from one single CSS file. Embedded CSS is place in the head tag of the HTML file, and applies styling only to that page. Inline CSS is just like HTML styling where it's place inline with the element code. This method should be avoided because it only applies style to that one element. Inline CSS are typically used for testing.
Minimal Work
Writing less code reduces the amount of work and makes it easier to maintain. HTML should be marked up using the most appropriate tags for the content, reducing the use of "id" and "class". This in turn will minimize the amount of CSS need.
One way of minimizing CSS is to let the hierarchy do some of the work for you. Applying style to top level such as the body tag will let all content on that page inherit the styling. Another way is to group selectors that use the same style by putting them on one line using the same rule. Lastly, learning some CSS shorthand will reduce the amount of time and code needed.
Blast from the Past
Tables are the thing of the past and should not be use for design purpose. Rather than using tables, you should use div instead. If you are converting from table to div, you should know that div tag is a block-level element that defines a section, thus it should be use correctly and not overused.
Declaring font size by using pixels is still commonly used but should also be avoided because with the varieties of screen size and resolution being used today, having a fixed font size will different effects on different resolutions. Instead, try declaring font size using the em unit such as 1em or 1.5em. This practice allows easy changing of your entire site's font size by simply changing the BODY tag’s (or any other container tag’s) font-size property.
Validate your work
Last but not least, make sure you always validate your pages using both the HTML validator and the CSS validator. Using these validators will ensure you that you are following the standards.
Well, after browsing the web to find some good examples of CSS that I could use for my current project, Here are some sites that I think we all could get some ideas from:
www.ndesign-studio.com adds personality and flare while keeping it simple.
www.carbonica.org nicely incorporate images relating to the theme into the menu and links. Also divides the page into columns which I find to increase usability.
www.yellowstonepark.com contains drop-down sub menu when you hover over each main menu choice, which I feel that it makes navigating to a specific page much quicker and easier.
foxie.ru was list as a good design but after looking at the source code, I found that the site was done completely using tables, which in turns makes it a bad design. The artistic value is there but they completely threw usability and maintainability out the window.
Following these guidelines will not make you the best web designer, but will guide you down the right path....
Reference:
8 Common CSS Mistakes
How to Develop with CSS
15+ CSS Tips and Tricks
Table vs. Div
Friday, March 19, 2010
CSS: Magic of web design
Have you ever wonder how some webpages look so nice while others just look like plain text? If you said it was because it was done professionally using expensive web design software, well you're partially correct. Any novice web designer (like me) can make webpages that are presentable without the need of any special software. All we need to learn in conjunction with HTML is another markup language called CSS (Cascading Style Sheets). Currently, CSS is the most used method for styling websites and for good reasons. CSS is fairly easy to learn, works great with most browsers (minus earlier versions of Internet Explorer, but who really uses IE by choice?), and contains numerous styling functionalities. And the best part it, It doesn't cost you a penny. Here is a before and after picture of a website with and without CSS.
Without CSS:
With CSS:
There are numerous tips and tutorials online where you can learn CSS without the need of a textbook. A great beginner's tutorial for CSS can by found on w3schools.com. And if you never made a webpage before, you might want to check out their HTML tutorial before hand.
The next project that I'll be on will be involving CSS. Kelli and I will be working on George's Pinax website for UH Dorm Energy. For this project we will be creating different layouts and themes for the website to eventually find the best design for it. But like every design, we will of course keep functionality and usability in mind. As I learn more about CSS, I hope to be able to create websites that will look as stunning as the examples on CSS Zen Garden.
We're both fairly new to CSS so we'll be going through some of the online tutorials and probably look at other website designs that we think we could incorporate into the UH Dorm Energy website.
For more tips and tricks on CSS, take a look at Philip Johnson's CSS bookmarks.
Without CSS:
With CSS:
There are numerous tips and tutorials online where you can learn CSS without the need of a textbook. A great beginner's tutorial for CSS can by found on w3schools.com. And if you never made a webpage before, you might want to check out their HTML tutorial before hand.
The next project that I'll be on will be involving CSS. Kelli and I will be working on George's Pinax website for UH Dorm Energy. For this project we will be creating different layouts and themes for the website to eventually find the best design for it. But like every design, we will of course keep functionality and usability in mind. As I learn more about CSS, I hope to be able to create websites that will look as stunning as the examples on CSS Zen Garden.
We're both fairly new to CSS so we'll be going through some of the online tutorials and probably look at other website designs that we think we could incorporate into the UH Dorm Energy website.
For more tips and tricks on CSS, take a look at Philip Johnson's CSS bookmarks.
Subscribe to:
Posts (Atom)