Hello beginner developers!

Many of us are not very familiar with SQL because ORMs do all the magic for us. Let’s learn some SQL and understand what really happens under the hood.

SQL join clause is used to combine rows from two or more tables based on a common column. There are four types of SQL joins, simple aka inner join and three complex aka outer joins.

Let’s take the example of following tables, Departments and Employees.


Hello beginner developers!

Components are the building blocks of a React app and there are two types of components ie. class components and function components. Let’s see the steps to change a class component to a function component.

We shall use the example of a UserDetail component that renders the detailed view of a user in a basic networking app.

Class Component

import React from ‘react’class UserDetail extends React.Component {  state = {user: null}  componentDidMount() {
fetchUser()
}
componentDidUpdate(prevProps, prevState) {
this.props.match.params.id !== prevProps.match.params.id &&
fetchUser()
}
fetchUser() { let userId = this.props.match.params.id fetch(`http://localhost:3001/users/${userId}`) .then(r => r.json()) .then(userObj…


Hello beginner developers!

The concept of object was quite different when I started learning Javascript after Ruby. In Ruby, objects are class-based. Let’s see the example of a student object. Symbol //=> stands for return value.

Ruby

class Student
attr_accessor :given_name, :age
end
student = Student.new
student.given_name = “Maria”
student.age = 39
student
#=> #<Student:0x00007fb6c0988fe0 @given_name=”Maria”, @age=39>

Javascript

let student = new Object();
student.givenName = “Maria”;
student.age = 39;
student;
//=> {givenName: “Maria”, age: 39}

So what’s the big difference?

Creating an object

In Javascript, the above student object can be created in a single statement also, as shown below.

let student =…


Hello beginner developers!

Ever since I started building apps with Ruby frameworks, following are the object relationships and active record associations that I have been using the most.

Relationships

  1. one-to-many
  2. many-to-many

Associations

  1. belongs_to
  2. has_many
  3. has_many :through

Let’s study them using the example of a basic e-commerce app. We shall start domain modeling with following models and attributes.

User: name (string)

Order: number (string)

Item: name (string)

A user can have many orders and an order can have only one user. This is a one-to-many relationship which is implemented using belongs_to and has_many associations.

User — < Order

class User < ApplicationRecord has_many…


Hello beginner developers!

Ever since I started programming in Ruby, there are four enumerables that I have been using the most. Let’s study them using an array with 3 elements. Symbol #=> stands for return value.

1. each

.each returns the same array.

[1, 2, 3].each { |x| x * 2 }#=>[1, 2, 3]

.each is best used to iterate over an array.

[1, 2, 3].each { |x| puts x * 2 }246#=>[1, 2, 3]

2. map or collect

.map/.collect returns a new array with transformed elements. The original array doesn’t change.

[1, 2, 3].map { |x| x * 2 }

Mariamol James

Full Stack Web Developer | Ruby on Rails | Javascript | React

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store