From 66f6311816b0c8532e9cc310b606c8fa74fd6aef Mon Sep 17 00:00:00 2001 From: AnaeleJoshua Date: Sat, 11 Nov 2023 10:00:29 +0100 Subject: [PATCH 1/4] update contributor.md --- Contributors.md | 1 + 1 file changed, 1 insertion(+) diff --git a/Contributors.md b/Contributors.md index a9e9ede..24d6699 100644 --- a/Contributors.md +++ b/Contributors.md @@ -5,4 +5,5 @@ 1. icodejsx 2. ogbon(Segun Amosu) 3. Solomon Eseme +4. AnaeleJoshua From 87bbf2236fa8f893aa14cc4395ff96398c335a58 Mon Sep 17 00:00:00 2001 From: AnaeleJoshua Date: Sat, 11 Nov 2023 11:08:34 +0100 Subject: [PATCH 2/4] add Lexical_scope --- Lexical_scope.md | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 Lexical_scope.md diff --git a/Lexical_scope.md b/Lexical_scope.md new file mode 100644 index 0000000..ea78879 --- /dev/null +++ b/Lexical_scope.md @@ -0,0 +1,41 @@ +# LEXICAL SCOPING + +* Scope is the part of the program where an identifier such as a variable or function is visible. I.e refers to the area where a function or variable is visible and accessible to other code. + +## Types Of Scope in Js +* there are basically two types of Scope in javascript and they are + 1. Global scope + 2. Function Scope + +*Global Scope:* A Identifier defined in the global scope is visble and accesible from anywhere in the program. + +*Local Scope:* An Identifier defined in the local scope is visible only within the local scope it was defined. The types of local scope are: + 1. *Function scope* + 2. *Block scope.* + +* Function scope refers to the scope within a function. An identifier(variable of function) defined in function scope is only accessible within the function. + +## ================= SCOPE CHAIN ============================ +* Scope chain refers to the unique spaces that exist from the scope where a variable was called to the global scope. Javascript uses scope chain to find an identifier when it is invoked. +* When the Javascript engine is searching for a variable, it starts from the current scope and moves outward. + - The Javascript engine looks in the scope where the variable is requested. + - If it can't find it in the current scope, it moves out one level and checks again. + - It keeps moving to the outer scope until it has reached the global scope. + - If the javascript engines checks the global scope and still can't find the identifier, it then returns a .Reference error + +## Lexical Scoping. +* Lexical scoping refers to the place/environment/area where an is defined i.e where it was created. An identifier is scoped in the area where it was defined and not were it is invoked. + + ` + // myName variable and getName function defined in the + // global variable + const myName = "Joshua"; + + // Call myName variable from a function: + function getName() { + const Country = "Nigeria" + return myName; + } ` + + - In the code above, the myName and getName identifiers are defined in the global scope, so they are globally scoped, hence they can be accessed from anywhere in the program. + - The country identifier however is function scoped as it is defined within getName function, hence it can only be accessed within that function. \ No newline at end of file From 70cedf712d1ddfb8a1610dd36d248f902d669ca7 Mon Sep 17 00:00:00 2001 From: AnaeleJoshua Date: Sat, 11 Nov 2023 12:52:49 +0100 Subject: [PATCH 3/4] add backend event --- backendEvent.md | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 backendEvent.md diff --git a/backendEvent.md b/backendEvent.md new file mode 100644 index 0000000..bfb9276 --- /dev/null +++ b/backendEvent.md @@ -0,0 +1,39 @@ +# Events in Backend + +In programming, an event is an action or occurrence that is detected by the program and triggers a response or behavior. There are several types of events in programming, including: + +1. User interface events: These events are triggered by user actions such as clicking a button, typing into a text box, or selecting an item from a list. + +2. System events: These events are triggered by system actions such as a change in the system clock or a change in the system configuration. + +3. Network events: These events are triggered by network actions such as a connection being established or data being received. + +4. Device events: These events are triggered by device actions such as a keyboard or mouse input, or a sensor reading. + +4. Application events: These events are triggered by application-specific actions such as the completion of a task or the loading of a file. + +5. Time-based events: These events are triggered based on a specified time or interval, such as a scheduled task or a timer event. + +6. Error events: These events are triggered when an error or exception occurs in the program. + +* Events are used in programming to enable programs to respond to user actions or changes in the system. For example, when a user clicks a button on a graphical user interface (GUI), an event is generated. The program can then respond to the event by executing a specific set of instructions, such as opening a new window or updating the data displayed on the screen. + +Event-driven programming is a popular paradigm used in many programming languages, such as Java, JavaScript, and Python. In event-driven programming, the program responds to events by executing specific functions or blocks of code. This allows programs to be more interactive and responsive, and it enables developers to create complex and dynamic applications. + +Events are also used in event-based systems, such as message queues and event-driven architectures. In these systems, events are used to communicate between different components or services, enabling them to work together and respond to changes in the system in real-time. + +Overall, events are an important concept in programming, enabling programs to be interactive, responsive, and adaptable to changes in the system or user input. + + +# EVENT-DRIVEN ARCHITECTURE (EDA) +* Event-driven architecture (EDA) is a software design pattern that enables an organization to detect “events” or important business moments (such as a transaction, site visit, shopping cart abandonment, etc) and act on them in real time or near real time. + +* Event-driven architecture is often referred to as “asynchronous” communication. This means that the sender and recipient don’t have to wait for each other to move onto their next task. Systems are not dependent on that one message. For instance, a telephone call is considered synchronous or more along the lines of the traditional “request/response” architecture. Someone calls you and asks you to do something, the requestor waits while the responder completes the task, and then both parties hang up. An asynchronous example would be text messaging. You send a message and in some cases, you don't even know who you are sending it to or if anyone’s listening, but you are not waiting for a response. + +# What is an Event? +An event is defined as a change of state of some key business system. For instance, somebody buys a product, someone else checks in for a flight or a bus is late arriving somewhere. And if one thinks about it, events exist everywhere and are constantly happening, no matter what industry. They are pervasive across any business. This includes anything that creates a message by being produced, published, detected, or consumed is considered an event. The event is separate from the message, because while the event is the occurrence, the message is the traveling notification that relays the occurrence. In event-driven architecture, an event will likely trigger one or more actions or processes in response to its occurrence. An example of an event might include: + +Request to reset a password +A package arrived was delivered to its destination +A grocery warehouse updates its inventory +An unauthorized access attempt was denied From 39958af729983c580b525b034af5f45a1749eb7a Mon Sep 17 00:00:00 2001 From: AnaeleJoshua Date: Sat, 11 Nov 2023 13:00:13 +0100 Subject: [PATCH 4/4] update backend event --- backendEvent.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/backendEvent.md b/backendEvent.md index bfb9276..9120b3f 100644 --- a/backendEvent.md +++ b/backendEvent.md @@ -37,3 +37,18 @@ Request to reset a password A package arrived was delivered to its destination A grocery warehouse updates its inventory An unauthorized access attempt was denied + +Each of these events is likely to trigger one or more actions or processes in response. One response might be simply to log the event for monitoring purposes. Others might be: + +An email to reset the password is sent to the customer +The sales ticket is closed +An order for more lettuce (or whatever materials are running low) is placed +An account is locked and security personnel are notified +With event-driven architecture, when an event notification is sent, the system captures that something happened like a change in state has occurred and waits to send the reply to whoever requests it, whenever they request it. The application that received that message can either respond or wait to respond until the change in state has occurred that it is waiting for. + +Applications built around an event-driven architecture enable more agile, scalable, contextual, and responsive digital business applications. + +## How does Event-driven architecture work? +The components of an event-driven architecture can include three parts: producer, consumer, broker. The broker can be optional, particularly when you have a single producer and a single consumer that are in direct communication with each other and the producer just sends the events to the consumer. An example would be a producer that is sending only to a database or data warehouse so the events are collected and stored for analysis. Most commonly in enterprises, you have multiple sources sending out all types of events with one or more consumers interested in some or all of those events. + +Let’s look at an example. If you are a retailer, you might be collecting all of the purchases that are happening at all of your stores all over the world. You are feeding them into your event-driven architecture that is watching for fraud, sending them to a credit card processor or whatever actions need to happen next. For a manufacturer, you have all kinds of data coming off your equipment that is telling you facts like temperature and pressure so you can monitor these events in real time and take actions like predict failures or schedule maintenance, depending on what the data is telling you.