Day 20/100 of 100daysofcode : Request-Response and Event-Driven APIs
Today, I explored the fascinating world of APIs and focused on two essential patterns: Request-Response APIs and Event-Driven APIs. Hereโs what I learned:
Request-Response API:
Overview: A synchronous communication pattern where the client sends a request and waits for the serverโs response. Key Features:
-Synchronous Interaction: The client waits for a response.
-Simple Cycle: One request leads to one response.
-Common Protocols: Primarily uses HTTP/HTTPS, seen in REST and GraphQL APIs. Example: Retrieving user data from the GitHub API using a GET request. Use Cases: Ideal for CRUD operations and scenarios needing immediate feedback.
Event-Driven API:
Overview: An asynchronous communication model where systems react to events without direct requests. Key Features:
-Asynchronous Interaction: Events trigger actions, allowing for real-time updates.
-Decoupled Architecture: Producers and consumers operate independently.
-Common Technologies: Typically implemented using WebSockets or gRPC. Example: In a chat application, new messages are instantly pushed to all connected users without requests. Use Cases: Great for real-time notifications, IoT applications, and microservices interaction.
What Iโve learned
-Request-Response APIs are best for immediate data retrieval and direct interactions.
-Event-Driven APIs excel in real-time updates and asynchronous communication.
Day 21/100 of 100daysofcode : Back on Track with React.js!
After being off track for a bit due to the unfortunate situation here in Lebanon, Iโm back to continue my learning journey. I hope for safety and peace for everyone affected by the ongoing events.
Today, I explored the history of React.js, understanding not only its origins but also why itโs such a game-changer in the web development world.
History of React.js:
React was first developed by Facebook in 2011 to address challenges they faced with dynamic and interactive UIs. It was released as an open-source library in 2013, allowing developers worldwide to build user interfaces with ease. Its key innovation? The Virtual DOM, which makes updating the UI faster and more efficient!
Why Use React?
Component-based architecture โ React breaks down the UI into reusable components, improving code maintainability and scalability.
Declarative syntax โ It makes the code easy to read and understand, allowing developers to describe what they want the UI to look like.
Fast rendering with Virtual DOM โ Updates are handled efficiently, making apps more responsive.
Strong ecosystem and community โ Tons of libraries, tools, and resources, all supported by a massive community of developers.
Creating Your First React App:
Install Node.js and npm (Node Package Manager).
Run the command: npx create-react-app my-app in your terminal.
Navigate into the app folder and start the app with npm start.
Open localhost:3000 in your browser, and boomโyour first React app is live!
React isnโt just a libraryโitโs a new way of thinking about web development, and I can already see why itโs so popular. Canโt wait to dive deeper into components and hooks tomorrow!
Hoping for better days ahead and staying positive while continuing my coding journey. Letโs keep learning and building.
Day 22/100 of 100daysofcode : MasterReact.js Folder Structure
Today, I focused on one of the most crucial aspects of building scalable React applicationsโorganizing the folder structure.
Folder Structure Overview:
Hereโs a breakdown of the essential directories in a React project:
Components:The core UI building blocks, organized by feature or functionality.
Hooks:Custom hooks for reusable logic across multiple components.
Context: Manages global state using React Context API.
Services:For handling API calls and external services, keeping the logic isolated.
Utils: Utility functions (e.g., date formatting) used across components.
Assets: Stores static files like images, icons, and fonts.
Styles:Contains all stylesheets or CSS modules to maintain consistent design.
Why This Matters:
An organized structure not only enhances the readability and manageability of your code but also makes collaboration easier and ensures smooth scaling as the project grows. By separating concerns, you can quickly identify where each part of your logic resides.
Day 23/100 of 100daysofcode : Optimized File Formats
Today, I explored the structure of three powerful file formats designed for efficient data storage and processing. Hereโs how each one works:
Avro: Avro is a row-based format. It stores data as binary and includes a schema in a JSON header. This schema defines the structure of the data, which helps applications parse and process the binary information efficiently. Avro is ideal for streaming and reduces storage by compressing the data.
ORC (Optimized Row Columnar): ORC organizes data into columns. Each file is divided into โstripesโ that store chunks of column data. Every stripe contains an index, the actual data, and a footer with metadata (like counts, min/max values, etc.) for quick lookups. This structure makes ORC highly efficient for reading and writing large datasets, especially for queries that target specific columns.
Parquet: Similar to ORC, Parquet is a columnar format, but it specializes in nested data structures. Data is divided into โrow groups,โ and each row group stores column chunks together. Parquet files include metadata that describes the structure, allowing fast access to specific rows and columns. Its encoding and compression techniques make it extremely space-efficient, particularly for complex data.
Day 24/100 of 100daysofcode : ๐๐ ๐ฝ๐น๐ผ๐ฟ๐ถ๐ป๐ด ๐๐ฎ๐๐ฎ๐ฏ๐ฎ๐๐ฒ ๐๐ผ๐ป๐๐ฟ๐ผ๐น ๐๐ถ๐๐ต ๐๐๐ ๐ฆ๐๐ฎ๐๐ฒ๐บ๐ฒ๐ป๐๐
Todayโs focus is on ๐๐ฎ๐๐ฎ ๐๐ผ๐ป๐๐ฟ๐ผ๐น ๐๐ฎ๐ป๐ด๐๐ฎ๐ด๐ฒ (๐๐๐) in SQL. As a critical component for database management, DCL enables administrators to fine-tune access and permissions, controlling who can perform specific actions on database objects.
DCL consists of three main commands:
๐๐ฅ๐๐ก๐ง: Provides permissions to users or groups to perform specific actions on database objects.
๐๐๐ก๐ฌ: Explicitly denies permissions, overriding any granted permissions.
๐ฅ๐๐ฉ๐ข๐๐: Removes previously granted permissions, limiting access as needed.
Imagine we want to allow a user named user1 to read, insert, and update records in a Product table. We can use the following GRANT statement:
This command allows user1 to access and modify the table data, which is useful in many real-world scenarios like assigning permissions to team members.
Tip: Use DCL wisely to ensure data security while providing necessary access!