0% found this document useful (0 votes)
56 views

Reactive Programming

The document discusses reactive programming, which is an asynchronous programming approach that handles changes in real time rather than static content. It allows programs to start long-running tasks without waiting for completion and remain responsive to other events. Multithreading runs multiple threads simultaneously, while asynchronous programming runs tasks sequentially or asynchronously.

Uploaded by

Evans
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views

Reactive Programming

The document discusses reactive programming, which is an asynchronous programming approach that handles changes in real time rather than static content. It allows programs to start long-running tasks without waiting for completion and remain responsive to other events. Multithreading runs multiple threads simultaneously, while asynchronous programming runs tasks sequentially or asynchronously.

Uploaded by

Evans
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

Reactive programming is a design approach or style of coding that employs asynchronous

programming logic to handle changes or real time updates rather than static contents.

a)It is a method that lets your program/software to start a task that could go on for a long time and,
instead of needing to wait for it to finish, it becomes responsive to other events while the other
work is ongoing.

b)Multithreading is the process of executing several threads simultaneously, whereas asynchronous


programming is the execution of tasks in and order or asynchronous sequence.

1. Single-Responsibility Principle - It means that for instance in React JavaScript a component should
have one and only one reason to change, meaning that one component should have only one job.
For instance you have component that handles the user inputs its work should only change when
user changes the input not other things which should be assigned to a different component. I have
applied this recently in my ongoing online shop system where I am only using one component say for
shipping to handle only shipping another one for payment and so on, this had made it easier mostly
when trying to identify which part of the software isn't working properly.

2. Open-Closed Principle - I could explain using the same components that the components should
be made easily available to be used by other components but not modifying them. For the case of
shipping and payment component the shipping component should be able to import data from the
payment component in that if the user has paid for his or her item then the shipping should be
processed.

3. Liskov Substitution Principle - This means that every subclass or derived class should be
substitutable for their base or parent class. For this case I was working on JavaScript classes and
when using the extend method to create a subclass from the parent class, the child class inherits the
methods that are available in its parent class. This makes the code more readable since the
properties and methods in the main class will be reused thus making my code more modular and
reusable.

4. Interface Segregation Principle -A client or user of your software should never be forced to
implement or view an interface that it doesn’t they don't want to use, or clients shouldn’t be forced
to depend on methods they do not use. For my current project the shopping system I am applying
this principle to give the user the freedom to find what page or interface they would like by using
search filtering in the software. This feature makes it easier for the clients to easily use your system
interface without much complications
5. Dependency Inversion Principle -This principle allows for decoupling. That is your software should
be able to be broken into several parts and they work or are connected without being directly
connected. Your software you should not force say high level classes say for my system The
PasswordReminder class should not care what low level databaseConnection method the application
uses rather it the database connection method should interface with the password reminder class,
with this it enables me achieve high level of abstraction.

Unified Modeling Language (UML) | Class Diagrams

I used it in the modelling of the system with different classes and components to show what class or
component interfaces or relates with one one another.

It works by visually representing a system along with its main actors, roles, actions, artifacts or
classes, in order to better understand, alter, maintain, or document information about the system.

I used it because it is the best way to visualize a project before it takes place or you start
implementing the code.

Agile software development process is practice that promotes continuous iteration of development
and testing throughout the software development lifecycle of the project. In the Agile model in
software development process, both development and testing activities are concurrent. It is a
software development approach that employ continual planning, learning, improvement, team
collaboration, evolutionary development, and early delivery. It encourages flexible responses to
change.

Has the following Phases -Project Initiation, Planning, Development, Integration and testing,
Implementation and deployment and lastly Review

How I Would Have used it in Real Life project.

Given my final year project a criminal record management system with several level of user
interactivity with system and different privileges'.

In the Project Initiation phase

The first phase I could gather on what the stakeholders or the users of the software need. Then I
could determine the time and work resources are required to complete the project. Taking stock of
resources is crucial to determining economic feasibility for project approval.
In the Planning phase

This is where I could get to know what the stakeholders really need what the management system
should maintain how it will be accessed and what privilege's are given to what users of the system,
what programming languages and which database to be used.

In the Development phase,

After gathering the requirements and the plans for the management system, I could code the system
first iterations that will be rolled out to some users for testing, I would develop different parts or
sprints for it to be tested separately and improve the ones tested.

In the Integration and testing phase

This is after several testing of different sprints of my coded system is where the system is made
available to the users and final testing of the entire system is done.

After integration I do Implementation and deployment -

the system software is now fully deployed and available to customers. This action leads to
maintenance phase. During this phase, I provide ongoing support to keep the system running
smoothly and fix any new bugs.

Lastly, Review

