A Guide for Developers: Avoiding the Top 10 Mistakes Made by Web Developers

The evolution of web application development since the term World Wide Web emerged in 1990 has been remarkable. What began with serving static HTML pages has transformed into the creation of dynamic and intricate business applications.

Today, a wealth of resources, both digital and printed, offer comprehensive guidance on building diverse web applications. Development environments have advanced significantly, now capable of detecting and rectifying errors that once plagued early developers. We’ve even witnessed the rise of platforms that effortlessly convert basic HTML pages into highly interactive applications.

Despite their variations, these development approaches, practices, and platforms share fundamental principles. Consequently, they remain susceptible to similar challenges inherent in the nature of web applications.

This guide aims to illuminate prevalent errors encountered throughout the web development lifecycle, ultimately helping you refine your skills. It touches upon universal concepts relevant to nearly all web developers, including validation, security, scalability, and SEO. While the specific examples provided offer insights into potential pitfalls, they should not be considered exhaustive.

Common Mistake No. 1: Inadequate Input Validation

Validating user input on both the client and server sides is absolutely essential! While the adage “don’t trust user input” is well-known, mistakes related to validation remain surprisingly common.

One of the most frequent repercussions of this oversight is SQL Injection, a vulnerability that persists in OWASP Top 10 year after year.

Fortunately, most front-end frameworks offer readily available validation rules that are incredibly user-friendly. Similarly, major back-end platforms employ simple annotations to ensure submitted data conforms to predefined standards. Although implementing validation can be time-intensive, it’s a crucial aspect of good coding practices that should never be neglected.

Common Mistake No. 2: Authentication Without Proper Authorization

Before delving further, let’s ensure a shared understanding of two key terms, as defined in the 10 Most Common Web Security Vulnerabilities:

Authentication: Confirming the identity (or at least the apparent identity) of an individual by verifying their provided security credentials (password, answers to security questions, fingerprint scan, etc.).

Authorization: Verifying that a specific user possesses the necessary permissions to access a particular resource or perform a specific action.

In simpler terms, authentication is about knowing “who” someone is, while authorization focuses on what a verified entity is allowed to do.

Let’s illustrate this concept with an example:

Imagine your browser storing currently logged-in user information in an object resembling the following:

1
2
3
4
5
{
    username:'elvis',
    role:'singer',
    token:'123456789'
}

During a password change process, your application makes the following POST request:

1
POST /changepassword/:username/:newpassword

Within your /changepassword method, you confirm the user’s logged-in status and ensure the token hasn’t expired. Subsequently, you retrieve the user profile using the :username parameter and proceed to update the password.

The process appears sound, right? Sadly, no!

A critical step is missing: verifying that the user initiating the action and the user whose password is being changed are indeed the same person. Bear in mind that information stored in the browser can be manipulated. A tech-savvy individual could easily modify username:'elvis' to username:'Administrator' using nothing more than standard browser tools.

In this scenario, we’ve addressed Authentication by confirming the user’s provided credentials. We could even enhance security by restricting the /changepassword method to Authenticated users. However, these measures alone are insufficient to safeguard your users from malicious activity.

It’s imperative to validate the actual requestor and request content within your /changepassword method. Implementing robust Authorization is key, ensuring that users can only modify their own data.

Remember, Authentication and Authorization are inseparable aspects of security. Treat them as two sides of the same coin.

Common Mistake No. 3: Lack of Scalability Planning

In today’s fast-paced development landscape, where startup accelerators and instant global reach are prevalent, launching an MVP (minimum viable product) swiftly is paramount for many companies.

However, this relentless time pressure often leads even skilled development teams to overlook critical aspects. Scalability is frequently one such area taken for granted. While the MVP concept is valuable, pushing it too far can lead to significant problems.

Choosing a scalable database and web server, and separating application layers onto independent scalable servers, is a good start but not enough. There are numerous details to consider if you aim to avoid substantial application rewrites later - a major web development headache.

For instance, consider storing uploaded user profile pictures directly on a web server. Initially, this seems practical—files are readily accessible to the application, file handling methods are standard across platforms, and serving these images as static content minimizes application load.

But what happens when your application grows, requiring multiple web servers behind a load balancer? Even with a scalable database, session state servers, and web servers, scalability falters due to something as simple as profile images. Now you need file synchronization (introducing delays and potential 404 errors) or other workarounds to distribute files across servers.

Planning ahead by using shared file storage, a database, or a remote storage solution from the outset would have saved significant trouble. A few extra hours of initial implementation effort would have been a worthwhile investment.

Common Mistake No. 4: Incorrect or Absent SEO

The root cause of improper or lacking SEO practices often stems from misinformed “SEO specialists.” Many developers overestimate their SEO knowledge, assuming it’s straightforward. In reality, mastering SEO demands considerable time and effort to stay abreast of best practices and the ever-evolving algorithms of Google, Bing, and Yahoo. Without continuous experimentation, accurate tracking, and insightful analysis, one cannot claim SEO expertise.

