Important Questions and Answers on Visual and Internet Programming – Part 2
1. Api, Api authentication:
API:
Definition:
API stands for Application Programming Interface, A set of rules and protocols that allow
one software component or application to interact with another.
Purpose:
The main purpose of an API is to enable integration and communication between
different software components. It defines how requests for services should be made,
how data is sent and received, and what formats or rules are followed.
Key Points:
✓ APIs standardize communication, making it easier for developers to integrate
different systems.
✓ They hide complexity. For example, when you use a weather app, it calls an API to
get data from a weather service, but you don’t need to know how the weather
service collects that data.
✓ APIs can be thought of as "functions" or "endpoints" that one program exposes for
another to use
Types of APIs:
Web APIs: APIs accessed over the internet, typically using HTTP/HTTPS, to provide data
or services. It is oftenly use formats like JSON or XML, accessed via URLs (endpoints), and
use protocols like REST or SOAP.
Ex. OpenWeatherMap API, which provides real-time weather data
2. Library APIs: APIs provided by software libraries or frameworks, offering reusable
functions or classes. This is accessed via function calls in programming languages like
Python, Java, or C#.
Ex. The .NET Framework’s API in Visual Studio provides functions for file handling, graphics.
3. OS-level APIs: This APIs are provided by the operating system to interact with hardware or
system resources.
Ex. Low-level, often specific to the OS (e.g., Windows API).
4. Hardware APIs: Hardware APIs allow software to interact with physical devices like GPUs,
printers, or cameras, abstracting low-level hardware details.
Ex.
▪ OpenGL / DirectX: Graphics rendering for games and simulations
▪ Printer APIs: Sending documents to be printed
▪ Camera / Audio APIs: Capturing input/output from devices
5. GUI APIs: GUI APIs focus on building graphical user interfaces, providing components like
buttons, forms, and layouts.
Ex.
❑ WinForms and WPF (Windows Presentation Foundation) in C#
❑ Tkinter in Python
❑ Java Swing or JavaFX
API Authentication
API Authentication is the process of verifying the identity of a user or application trying to
access an API. It ensures that only authorized clients can access protected resources,
functions, or data through the API.
Goal:
❖ Prevents unauthorized access to sensitive data
❖ Helps in tracking and monitoring usage
❖ Enforces rate limits and user permissions
❖ Ensures that requests are coming from genuine sources
Common API Authentication Methods:
1. API Key Authentication
a) A simple token (like a password) sent with the request
b) Example: GET /users?api_key=abc123
c) Easy to implement, but not very secure if exposed
2. Basic Authentication
a) Sends a base64 encoded username and password
b) Authorization: Basic YWRtaW46cGFzc3dvcmQ=
c) Not secure unless used over HTTPS
3. OAuth 2.0
a) Industry standard for delegated access
b) Allows apps to access user data without sharing credentials
c) Supports access tokens, refresh tokens, and scopes
d) Used by Google, Facebook, Microsoft APIs
4. Bearer Token
a) A token (usually from OAuth) sent in the Authorization header
b) Example: Authorization: Bearer eyJhbGciOiJIUzI1NiIsIn...
5. JWT (JSON Web Token)
a) A compact, self-contained token with payload, header, and signature
b) Used for authentication and data exchange
c) Can be verified without querying the server
2. OLE and it’s mechanism, COM and IDispatch:
OLE and it’s mechanism:
Definition: OLE Automation is a feature of Microsoft’s Object Linking and Embedding (OLE)
technology, built on the Component Object Model (COM). It enables one application (the client) to programmatically control another application (the server) by intreating its methods or properties, like a script telling Excel to create a chart or Word to format a document.
Purpose:
The core goal of OLE Automation is to promote software reusability and interoperability within
the Windows ecosystem. It provides a standardized mechanism for applications like Excel, Word,
and PowerPoint to be automated and extended by custom software, including scripts and
compiled applications
Mechanism of OLE:
Ø OLE Automation operates on top of the COM infrastructure.
Ø The client application calls into the server application via standardized COM interfaces.
Ø Idispatch allows late binding, meaning the client can discover and invoke properties or methods at runtime.
Component Object Model (COM)
COM is Microsoft's platform-independent, distributed, object-oriented system for creating binary software components that can interact seamlessly. COM provides a binary-interoperability standard, allowing developers to build reusable objects that work across languages, processes, and even machines via DCOM (Distributed COM).
Key elements:
· Interfaces: Just a list of methods with no code — objects can use many of them to keep things organized.
· Binary Standard: COM uses tables (vtables) to call methods so different programming languages can work together.
· Reference Counting: Tracks how many times an object is used; when the count hits zero, the object is deleted automatically.
· Query Interface: Lets you check what features (interfaces) an object supports while the program is running.
Understanding the IDispatch:
IDispatch is a COM interface built on top of IUnknown that allows methods and properties to be accessed dynamically at runtime. It was introduced to support scripting languages and other environments where type information isn’t available at compile time. Instead of relying on fixed memory offsets, IDispatch lets clients call methods by name, enabling late binding and making OLE Automation far more flexible.
Early Binding: compile against a known library (.tlb, .dll) → safer, faster.
Late Binding: More flexible, no dependency on compile-time definitions → slower but dynamic.
3. Domain Name System (DNS)
How DNS Translates Names to IP Addresses?
DNS acts as the Internet’s phonebook, converting human-friendly domain names (e.g., www.example.com) into machine-readable IP addresses (e.g., 192.0.2.1).
Steps in DNS Resolution:
1) DNS Query Initiated: Your device asks a recursive DNS resolver for the IP address of the domain.
2) Root Server Query: The resolver queries root DNS servers to find the Top-Level Domain (TLD) server (.com, .org, etc.).
3) TLD Server Query: The resolver asks the TLD server for the authoritative DNS server of the domain.
4)Authoritative Server Query: The resolver retrieves the IP address from the authoritative DNS server.
5)Response Returned: The resolver returns the IP address to the client for use in connecting to the server.
4. Client-Server Architecture:
❑ Client: The user’s device, usually a web browser (Chrome, Firefox, Edge), which sends
requests to access web resources.
❑ Server: A powerful computer that stores website files, processes requests, and sends
responses back to clients.
Process:
1. Client sends an HTTP request asking for a webpage or data.
2. Server receives the request, processes it (may fetch data from databases).
3. Server sends back the HTML, CSS, and JavaScript files to the client.
4. Client’s browser renders the page for the user to see and interact with.
5. Front-end development(HTML, CSS, JavaScript)(only basic concept)
➢ HTML (Hypertext Markup Language)
This is the structure or skeleton of a web page. It defines the content and layout using tags like headings, paragraphs, images, and links. Without HTML, there would be no webpage.
➢ CSS (Cascading Style Sheets)
CSS controls the visual appearance of the webpage. It lets us style text (fonts, sizes, colors), arrange
elements (layouts, grids), and create responsive designs that adapt to different devices like phones or tablets.
➢ JavaScript
JavaScript adds interactivity and dynamic behavior to web pages. It handles user events like clicks, form inputs, animations, and updating parts of the page without reloading (like live chat or real-time data).
6. Web Performance Optimization
Caching Strategies
▪ Browser Caching: Stores resources locally in the user’s browser to avoid repeated downloads.
▪ Content Delivery Network (CDN): Distributes content across multiple servers worldwide to deliver data faster based on user location.
▪ Server-Side Caching: Saves computed responses or database query results to reduce processing time.
Minification and Bundling
▪ Minification: Removes unnecessary characters from code files to reduce size.
▪ Bundling: Combines multiple files into one to reduce the number of HTTP requests.
Lazy Loading and Code Splitting
▪ Lazy Loading: Delays loading of non-essential resources until they are needed.
▪ Code Splitting: Breaks large JavaScript files into smaller pieces loaded on demand.
7. Concept of Database
What is a Database?
A database is a systematically organized collection of data that allows users to store, retrieve, manipulate, and manage data efficiently and securely.
Databases are managed by software called Database Management Systems (DBMS) such as Microsoft SQL Server, MySQL, PostgreSQL, Oracle.
Relational databases (RDBMS) organize data into related tables, where:
▪ Tables represent entities (e.g., students, courses).
▪ Each row is a record (e.g., one student’s data).
▪ Each column represents a field/attribute (e.g., Name, Roll Number, Grade).
▪ Primary Key: A unique identifier for each record (e.g., Student ID).
▪ Foreign Key: Links to another table (e.g., DepartmentID referencing a Departments table)
Characteristics of a Database:
1.Structured Storage
▪ Data is stored in a consistent and logical format (tables, rows, columns).
▪ Example: A student table stores each student as a row, with fields like name, ID, GPA.
2.Efficient Retrieval
▪ You can retrieve data quickly using query languages like SQL.
▪ Example: "Show all students with GPA > 3.5".
3.Data Integrity
▪ Ensures data is accurate, consistent, and up-to-date using rules (e.g., no duplicate IDs).
4.Concurrency
▪ Multiple users can access and modify data simultaneously, safely.
5.Security
▪ Access controls determine who can view or edit what data.
6.Scalability
▪ Can handle small apps (e.g., a desktop library system) to massive services (e.g., Facebook, Google).
8. Responsive & Adaptive Design
Breakpoints and Fluid Layouts
· Breakpoints: Specific screen widths where the layout changes to better fit the device (e.g., mobile, tablet, desktop). Common breakpoints: mobile phones 320px to 480px, tablets 768px, and desktops 1024px above.
· Fluid Layouts: Use relative units like percentages to allow layouts to stretch and shrink smoothly across screen sizes.
Adaptive Images and Viewport Meta Tags
· Adaptive Images: Serve appropriately sized images based on device screen size and resolution to optimize load times.
· Viewport Meta Tag: Controls how the page scales on different devices, critical for mobile-friendly design.
Accessibility Considerations WCAG Guidelines (Web Content Accessibility Guidelines)
· Design websites so people with vision, hearing, movement, or thinking difficulties can use them.
· Follow four main rules: content should be easy to see, easy to use, easy to understand, and work well on all devices.
· Use clear HTML structure, good color contrast, let users navigate with a keyboard, and add ARIA roles for accessibility.
No comments