Help your business Web app succeed by using standard coding practices and CSS, keeping the site’s purpose top of mind, testing, and fixing errors
Editor’s note: This article is excerpted from chapter 14 of Developing Business Applications for the Web: With HTML, CSS, JSP, PHP, ASP.NET, and JavaScript, by Laura Ubelhor and Christian Hur.
There are a number of things to keep in mind to help make your website more effective and productive. Some of these best practices include keeping the site’s overall purpose in mind, using a clear and easily maintained folder structure, and avoiding cutting-edge techniques. This article takes a closer look at these best practices.
1: Focus on the Site’s Objective
When designing your site and Web applications, keep the focus on your business and technical objectives for the website. Don’t add components and content needlessly. A high-quality site should meet the following criteria:
- Offer site visitors what they want and need.
- Be up to date.
- Load and perform quickly.
- Be easy to use.
- Be simple.
If your site has too much content, slow-loading pages, is hard to use, does not provide current information, or does not provide what visitors are looking for, not only will visitors have an unfavorable experience, but you will also increase the potential for unfavorable results due to browser differences.
2: Structure Your Site
Keep your site’s file structure simple. Don’t haphazardly structure your site files or use no structure at all. This is especially critical for larger sites, but it is also important for small ones. It is easy to have a Web application’s structure get out of hand and become disorganized. Create a simple site structure to easily organize the components of your site. Use simple, meaningful filenames. For example, if you have a logo image, you might name the file Logo.jpg. Similarly, your “about us” Web page might be named AboutUs.html. Let’s consider a site with the following components: HTML, CSS, JavaScript, images, and document files.
The example in Figures 1 and 2 is simplistic, but the message is clear: organizing your files in a simple structure makes it easier to locate them. If you put all your image files in an “images” folder, then you know any code that references an image file will use the format images/imagefilename.xxx.
C:\BelhurSite
Abc.html
Abc.js
Abc.jpg
BBQ.html
CC.html
CC.jpg
CC.doc
DD.doc
Figure 1: Unstructured site files
ABC.html
BBQ.html
CCC.html
\JSFiles
Abc.js
CC.js
\Images
ABC.jpg
CC.jpg
\Docs
CC.doc
DD.doc
Figure 2: Structured site files
When defining path-naming and file-naming conventions, remember that Windows is not case sensitive, but other operating systems are. For example, Windows would deem \Images and \images to refer to the same folder, but some other operating systems would not.
The design of your site and applications is critical. The more complex your site and applications, the more important it is to have a great design. The time and effort spent up front on design will result in a good end product and will also save you support time in the long run. Incorporate the file-structure definition and file-naming conventions as a part of your development standards.
3: Avoid the Cutting Edge
It can be very tempting to use cutting-edge coding techniques. However, “cutting edge” can also mean “bleeding edge”; such techniques may end up causing unforeseen problems or be difficult to maintain or support. Be careful to choose your coding techniques and tools wisely. Choose proven tools that fit your business needs.
When choosing your Web development tools, don’t reinvent the wheel. Research available tools before committing to a particular tool or set of tools. Also keep in mind the browsers you’ll be developing a website or Web application for, and make sure your tools will work well on all those browsers. Choose tools and technologies with a track record and proven capability for use in Web development—tools like JavaScript, PHP, JSP, .NET, HTML, and CSS. It is likely you’ll use a combination of these.
Do not lose sight of your goal. Code to fit your application requirements, not to use technology for the sake of trying something new. If your company objective is to only use cutting-edge technology, be prepared to spend more time, money, and other resources on Web application development.
4: Use CSS
Use only Cascading Style Sheets (CSS) for layout consistency and put the CSS in files that all pages share. Browsers have many properties whose default values are not defined in the specifications, and these properties can vary from browser to browser. You should, therefore, specify CSS properties fully to prevent differences in browser defaults. For example, default margins and padding are not defined in the specifications and may differ for different browsers; to ensure consistent results, your CSS should set both. Make sure designers and application developers work together in developing the CSS and consider the business application requirements when you create your style sheets.
You might need to use different CSS code for different browsers and possibly for different versions of browsers. You can do this by detecting the version of the browser and coding to point to the CSS file designed for it.
5: Address Coding Issues
Coding errors are one of the leading causes of browser display problems. Making sure your code is error-free can have the biggest impact on preventing problems because of browser differences. Poor code can affect a page’s look, performance, and errors encountered. Poorly coded sites will result in browser issues.
Use well-formed HTML. Tags should be nested properly. No end tags should be omitted. Some browsers will not display your site as desired if the HTML is not well-formed. The same applies to script and program code. You might want to use a code checker to identify and make corrections. Code checkers warn about irregular or faulty code.
Don’t assume there are no coding errors in a page that appears correct. Some errors might not be obvious when you test your work. A browser that does not conform to the standards may produce the wrong results. Some browsers, most notably IE, try hard to recover from errors gracefully by guessing what the designer intended, which covers up errors. Often, the first sign of a problem with your code is that your page doesn’t look right when viewed a different browser or an updated browser. This also applies to Web application programming. Integrated development environments (IDEs) and other development tools like Dreamweaver, Eclipse, Komodo IDE, Microsoft Expression, Notepad++, Zend Studio, and many others can flag or help you avoid errors in your PHP, HTML, JSP, JavaScript, and .NET coding.
6: Use Accepted Coding Standards and Techniques
Every programmer has his or her favorite coding techniques. Whatever your preferred coding methods, make sure you create code being mindful that someone else might have to maintain the application. Following accepted coding standards will minimize inconsistencies in code written by different programmers and will make it much easier to maintain and support the application in the future. This advice applies whether your organization is new to Web development or is experienced. The time spent on standards up front will minimize development and support requirements later.
When creating new pages or changing existing pages, do your work one step at a time, and after each change, verify that the code works as intended. This approach makes it easier to develop and test your work. If a new problem appears, you know that it is caused by what you have just done. Therefore, you only have to review the little bit of work since your previous step. This process is called incremental development. Making massive changes before testing any of them can make testing and debugging a time-consuming and frustrating task.
7: Test the Website and Code
Testing is a critical part of your Web project, just as it would be in any other application development project. This step should not be skimped. The goal of testing is to find any fundamental flaws in the design, to identify coding errors, and to ensure that your site displays as expected for your audience. The test plan should include testing of all pages in your website. If you have a large, complex site, we recommend that you complete the first round of testing after only a few pages have been coded. Initial testing will identify design flaws early on and minimize the time required to address them.
Testing needs to be comprehensive, and testers should try hard to make the design fail. A well-designed test plan will uncover flaws well before your audience views your site and Web applications. Test first with the browser most commonly used by your audience. After you are satisfied with your test results, move on to test the rest of the browsers your site will support. You might want to incorporate the use of automated tools to validate and test your site. As discussed earlier, a variety of automated tools are available, including code validators and checkers. The expense of such tools may well be justified by minimizing coding errors and saving time testing a large, complex site. Testing should not be considered complete until the problems identified have been corrected and retested.
Consider your tolerance for defects. It would be easy to say that you have zero tolerance for errors, but this is not practical, taking into consideration browser differences. If your website caters to a small or informal audience, your bug tolerance will be much higher than if your website represents your company to the public. The purpose and audience of your site will likely provide the key to determining your tolerance for errors and defects. You will have to consider how large an audience you will support and how much expense you are willing to expend to support it.
Make a formal test plan. Use your list of browsers, settings, hardware, and operating systems as a test checklist, as shown in Table 1. Incorporate the test plan as part of your standard development procedures. The test plan should be designed so it can be used for new development and for site changes. The test plan should include a detailed identification of the problems encountered, with planned actions to be taken to correct the errors.
Table 1: Test Plan Support Example |
||||
Browsers Supported |
Operating Systems Supported |
Monitor Resolution Supported |
Monitor Size Supported |
Connection Speed Supported |
Chrome |
Windows 8 |
800 x 600 |
17” |
Cable Internet |
Firefox |
Windows 7 |
1024 x 768 |
19” |
DSL |
IE |
Windows 10 |
1366 x 768 |
14.1” |
3G/4G Wireless |
Safari |
Apple Mac OS. 7.0.2 |
1280 x 1024 |
18.4” |
Satellite |
Opera |
Windows 8.1 |
1366 x 768 |
15” |
DSL |
Summary
Web design projects have some similarity to traditional application design projects. There is no substitute for good planning, design, documentation, and testing. Developing and following coding standards improves your ability to create functional and easily maintained websites. Be sure to test your Web pages with the most common browsers. Also test them with the most common screen resolutions. We highly recommend using both CSS and JavaScript to extend the capabilities of your website and to make it easy to maintain.
About the Authors
Laura Ubelhor owns and operates Consultech Services, Inc., a Rochester, Michigan-based technology consulting company. She is an author of HTML for the Business Developer (MC Press, 2008) and many technology articles. She also helped write the COMMON certification RPG and Business Computing Professional exams.
Laura has been involved in the Southeast Michigan iSeries User group since 1988, and has served as group president for over 15 years and as lead organizer for the group’s annual MITEC conference. She is also a longtime volunteer for COMMON, the IBM i and Power Systems user group, and has spent much of her career advocating for IT professional education.
Christian Hur is an IT-Web Instructor at Gateway Technical College in Racine, Wisconsin, where he teaches courses in Web Development and Microsoft SharePoint. Christian also manages Gateway’s Ubuntu (Linux) Web server, which runs on an IBM Power 8. Christian has a BLS from the University of Wisconsin-Oshkosh and is an MSCIS candidate at Boston University.
Christian has more than 20 years’ experience in Web development and has built many websites and Web applications using HTML, CSS, JavaScript, PHP, and ASP/ASPX. He has managed dedicated Web servers and maintained websites using various CMS applications. He is also an entrepreneur who cofounded two companies.
LATEST COMMENTS
MC Press Online