Unit 6: Web Application Development and Deployment - Subjective Questions
CSE326 — Internet Programming • Practice Questions with Detailed Answers
20 questions
Define web application debugging. Explain the main stages of a systematic debugging process.
Web application debugging is the process of identifying, analyzing, and correcting defects that cause a web application to behave unexpectedly.
A systematic debugging process includes:
- Reproduce the problem: Identify the exact actions, inputs, browser, and environment that trigger the defect.
- Collect evidence: Examine error messages, console logs, network requests, stack traces, and application state.
- Isolate the cause: Reduce the problem to the smallest relevant component or code section.
- Form and test a hypothesis: Predict the cause and verify it using breakpoints, temporary logs, or controlled changes.
- Implement the correction: Fix the root cause rather than merely hiding the visible symptom.
- Verify the correction: Repeat the original scenario and test related use cases.
- Prevent regression: Add automated tests, validation, or documentation so that the defect is less likely to return.
Describe five important debugging techniques used in client-side web development.
Important client-side debugging techniques include:
- Console logging: Use methods such as
console.log(),console.warn(), andconsole.error()to inspect values and execution flow. - Breakpoints: Pause JavaScript execution at a selected line and inspect variables, scope, and the call stack.
- Step execution: Use step over, step into, and step out to follow program execution one statement at a time.
- Binary search through code: Disable or inspect sections of code systematically to narrow down the source of a defect.
- Minimal reproduction: Create a smaller example that contains only the code required to reproduce the issue.
- Network inspection: Examine HTTP requests, status codes, headers, payloads, and response data.
- Automated testing: Use unit and integration tests to detect incorrect behavior consistently.
Effective debugging combines these techniques instead of relying only on trial-and-error code changes.
Explain how the Elements, Console, Sources, and Network panels of browser developer tools help developers diagnose web application problems.
The main browser developer tool panels serve different diagnostic purposes:
- Elements panel: Displays the live DOM and applied CSS. It helps developers inspect elements, temporarily edit markup and styles, analyze the box model, and detect overridden CSS rules.
- Console panel: Displays JavaScript errors, warnings, and developer-generated messages. It also provides an interactive environment for evaluating JavaScript expressions.
- Sources panel: Shows loaded scripts and supports breakpoints, step execution, variable inspection, watch expressions, and call-stack analysis.
- Network panel: Records resource and API requests. It reveals request methods, URLs, status codes, timing, headers, payloads, responses, and caching behavior.
For example, when a button fails to display server data, a developer can inspect its event handler in Sources, check errors in Console, examine the API request in Network, and verify the rendered output in Elements.
Distinguish between syntax errors, runtime errors, and logical errors in JavaScript. Give an example of each.
- Syntax error: Occurs when code violates JavaScript grammar and therefore cannot be parsed correctly. Example:
if (age > 18 { console.log(age); }is missing a closing parenthesis. - Runtime error: Occurs while syntactically valid code is being executed. Example: calling
user.getName()whenuserisnullproduces an exception. - Logical error: Occurs when the program runs without throwing an exception but produces an incorrect result. Example: calculating an average as
total / (count - 1)instead oftotal / count.
Syntax errors are commonly detected by the parser, runtime errors appear during execution, and logical errors generally require testing, inspection, or comparison with expected behavior.
Explain robust error handling in an asynchronous JavaScript application. Include the roles of try...catch...finally, Promise rejection handling, validation, and user feedback.
Robust asynchronous error handling prevents failures from leaving the application in an inconsistent or confusing state.
- Input validation: Reject invalid data before starting an asynchronous operation.
try...catch: When used withasyncandawait, it catches rejected Promises and synchronous exceptions within thetryblock.finally: Runs whether the operation succeeds or fails. It is useful for hiding loading indicators or restoring disabled controls.- Promise rejection handling: Promise chains should end with
.catch()whenawaitis not used. Unhandled rejections should be avoided. - Response checking:
fetch()does not reject automatically for every HTTP error, so code should inspectresponse.okor the status code. - User feedback: Display a clear, actionable message without exposing sensitive implementation details.
- Diagnostic logging: Record technical context for developers while avoiding passwords, tokens, and private user data.
- Recovery: Provide retry, fallback, cancellation, or offline behavior where appropriate.
Example:
try { const response = await fetch(url); if (!response.ok) throw new Error(\HTTP ${response.status}\); data = await response.json(); } catch (error) { showError("Unable to load data."); } finally { hideLoader(); }
Describe the principles for developing an interactive, accessible, and responsive user interface.
An effective interactive user interface should follow these principles:
- Clear feedback: Show visible responses for clicks, submissions, loading, success, and failure.
- Consistency: Use predictable labels, colors, control behavior, spacing, and navigation.
- Accessibility: Prefer semantic HTML, associate labels with inputs, support keyboard navigation, maintain visible focus, and provide sufficient color contrast.
- Responsiveness: Use flexible layouts, media queries, and appropriately sized controls for different screens.
- Error prevention: Validate data, constrain inputs, and confirm destructive actions where necessary.
- State communication: Clearly present selected, disabled, expanded, invalid, and loading states.
- Performance: Avoid unnecessary rendering and provide immediate feedback for potentially slow tasks.
- Progressive enhancement: Ensure core content and actions remain available even when advanced features are unsupported.
These principles make the interface easier to understand and operate across devices and for users with different abilities.
Explain event-driven programming in interactive web interfaces. How do event propagation and event delegation work?
In event-driven programming, application behavior is organized around events such as clicks, keyboard input, form submission, scrolling, and network completion. JavaScript registers event listeners that execute when specified events occur.
DOM events generally propagate through three stages:
- Capture phase: The event travels from the document root toward the target element.
- Target phase: The event reaches the element on which it originated.
- Bubble phase: The event travels from the target back toward ancestor elements.
Event delegation attaches one listener to a common ancestor instead of adding separate listeners to many child elements. The handler examines event.target or uses closest() to determine which child initiated the event.
Advantages of delegation include:
- Fewer event listeners and lower memory use.
- Automatic support for dynamically added child elements.
- Centralized interaction logic.
Developers should use preventDefault() only when replacing a browser's default action and stopPropagation() only when propagation would cause incorrect behavior.
Describe the major concerns involved in client-side application design.
Client-side application design involves organizing browser code so that the application remains understandable, responsive, and maintainable. Major concerns include:
- Separation of concerns: Keep data access, business rules, state management, presentation, and event handling logically separated.
- State management: Define the authoritative application state and update the interface consistently when it changes.
- Component design: Divide the interface into reusable components with clear inputs and responsibilities.
- Routing: Map URLs to views so navigation, refresh, bookmarking, and browser history work properly.
- Data communication: Handle API requests, loading states, caching, errors, retries, and cancellation.
- Security: Validate untrusted data, prevent cross-site scripting, and protect authentication information.
- Accessibility and responsiveness: Design for different users, input methods, and screen sizes.
- Testability: Keep logic modular and reduce hidden dependencies so individual behaviors can be verified.
Compare a single-page application (SPA) with a traditional multi-page application (MPA).
Single-page application:
- Loads an application shell and updates views through client-side JavaScript.
- Often provides fast navigation after the initial load.
- Commonly uses client-side routing and APIs.
- May require more JavaScript, state management, and build tooling.
- Requires careful handling of search indexing, accessibility, history, and initial performance.
Multi-page application:
- Requests a new HTML document from the server for major navigation actions.
- Usually has a simpler browser architecture and smaller client-side state.
- Can provide straightforward search indexing and progressive enhancement.
- May cause full-page reloads and repeated resource processing.
- Often relies more heavily on server-side routing and rendering.
Neither design is universally superior. An SPA is suitable for highly interactive applications with frequent in-page updates, while an MPA is often appropriate for content-oriented websites and workflows where server-rendered navigation is sufficient.
Explain how JavaScript code should be organized in a maintainable web application. Discuss modules, naming, separation of concerns, and dependency management.
Maintainable JavaScript code should have a predictable structure and clearly defined responsibilities.
- Modules: Split code into focused files and use
exportandimportto define explicit interfaces. - Separation of concerns: Keep DOM rendering, event handling, validation, API communication, and business logic separate where practical.
- Naming: Use descriptive, consistent names that communicate purpose, such as
fetchProductsorvalidateEmail. - Small functions: Each function should perform one coherent task and have clear inputs and outputs.
- Dependency management: Declare third-party packages in the project's package manifest and lock compatible versions with a lock file.
- Configuration management: Keep environment-specific values outside business logic and never commit secrets.
- Shared utilities: Reuse genuinely common logic while avoiding a large, unrelated utility file.
- Documentation and tests: Document public contracts and test important behavior.
A common structure may contain directories such as components, services, utils, styles, and tests, adjusted to the scale and framework of the project.
Define website performance and explain the significance of Largest Contentful Paint (LCP), Interaction to Next Paint (INP), and Cumulative Layout Shift (CLS).
Website performance describes how quickly and smoothly a website loads, becomes usable, and responds to user interaction.
- Largest Contentful Paint (LCP): Measures how long it takes for the largest visible content element in the viewport to render. It represents perceived loading speed.
- Interaction to Next Paint (INP): Measures the responsiveness of a page by evaluating the delay between user interactions and the next visual update. Long JavaScript tasks commonly harm INP.
- Cumulative Layout Shift (CLS): Measures unexpected movement of visible content during the page's lifetime. It reflects visual stability.
Typical improvements include:
- Optimize important images and preload critical resources to improve LCP.
- Reduce long tasks, excessive JavaScript, and expensive rendering to improve INP.
- Reserve dimensions for images, advertisements, and embedded content to reduce CLS.
These metrics should be measured using both controlled laboratory tools and real-user field data.
Describe practical techniques for improving the loading and runtime performance of a website.
Practical website performance techniques include:
- Optimize images: Choose suitable formats, compress files, provide responsive image sizes, and lazy-load noncritical images.
- Reduce transferred code: Minify assets, remove unused CSS and JavaScript, and apply code splitting.
- Use caching: Configure browser caching for static assets and use content hashes for safe long-term caching.
- Reduce requests: Avoid unnecessary dependencies and combine very small resources when appropriate.
- Prioritize critical resources: Load essential CSS early and defer noncritical scripts.
- Use a CDN: Deliver static resources from locations closer to users.
- Optimize JavaScript: Break up long tasks, limit repeated DOM work, and debounce high-frequency handlers when appropriate.
- Prevent layout shifts: Specify image dimensions and avoid inserting content above existing content.
- Measure results: Use Lighthouse, the Performance panel, and real-user monitoring to verify improvements.
Optimization should be guided by measurements because reducing file size alone may not address the actual user-visible bottleneck.
Explain the purpose of a GitHub repository and describe the standard workflow for creating, committing, and pushing a web project.
A GitHub repository stores a Git project's files, revision history, branches, and collaboration metadata on GitHub. It supports backup, version control, review, issue tracking, automation, and team collaboration.
A standard workflow is:
- Create a repository on GitHub or initialize a local repository with
git init. - Add project files and create a suitable
.gitignorefile. - Inspect changes using
git status. - Stage selected changes using
git add <file>orgit add .. - Record a meaningful commit using
git commit -m "Describe the change". - Connect the remote repository using
git remote add origin <repository-url>when required. - Push the branch using
git push -u origin main. - Continue development through small, focused commits and synchronize remote changes with
git pullorgit fetchfollowed by an appropriate integration step.
Sensitive data such as API keys, passwords, and private configuration must never be committed.
Describe how branches, pull requests, merge reviews, and issue tracking support collaborative development on GitHub.
- Branches isolate work on features, fixes, or experiments from the stable default branch. They allow multiple developers to work concurrently.
- Pull requests propose merging one branch into another. They display code differences, related commits, checks, and discussion.
- Merge reviews allow reviewers to identify defects, request changes, confirm standards, and share knowledge before integration.
- Automated checks can run tests, linting, builds, and security scans for every pull request.
- Issues record bugs, enhancements, tasks, decisions, and acceptance criteria. Labels, milestones, and assignees help organize work.
- Protected branches can require approvals and successful checks before changes enter the default branch.
A typical workflow is to create an issue, develop on a short-lived branch, commit focused changes, open a pull request linked to the issue, complete review and automated checks, and then merge the approved work.
Explain how to deploy a static website using GitHub Pages.
GitHub Pages hosts static HTML, CSS, JavaScript, and media files directly from a GitHub repository.
Deployment steps include:
- Place the website in a repository and ensure that the deployment output contains an entry file such as
index.html. - Push the website files to GitHub.
- Open the repository's Settings and select Pages.
- Choose a deployment source, such as a branch and folder, or configure a GitHub Actions workflow.
- Save the configuration and wait for the deployment process to complete.
- Open the generated Pages URL and verify links, styles, scripts, and assets.
Important considerations include:
- Use relative paths or configure the application's base path correctly for a project site.
- GitHub Pages does not run arbitrary server-side application code.
- Client-side routing may require special handling because direct requests to nested routes can return
404. - A custom domain can be configured, and HTTPS should be enabled.
- Build output should be deployed instead of unprocessed source files when a framework requires compilation.
Distinguish between a GitHub Pages user or organization site and a project site. Explain how this distinction affects URLs and asset paths.
A user or organization site is normally stored in a repository named <account>.github.io. Its default URL is:
https://<account>.github.io/
A project site is associated with a regular project repository. Its default URL is:
https://<account>.github.io/<repository>/
The distinction affects asset paths:
- On a user site, an absolute path such as
/styles.csspoints to the site's root and may work as expected. - On a project site,
/styles.cssstill points to the account-level root, not necessarily to/<repository>/styles.css. - Relative paths such as
./styles.cssare often suitable for simple project sites. - Applications built with frameworks may require a
base,homepage, or public-path configuration matching the repository name.
Incorrect base-path configuration commonly causes a deployed page to load without CSS, JavaScript, or images even though it works on a local server.
Discuss important web development best practices related to semantics, accessibility, security, compatibility, testing, and maintainability.
Important web development best practices include:
- Semantic HTML: Use elements such as
header,nav,main,button, andformaccording to their meaning. - Accessibility: Provide labels, alternative text, keyboard support, visible focus indicators, logical heading order, and sufficient contrast.
- Security: Treat all external data as untrusted, encode output, avoid unsafe HTML insertion, use HTTPS, and never expose secrets in client code.
- Compatibility: Test important workflows in supported browsers, devices, and screen sizes; use feature detection where necessary.
- Progressive enhancement: Build core functionality with broadly supported web features before adding advanced behavior.
- Testing: Combine unit, integration, end-to-end, accessibility, and manual exploratory testing according to project risk.
- Maintainability: Use consistent formatting, linting, meaningful names, focused modules, documentation, and code review.
- Performance: Optimize assets, minimize unnecessary work, and measure user-facing performance.
These practices improve reliability and usability throughout the application's lifetime.
Explain common client-side web security risks and the practices used to reduce them.
Common client-side web security risks include:
- Cross-site scripting (XSS): Untrusted content is executed as script. Reduce it by escaping output, sanitizing permitted HTML, avoiding unsafe
innerHTML, and using a Content Security Policy. - Exposed secrets: Client-side code can be inspected by users. API secrets and private credentials must remain on a trusted server or secure platform service.
- Insecure dependencies: Outdated packages may contain vulnerabilities. Review dependencies, apply updates, and use security scanning tools.
- Unsafe authentication storage: Sensitive tokens can be stolen through XSS. Use secure authentication designs and appropriate cookie protections when supported by the architecture.
- Unvalidated data: Client-side validation improves usability but cannot enforce security because it can be bypassed. The server must independently validate and authorize requests.
- Untrusted links and redirects: Validate destinations and use
rel="noopener noreferrer"where appropriate for external pages opened in new tabs.
Security requires defense in depth across the browser, server, deployment configuration, and development process.
Explain how GitHub Copilot can be used to improve a web application during development.
GitHub Copilot can assist web application development by:
- Suggesting code completions and repetitive implementation patterns.
- Generating initial versions of components, functions, styles, and tests from clear requirements.
- Explaining unfamiliar code and summarizing how modules interact.
- Proposing refactoring ideas for readability and reduced duplication.
- Assisting with debugging by interpreting errors and suggesting likely causes.
- Generating documentation, comments, test cases, and example data.
- Suggesting accessibility, error-handling, and performance improvements when explicitly prompted.
Copilot is most useful when developers provide precise context, constraints, expected behavior, and existing project conventions. Its output should be treated as a proposal rather than an authoritative solution. Developers remain responsible for understanding, testing, securing, and maintaining all accepted code.
Evaluate the limitations and responsible-use practices of GitHub Copilot when generating code for a production web application.
GitHub Copilot can accelerate development, but its suggestions may be incorrect, insecure, outdated, inefficient, or inconsistent with project requirements. It may also generate plausible code that uses nonexistent APIs or fails in important edge cases.
Responsible-use practices include:
- Review every suggestion: Understand the logic before accepting or modifying generated code.
- Verify correctness: Run tests and manually exercise normal, boundary, and failure scenarios.
- Perform security checks: Inspect data handling, authorization assumptions, dependency use, HTML insertion, and secret management.
- Check accessibility and performance: Generated interfaces may omit labels, keyboard behavior, responsive design, or efficient rendering.
- Protect sensitive information: Do not place credentials, private user data, or confidential source material in prompts.
- Confirm licensing and policy compliance: Follow organizational rules and review generated code where provenance may matter.
- Use project context: Provide coding standards, framework versions, interfaces, and acceptance criteria.
- Retain human accountability: Developers and reviewers remain responsible for production code.
Copilot should support engineering judgment, not replace design review, testing, documentation, or security analysis.
Define web application debugging. Explain the main stages of a systematic debugging process.
Web application debugging is the process of identifying, analyzing, and correcting defects that cause a web application to behave unexpectedly.
A systematic debugging process includes:
- Reproduce the problem: Identify the exact actions, inputs, browser, and environment that trigger the defect.
- Collect evidence: Examine error messages, console logs, network requests, stack traces, and application state.
- Isolate the cause: Reduce the problem to the smallest relevant component or code section.
- Form and test a hypothesis: Predict the cause and verify it using breakpoints, temporary logs, or controlled changes.
- Implement the correction: Fix the root cause rather than merely hiding the visible symptom.
- Verify the correction: Repeat the original scenario and test related use cases.
- Prevent regression: Add automated tests, validation, or documentation so that the defect is less likely to return.
Did this save you a night before the exam?
LPU Notes is free, and it stays free. Ads cover part of the server bill. The rest comes out of a student's own pocket: the domain, the storage, and keeping the site up through the weeks everyone needs it at once.
The payment button didn't load. An ad blocker or a filtered network is the usual reason. to try again.
Nothing here is ever locked, and nothing unlocks. Chip in only if it was worth it. What it pays for →