That is the last stage of the Agile development cycle. After completing all the previous stages of
development, I would present to the owner the result achieved in meeting the requirements. After
that, the Agile software development phases start over – either with a new iteration or moving to
the next stage and scaling Agile.

Coupling describes is the degree of interdependence between software modules - is used to indicate
the relative independence among the modules.

Cohesion refers to the degree to which the elements inside a module relates together - it is a
measure of the strength of relationship between the methods and data of a class and some unifying
purpose or concept served by that class

Alpha testing is mainly about ensuring bug-free functionality it relates to the internal testing by
customers, online visitors or an independent test team for in-house preliminary software, before the
next stage.
Beta testing involves releasing the software to a limited number of real users. It is a reference to the
external form of user acceptance testing within the marketplace.

CHANGING OF THE DATABASE FROM MySQL TO MONGODB

I am currently using MongoDB database and Mongoose rather than the previously used MySQL, with
the change in the database system it has been a challenging problem to make use of data that was in
the MySQL database to the MongoDB using the schemas and to try and store the data and fetch it
rather from the localhost of MySQL, my shopping system has different data to be stored in the
database.

I used different learning platforms to be able to integrate the previously MySQL database to
MongoDB, with the help of online resources and some of tutorials and my friends in tech I was able
to use MongoDB to store and fetch data from the database as it was in MySQL

let tasks = [2, 2, 3, 3, 2, 4, 4, 4, 4, 4];

let minimumRounds = function (tasks) {

function solve(x, cnt) {

if (x == 0) {

return 0;

if (x < 2) {

return Number.MAX_VALUE;

if (cnt[x]) {

return cnt[x];

let left = 1 + solve(x - 3, cnt);

let right = 1 + solve(x - 2, cnt);


cnt[x] = Math.min(left, right);

return cnt[x];

let hash = {};

for (let x of tasks) {

hash[x] = hash[x] ? hash[x] + 1 : 1;

let ans = 0;

for (let x of Object.values(hash)) {

let temp = solve(x, {});

if (temp == Number.MAX_VALUE) {

ans = -1;

break;

} else {

ans += temp;

return ans;

};

console.log(minimumRounds(tasks));

//OUTPUT = 4
public String[] chatBot(String[][] conversations, String[] currentConversation) {

int hmNumOfMatches = 0; // highest matched conversation's similar words to the current


conversation

ArrayList<String> hmRestOfWords = new ArrayList<>(); // the rest of the words in the matched
conversation

// for all given conversations

for (String[] pc : conversations) {

int numOfMatches = 0;

int indexOfLastMatchingWord = -1;

HashSet<String> uw = new HashSet<String>(); // stores the unique words in pc (possible


conversation)

// for all words of possible conversation

for (int j = 0; j < pc.length; j++) {

String pw = pc[j]; // possible word

// exclude words that have already been accounted for

if (!uw.contains(pw)) {

// for all words in the current conversation

for (int i = 0; i < currentConversation.length; i++) {

String w = currentConversation[i];

if (w.compareTo(pw) == 0) {

numOfMatches++;

indexOfLastMatchingWord = j;

uw.add(pw);

ArrayList<String> restOfWords = new ArrayList<>();


// if there were matching words

if (indexOfLastMatchingWord != -1)

restOfWords = getRestOfWords(pc, indexOfLastMatchingWord);

else continue;

// set the highest number of matches if it has none

if (hmNumOfMatches == 0) {

hmNumOfMatches = numOfMatches;

hmRestOfWords.addAll(restOfWords);

// also update it if it's less then the current number of matches

if (hmNumOfMatches < numOfMatches) {

hmNumOfMatches = numOfMatches;

hmRestOfWords = restOfWords;

/**

* Create the answer

*/

String[] answer = new String[currentConversation.length + hmRestOfWords.size()];

int i;

// append the current conversation to the answer

for (i = 0; i < currentConversation.length; i++) {

answer[i] = currentConversation[i];

// and append the rest of the words from the matched historical conversation
for (int j = 0; j < hmRestOfWords.size(); j++) {

answer[i + j] = hmRestOfWords.get(j);

return answer;

public ArrayList<String> getRestOfWords(String[] pc, int indexOfLastMatchingWord) {

ArrayList<String> restOfWords = new ArrayList<String>();

for (int i = indexOfLastMatchingWord + 1; i < pc.length; i++) {

if (!restOfWords.contains(pc[i])) restOfWords.add(pc[i]);

return restOfWords;

JavaScript code

function validTime(time) {

return Number(time.split(":")[0]) < 24 && Number(time.split(":")[1]) < 60;

let checkTime = validTime("13:58");

console.log(checkTime); // true

You might also like