Posts

Showing posts from April, 2018

Week 12 - Session 2 - Group Programming Workshop - Music Library API

Image
blog image source Group exercise - b uilding a Music Library API (application programming interface)  using a hosted database provider called mLab, which offer a free tier solution where a MongoDB database is created and used with Express API.  Once a Mlab account and a MongoDB database have been set-up, implement a REST ( REpresentational State Transfer ) API which will do the following : Can you use mLab to hosts MongoDB databases? Can you use Express to build a basic CRUD (Create, Read, Update, Delete) web API? Can you use Postman to feature test an API? Can you validate user input? Can you use query parameters? Can you create unique IDs for objects to distinguish them from one another? Refactoring the schema including test units. Creating and testing multiple models. GitHub Music Library API exercise -  https://github.com/SharifCoding/music-library-api

Week 12 - Session 1 - Relational/Nested Data

Image
blog image source It is important to carefully plan out your database structure on how you want to store data, how it is accessed, and what objects belong to other objects. There are two common data structures: Relational Data - a collection of data items organized as a set of formally-described tables from which data can be accessed or reassembled in many different ways without having to reorganize the database tables. Nested Data - performs a particular function and that is contained within a code that performs a broader function. How I Conquered a Functioning (Relational) Database -  https://medium.com/@dschro225/how-i-conquered-a-functional-relational-database-with-mongodb-and-mongoose-js-bbc025cd67fe Model One-to-Many Relationships -  https://docs.mongodb.com/manual/tutorial/model-embedded-one-to-many-relationships-between-documents/ Modelling Relational Data With Mongoose - https://alexzywiak.github.io/best-of-both-worlds-modelling-relational-data-with-mongoos

Week 11 - Session 2 - Scope & Modules

Image
blog image source Scope determines the accessibility (visibility) of variables. JavaScript uses lexical scoping, where variables are available in the scope in which they are defined (using const or let). There are two types of scope: Local scope ; Variables declared within a JavaScript function become local to the function. Local variables have local scope: They can only be accessed within the function. Global scope ; a variable declared outside a function, becomes global. A global variable has global scope: All scripts and functions on a web page can access it. A module collects together related functionality - such as functions, procedures and other information. In Node, every file has its own scope, the top level of the file is the global scope, we can create nested scopes within, can use module.exports and require to make code defined in one file available in another, require is effectively another way of defining a variable within the scope of a node file.  

Week 11 - Session 1 - Databases/MongoDB

Image
blog image source A database is a collection of information that is organized so that it can be easily accessed, managed and updated. Data is organized into rows, columns, and tables, and it is indexed to make it easier to find relevant information. Data gets updated, expanded and deleted as new information is added. Databases process workloads to create and update themselves, querying the data they contain and running applications against it. There are two main database types in database technology, SQL(Structured Query Language): Relational ; databases are relationally structured entities, usually representing a real-world object; for example, a person or shopping cart details. Non-relational ; databases are document-structured and distributed, holding information in a folder-like Hierarchy which holds the data in an unstructured format. MongoDB is a free and open-source cross-platform document-oriented database program. Classified as a NoSQL database program, MongoDB use

Week 10 - Session 2 - Group Programming Workshop - Microlife Calculator

Image
blog image source Group exercise - b uilding a life activity tracker, which will tell us how much our life expectancy has increased or decreased based on a day's activities. Use a single JSON file to store information about the user and their activities.  Learning objectives from this exercise: Can you explain Request/Response? Can you use Express to create a web server locally? Can you use Postman to feature test an API? Can you use Node's fs module to read and write from files? Can you follow JavaScript asynchronously? Can you use Express to build a basic CRUD (Create, Read, Update, Delete) web API? Can you create unique IDs for objects to distinguish them from one another? Do you understand different status codes and how to send them? Can you validate user input? Can you use query parameters? GitHub Microlife Calculator exercise -  https://github.com/SharifCoding/microlife-calculator

Week 10 - Session 1 - Asynchronous JavaScript

Image
blog image source Synchronous programming means that, barring conditionals and function calls, a code is executed sequentially from top-to-bottom, blocking on long-running tasks such as network requests and disk I/O. Asynchronous programming means that the engine runs in an event loop. When a blocking operation is needed, the request is started, and the code keeps running without blocking for the result. When the response is ready, an interrupt is fired, which causes an event handler to be run, where the control flow continues. In this way, a single program thread can handle many concurrent operations. User interfaces are asynchronous by nature and spend most of their time waiting for user input to interrupt the event loop and trigger event handlers.  Node is asynchronous by default, meaning that the server works in much the same way, waiting in a loop for a network request, and accepting more incoming requests while the first one is being handled.  This is important in JavaSc