Moreover, SEO is frequently relegated to a post-development activity, leading to costly consequences. SEO is not solely about crafting compelling content, optimizing tags, keywords, metadata, image alt tags, sitemaps, etc. It also involves eliminating duplicate content, ensuring a crawlable site architecture, optimizing load times, building intelligent backlinks, and more.

Similar to scalability, SEO considerations should be integrated from the outset of your web application development. Otherwise, you risk facing a complete system rewrite to fully implement SEO best practices.

Common Mistake No. 5: Resource-Intensive Actions within Request Handlers

Sending emails based on user actions exemplifies this mistake. Developers often resort to making SMTP calls directly from user request handlers, assuming it’s a simple solution.

Imagine an online bookstore anticipating a few hundred daily orders. Sending confirmation emails directly within the order processing workflow might suffice initially. However, as the system scales and order volume surges, problems arise. You encounter SMTP connection timeouts, exceed quotas, or experience significant application slowdown as it grapples with email handling instead of user requests.

Any time-consuming or resource-intensive task should be delegated to an external process, allowing HTTP requests to be released promptly. In this case, an external mailing service should handle order pickups and notification dispatch.

Common Mistake No. 6: Neglecting Bandwidth Optimization

Development and testing often occur within local networks with high-speed connections. Downloading multiple large background images might seem inconsequential in such an environment. However, when users on mobile devices with limited bandwidth try to load a bulky webpage, complaints and issues are inevitable.

Optimizing bandwidth usage significantly enhances performance, often achievable through a few simple techniques. Good developers often incorporate these practices by default:

  1. Minifying all JavaScript code
  2. Minifying all CSS code
  3. Enabling server-side HTTP compression
  4. Optimizing image sizes and resolutions

Common Mistake No. 7: Overlooking Different Screen Sizes

Responsive design has gained significant traction in recent years. The proliferation of smartphones with varying screen resolutions has ushered in diverse ways to access online content, presenting new challenges for web developers. With mobile and tablet traffic continuously rising, accommodating different screen sizes is crucial.

Numerous patterns and practices facilitate responsive web application development. While each platform has its nuances, some frameworks transcend platforms. Twitter Bootstrap stands out as a prominent open-source HTML, CSS, and JavaScript framework embraced by major development platforms. Adhering to its patterns and practices simplifies responsive development considerably.

Common Mistake No. 8: Cross-browser Incompatibility

Time constraints often plague the development process. The pressure to release applications quickly sometimes leads even experienced developers to prioritize functionality over design. While developers typically have Chrome, Firefox, and IE installed, they often focus on just one during development, only testing in others towards the end. This approach is acceptable if ample time exists for late-stage testing and bug fixing.

However, some tips can streamline cross-browser testing:

  1. Exhaustive testing in all browsers throughout development is inefficient and time-consuming. Instead, switch browsers periodically to identify major issues early on.
  2. Avoid relying solely on statistics to justify neglecting a specific browser. Many organizations are slow to adopt new software or upgrades. Thousands of users might still depend on older browsers due to internal policies, and they need access to your application.
  3. Minimize browser-specific code. In most cases, elegant cross-browser compatible solutions exist.

Common Mistake No. 9: Insufficient Portability Planning

Assumptions are often the root of problems, especially concerning portability. Hardcoded file paths, database connection strings, and assumptions about library availability on servers are common pitfalls. Assuming production environments mirror local development setups is a recipe for disaster.

An ideal application setup should be maintenance-free:

  1. Ensure scalability and the ability to run in a load-balanced, multi-server environment.
  2. Provide straightforward configuration, preferably through a single configuration file.
  3. Gracefully handle exceptions when web server configurations deviate from expectations.

Common Mistake No. 10: RESTful Anti-Patterns

RESTful APIs have become integral to web development, with nearly every application incorporating them for internal use or external system integration. Despite their prevalence, broken RESTful patterns and deviations from established practices persist.

Two common errors in RESTful API development include:

  1. Misusing HTTP verbs. For example, using GET for writing data. GET is designed for idempotency and safety. Regardless of how many times you call GET on a resource, the response should remain consistent, with no application state changes.

  2. Sending incorrect HTTP status codes. A prime example is sending error messages with a 200 OK status code.

    1
    2
    3
    4
    
     HTTP 200 OK
     {
         message:'there was an error'
     }
    

Reserve HTTP 200 OK for successful requests. For errors, utilize appropriate status codes such as 400, 401, 500, or others that accurately reflect the situation.

A comprehensive overview of standard HTTP status codes can be found here.

Conclusion

Web development encompasses a vast landscape, spanning websites, web services, and intricate web applications.

The key takeaway from this guide is to emphasize the importance of robust authentication and authorization, careful scalability planning, and avoiding hasty assumptions. By heeding these principles, you can mitigate potential web development challenges and streamline your development process.

Licensed under CC BY-NC-SA 4.0