Skip to main content

Posts

Showing posts from May, 2022

How JavaScript uses hashing

What is hashing and what it is used for? There are many important reasons for using hashing. One application of hashing is using it to store passwords in databases. You may need to store your user’s password so that you know whether they have entered a valid password or not. However, it would be very insecure to store all passwords as plain text in the database. Rather, it would be more secure if you applied a hashing function to the password and stored the hash/digest in the database instead.  Hashing can also be used for version control. When given the same input, a specific hashing algorithm will always produce the same digest. Therefore, we can compare the digest of two separate files and if the digests are the same, we will know the files are the same and have not been changed.   What is a hash table and what are the benefits of this data structure? A hash table, also known as a hash map, is a data structur...

Interfaces in object oriented programming languages and prototype-based languages

  What is an interface and what are the benefits of using interfaces in OOP? An interface is a shared boundary across which two or more separate components of a computer system exchange information. The exchange can be between software, computer hardware, peripheral devices, humans, and combinations of these.  Interfaces are a key concept in OOP. An interface defines which methods and properties a class must implement. The interface itself does not contain any code to implement an object. Interfaces specify what a class must do but not how they go about  doing it . An interface is often referred to as a contract because it is agreed that a class that implements the interface will implement the properties and methods defined in the interface.   Nowadays interface is absolutely indispensable mechanism of OOP. A base of lots of OOP patterns Steve Jobs on what OOP is:   'Objects are like people. They’re living, breathing things that have knowledge inside them about...

Big O notation basics for web developers

Big O Notation is just a way of representing the general growth in a computing difficulty of A task as you increase the DATA set. digitalocean.com O(1) The Big O notation for a constant function is 0(1). This describes an algorithm that will always execute in the same time(or space). bool IsFirstElementNull(IList<String> elements) { return elements[0] == null; } O(N²) With Quadratic time an algorithm run time is proportional to the square root of the amount of data. O(N²) is the Big O notation for Quadratic time. O(N²) represents an algorithm whose performance is directly proportional to the square of the size of the input data set. This is common with algorithms that involve nested iterations over the data set. Deeper nested iterations will result in O(N³), O(N⁴) etc. bool ContainsDuplicates(IList<string> elements) { for (var outer = 0; outer < elements.Count; outer++) { for (var inner = 0; inner < elements.Count; inner++) { ...

Concurrency in Web Development

  What is concurrency and how can it be implemented? Concurrency  is basically  multiple computations  or doing more than one thing at a time.   Concurrency is everywhere in programming . Web servers would definitely need to implement concurrency because they support many requests simultaneously. There are various ways to implement  concurrency .  such as  multiprocessing  and  multithreading  or an approach that uses both standard implementation methods.   How is concurrency implemented with Node.js? Node.js has another approach to concurrency. It uses  the I/O operations model  that uses  asynchronous  non-blocking I/O calls to implement concurrency. JavaScript is a  single-threaded asynchronous  (but not parallel)   programming language   yet everything done on the web   tends to be   blocking or time-consuming. Javascript code runs fundamentally in a  single t...