Testing APIs Using Postman

Image
blog image source An application program interface (API) is a set of routines, protocols, and tools for building software applications(how an API specifies how software components should interact). Postman is a popular API client that makes it easy for developers to create, share, test and document APIs. Postman is very convenient when it comes to executing APIs, since once you’ve entered and saved them you can simply use them over and over again, without having to remember the exact endpoint, headers, API key etc. Postman can run GET, POST, PUT, DELETE, and various other request methods as well, and also has utilities to help with developing APIs. Getting Started with Postman -  https://www.blazemeter.com/blog/getting-started-postman API testing tips -  http://blog.getpostman.com/2017/07/28/api-testing-tips-from-a-postman-professional/

Middleware is software glue

Image
blog image source Middleware is computer software that provides services to software applications beyond those available from the operating system. It can be described as software glue. Middleware functions are functions that have access to the request object (req), the response object (res), and the next middleware function in the application’s request-response cycle. These functions are used to modify req and res objects for tasks like parsing request bodies, adding response headers, etc. functions that have access to the request and response gets called before the controller function can modify the request object that gets passed to the controller can send a response and prevent the controller being accessed used for common tasks that are not the responsibility of any single controller: authentication request Body Validation logging redirection error handling can be applied at application or route level application level applies to all requests route level ap

What is MVC (Model, View, Controller)?

Image
blog image source MVC (Model, View, Controller) is a pattern for organising code in an application to improve maintainability. Imagine a photographer with his camera in a studio. A customer asks him to take a photo of a box. The box is the model, the photographer is the controller and the camera is the view. Because the box does not know about the camera or the photographer, it is completely independent. This separation allows the photographer to walk around the box and point the camera at any angle to get the shot/view that he wants. Models ; represent knowledge. contains the logic of the application responsible for managing application state expresses solution to our problem in terms of domain model this is where our OOP/domain modelling concepts come in Views ; a (visual) representation of its model. responsible for providing a representation of the requested application state to the client traditionally would be HTML pages, but can be any representati

Week 9 - Session 2 - Web APIs & Express

Image
blog image source In computer programming, an application programming interface (API) is a set of subroutine definitions, protocols, and tools for building application software.  A server-side web API is a programmatic interface consisting of one or more publicly exposed endpoints to a defined request–response message system, typically expressed in JSON or XML, which is exposed via the web—most commonly by means of an HTTP-based web server. Web API’s - Benefits: Simplified server code - not concerned with UI Allows for better professional specialization Separation allows server and client-side applications to evolve independently Increased portability of UI components Single Web API can power multiple UI's - website, mobile app etc Express is a (relatively) lightweight server-side JavaScript framework that runs on a Node.js server, a web application can be built up in Node with the help of the HTTP module. With Express, it will take it to the next level and make ap

Hypertext Transfer Protocol (HTTP) Methods

Image
blog image source The Hypertext Transfer Protocol (HTTP) is designed to enable communications between clients and servers. HTTP works as a request-response protocol between a client and server. A web browser may be the client, and an application on a computer that hosts a website may be the server. Two commonly used methods for a request-response between a client and server are GET and POST. GET - f or returning resources POST - for creating a new resource Other used methods: PUT - for updating a resource PATCH - for updating a resource DELETE - for deleting a resource Why should you use standard HTTP methods while designing REST APIs? -  https://medium.com/@suhas_chatekar/why-you-should-use-the-recommended-http-methods-in-your-rest-apis-981359828bf7

Difference between URI, URL, and URN

Image
blog image source URI identifies a resource  (text document, image file, etc) , URL is a subset of the URIs that include a network location. A URN is a subset of URIs that include a name within a given space, but no location. URI - Uniform Resource Identifier URL - Uniform Resource Locator URN - Uniform Resource Name What is a URL - https://www.dailytutorialz.com/url-meaning/

Week 9 - Session 1 - The Internet, the Web, HTTP

Image
blog image source The internet, a worldwide network of computer networks, a llows transfer of information between networks, and the information is transferred using the internet protocol suite (IP/TCP). One of the most commonly used services on the internet is the world wide web (www). A primary mode of transferring data (resources) over the internet for billions. The application protocol that makes the web work is hypertext transfer protocol. blog image source As web developers, we are mainly interested in HTTP,  a protocol that web browsers and web servers use to communicate with each other over the Internet.  The Hypertext Transfer Protocol (HTTP) is designed to enable communications between clients and servers. HTTP works as a request-response protocol between a client and server. A web browser may be the client, and an application on a computer that hosts a website may be the server. How does the Internet work? -  https://developer.mozilla.org/en-US/docs/Learn/Common_