<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Cicada0315</title>
    <description>The latest articles on DEV Community by Cicada0315 (@cicada0315).</description>
    <link>https://dev.to/cicada0315</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F574699%2F3d353948-46dc-42c8-b358-3eca164635a8.jpg</url>
      <title>DEV Community: Cicada0315</title>
      <link>https://dev.to/cicada0315</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/cicada0315"/>
    <language>en</language>
    <item>
      <title>Part 2: React-Redux</title>
      <dc:creator>Cicada0315</dc:creator>
      <pubDate>Wed, 16 Jun 2021 19:22:08 +0000</pubDate>
      <link>https://dev.to/cicada0315/part-2-redux-react-1lp</link>
      <guid>https://dev.to/cicada0315/part-2-redux-react-1lp</guid>
      <description>&lt;p&gt;Let's actually make a new react app and go one by one to learn how to use redux with react.&lt;/p&gt;

&lt;h2&gt;
  
  
  Install
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//create new react app
$ npm install -g create-react-app
$ create-react-app &amp;lt; APP-NAME &amp;gt;

//(optional) install Yarn
$ npm install --global yarn

//install redux  
$ npm install redux
$ npm install react-redux
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Useful tools
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Redux DevTools,&lt;/strong&gt; &lt;br&gt;
&lt;a href="https://github.com/zalmoxisus/redux-devtools-extension" rel="noopener noreferrer"&gt;https://github.com/zalmoxisus/redux-devtools-extension&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;React Developer Tools,&lt;/strong&gt; &lt;br&gt;
&lt;a href="https://chrome.google.com/webstore/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi/related?hl=ko" rel="noopener noreferrer"&gt;https://chrome.google.com/webstore/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi/related?hl=ko&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Short Explanation for each library
&lt;/h2&gt;
&lt;h3&gt;
  
  
  import { createStore } from 'redux'
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { createStore } from 'redux'
createStore(reducer, [preloadedState], [enhancer])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;It creates store and returns that store. For more details for createStore or reducer use my first blog.&lt;br&gt;
Link: &lt;a href="https://dev.to/cicada0315/part-1-redux-1mi5"&gt;https://dev.to/cicada0315/part-1-redux-1mi5&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  import { Provider } from 'react-redux'
&lt;/h3&gt;

&lt;p&gt;Using  component makes the Redux store available to any child components. In other word, it Enables to access store and dispatch actions from any component. You can simply think that it can pass store as props to the child components. Most of time the  will render at the top level so that everyone can have access for store.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { Provider } from 'react-redux'
  &amp;lt;Provider store={store}&amp;gt;
  &amp;lt;/Provider&amp;gt;,
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  import { connect } from 'react-redux'
&lt;/h3&gt;

&lt;p&gt;To gain access to the store somewhere in our component we have to use this connect.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { connect } from 'react-redux';
export default connect(mapStateToProps, mapDispatchToProps)(ComponentName);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;connect():&lt;/strong&gt; It's a function connects a React component to a Redux store.&lt;br&gt;
&lt;strong&gt;mapStateToProps(aka mapState):&lt;/strong&gt; It's a function takes a first argument called state, optionally a second argument called ownProps, and return a plain object which become a props for your component.&lt;br&gt;
This function is passed in as the first argument to connect() and when connect() is run then it will passing in current state to the mapStateToProps.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const mapStateToProps = (state) =&amp;gt; ({ characters: state.characters })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;mapDispatchToProps:&lt;/strong&gt; It can be function, an object, or not supplied(null). This function expected to return an object. It is used for dispatching actions to the store.&lt;br&gt;
This function is passed in as the second argument to connect().&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const mapDispatchToProps = (dispatch) =&amp;gt; {
  return {
    createCharacter: (character) =&amp;gt; dispatch({ type: 'CREATE_CHARACTER', character }),
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Good things to know!
&lt;/h4&gt;

&lt;p&gt;Those three code is equivalent to each other&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//three different code is equivalent to each other
export default connect(mapStateToProps, mapDispatchToProps)(ComponentName);
export default connect(mapStateToProps, { createCharacter })(ComponentName);
export default connect(state =&amp;gt; ({ characters: state.characters }), { createCharacter })(ComponentName);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Dive into coding!
&lt;/h2&gt;

&lt;p&gt;Let's use what we've discussed above and make a simple app that can create characters and show list of created character.&lt;/p&gt;

&lt;h3&gt;
  
  
  Component tree (create folders and files under src)
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;src/components/CharacterForm.js&lt;/li&gt;
&lt;li&gt;src/components/Character.js&lt;/li&gt;
&lt;li&gt;src/containers/Characters.js&lt;/li&gt;
&lt;li&gt;src/reducers/charactersReducer.js&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcicada0315.github.io%2Fimage%2Ftree.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcicada0315.github.io%2Fimage%2Ftree.png" alt="alt Component_tree"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Modify index.js
&lt;/h3&gt;

&lt;p&gt;In index.js, I created store and take that store as provider argument to make it available to the child component of Apps.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';
import { Provider } from 'react-redux'; //add
import { createStore } from 'redux'; //add
import charactersReducer from "./reducers/charactersReducer"; //add

const store = createStore(charactersReducer); //add

ReactDOM.render(
  &amp;lt;React.StrictMode&amp;gt;
  &amp;lt;Provider store={store}&amp;gt;
    &amp;lt;App /&amp;gt;
  &amp;lt;/Provider&amp;gt;
  &amp;lt;/React.StrictMode&amp;gt;,
  document.getElementById('root')
);

reportWebVitals();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  App.js
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import './App.css';
import CharacterForm from './components/CharacterForm';
import Characters from './containers/Characters';

function App() {
  return (
    &amp;lt;div className="App"&amp;gt;
      &amp;lt;h1&amp;gt;Welcome to Character Storage&amp;lt;/h1&amp;gt;
      &amp;lt;CharacterForm /&amp;gt;
      &amp;lt;Characters /&amp;gt;
    &amp;lt;/div&amp;gt;
  );
};

export default App;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  reducers/charactersReducer.js
&lt;/h3&gt;

&lt;p&gt;For more information about reducer use my part 1: redux? blog.&lt;br&gt;
link: &lt;a href="https://dev.to/cicada0315/part-1-redux-1mi5"&gt;https://dev.to/cicada0315/part-1-redux-1mi5&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export default function charactersReducer(state={characters: []}, action) {
    switch(action.type){
        case "CREATE_CHARACTER":
            return {
                ...state,
                characters: [...state.characters, action.character]
            }
        default:
                return state
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  containers/Characters.js
&lt;/h3&gt;

&lt;p&gt;To gain access to the store which contains characters array, I used connect() with first argument mapStateToProps here. Then, I used that characters array with map method to pass character as props to the child component character.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React, { Component } from 'react'
import Character from '../components/Character'
import { connect } from 'react-redux';

class Characters extends Component {
    render() {
        const characters = this.props.characters.map(character =&amp;gt; &amp;lt;Character character={character}/&amp;gt;);
        return (
            &amp;lt;div&amp;gt;
                &amp;lt;h1&amp;gt;Character list&amp;lt;/h1&amp;gt;
               {characters}
            &amp;lt;/div&amp;gt;
        );
    };
};

const mapStateToProps = (state) =&amp;gt; {
    return{
        characters: state.characters
    };
};

export default connect(mapStateToProps)(Characters);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  components/Character.js
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function Character(props){
    return (
      &amp;lt;div className="character"&amp;gt;
        &amp;lt;h1&amp;gt;{props.character.name}&amp;lt;/h1&amp;gt;
        &amp;lt;img src={props.character.image_url} alt={props.character.name} height="400" width="800"/&amp;gt;
        &amp;lt;h3&amp;gt;Description: {props.character.description}&amp;lt;/h3&amp;gt;
      &amp;lt;/div&amp;gt;
    );
}

export default Character;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  components/CharacterForm.js
&lt;/h3&gt;

&lt;p&gt;To gain access to the store to dispatch action, I used connect() here too. Once the form is submitted. It will call the function handleSubmit which will dispatch createCharacter(this.state) which will pass the new created character in it as this.state as eventually add that new character to our state.characters array.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React, { Component } from 'react';
import { connect } from 'react-redux';

class CharacterForm extends Component{
    state={
        name: "",
        image_url: "",
        description: ""
    };

    handleChange=(e)=&amp;gt;{
        this.setState({
            [e.target.name]: e.target.value
        });
    };

    handleSubmit=(e)=&amp;gt;{
        e.preventDefault();
        this.props.createCharacter(this.state);
        this.setState({
            name: "",
            image_url: "",
            description: ""
        });
    }

    render(){
        return (
            &amp;lt;div&amp;gt;
                &amp;lt;form onSubmit={this.handleSubmit}&amp;gt;
                &amp;lt;h1&amp;gt;Create New Character&amp;lt;/h1&amp;gt;
                Name: &amp;lt;input type="text" name="name" value={this.state.name} onChange={this.handleChange}/&amp;gt;&amp;lt;br /&amp;gt;
                Image_url: &amp;lt;input type="url" name="image_url" value={this.state.image_url} onChange={this.handleChange}/&amp;gt;&amp;lt;br /&amp;gt;
                Description: &amp;lt;textarea name="description" value={this.state.description} onChange={this.handleChange}/&amp;gt;&amp;lt;br /&amp;gt;
                &amp;lt;input type = "submit" value = "Create New Character" /&amp;gt;
                &amp;lt;/form&amp;gt;
            &amp;lt;/div&amp;gt;
        );
    };
};

const mapDispatchToProps = (dispatch) =&amp;gt; {
    return {
        createCharacter: (character) =&amp;gt; dispatch({ type: 'CREATE_CHARACTER', character }),
    }
  }

export default connect(null, mapDispatchToProps)(CharacterForm);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We have everything here, so why don't you try in visual studio? You can use marvel website to add new characters.&lt;br&gt;
link: &lt;a href="https://www.marvel.com/characters" rel="noopener noreferrer"&gt;https://www.marvel.com/characters&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Reference
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://react-redux.js.org/using-react-redux/connect-mapstate" rel="noopener noreferrer"&gt;https://react-redux.js.org/using-react-redux/connect-mapstate&lt;/a&gt;&lt;br&gt;
&lt;a href="https://react-redux.js.org/using-react-redux/connect-mapdispatch" rel="noopener noreferrer"&gt;https://react-redux.js.org/using-react-redux/connect-mapdispatch&lt;/a&gt;&lt;/p&gt;

</description>
      <category>redux</category>
      <category>react</category>
    </item>
    <item>
      <title>Part 1: Redux?</title>
      <dc:creator>Cicada0315</dc:creator>
      <pubDate>Tue, 15 Jun 2021 17:56:37 +0000</pubDate>
      <link>https://dev.to/cicada0315/part-1-redux-1mi5</link>
      <guid>https://dev.to/cicada0315/part-1-redux-1mi5</guid>
      <description>&lt;h2&gt;
  
  
  What is Redux?
&lt;/h2&gt;

&lt;p&gt;Redux is a state container for JavaScript applications. It's basically another library. Redux puts all of our data(state) in one place. All the parts of Redux are plain old JavaScript including state(obj). You can use Redux together with React, or with any other view library. I will go over how Redux-React works in another blog but first let's learn about Redux.&lt;br&gt;
&lt;strong&gt;How Redux-React works, &lt;br&gt;
link: &lt;a href="https://dev.to/cicada0315/part-2-redux-react-1lp"&gt;https://dev.to/cicada0315/part-2-redux-react-1lp&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Why using Redux?
&lt;/h2&gt;

&lt;p&gt;Redux state is separate from the component tree so, we can get any part of this data(state) for any component just by connecting the component. &lt;/p&gt;

&lt;p&gt;Redux made complex interaction between components much easier. For example, there is one parent and from that parent there is two sibling components. If both of siblings displaying or manipulating the same data (state), the data needs to be stored in their parent component's state and passing props up and down to accessible for both siblings. Passing props up and down makes code complicated and messy. However, with Redux, every component we allow can get the update state data regardless of the their position of component tree.&lt;br&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zDO0seyw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://css-tricks.com/wp-content/uploads/2016/03/redux-article-3-03.svg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zDO0seyw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://css-tricks.com/wp-content/uploads/2016/03/redux-article-3-03.svg" alt="alt Component tree"&gt;&lt;/a&gt; Image_link: &lt;a href="https://css-tricks.com/learning-react-redux/"&gt;https://css-tricks.com/learning-react-redux/&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Three Principles
&lt;/h2&gt;

&lt;p&gt;Three principles comes from this link: &lt;br&gt;
&lt;a href="https://redux.js.org/understanding/thinking-in-redux/three-principles"&gt;https://redux.js.org/understanding/thinking-in-redux/three-principles&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  1. Single source of truth
&lt;/h3&gt;

&lt;p&gt;The global state of your application is stored in an object tree within a single store.&lt;/p&gt;
&lt;h3&gt;
  
  
  2. State is read-only
&lt;/h3&gt;

&lt;p&gt;The only way to change the state is to emit an action, an object describing what happened.&lt;/p&gt;
&lt;h3&gt;
  
  
  3. Changes are made with pure functions
&lt;/h3&gt;

&lt;p&gt;To specify how the state tree is transformed by actions, you write pure function reducers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;pure function:&lt;/strong&gt; It returns the same result for same arguments, it does not alter input data, no modification of local and global variables and it does not depend on the external state like a global variable.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const addtwo = n =&amp;gt; n+2;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;link: &lt;a href="https://www.tutorialspoint.com/redux/redux_pure_functions.htm"&gt;https://www.tutorialspoint.com/redux/redux_pure_functions.htm&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Reducers:&lt;/strong&gt; It's a pure functions that take the previous state and an action. It returns the next state without mutating the previous state. Simply, it only returns new state obj.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function reducer(state, action){ }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  More terminology to understand redux
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;store:&lt;/strong&gt; It's a container that carry the whole state tree of your application. There should only be a single store in your app (use combineReducers to create a single root reducer out of many).&lt;br&gt;
To change the state is through(dispatch) an action and this is the only way.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;createStore() method:&lt;/strong&gt; It is provided by the redux library. Creates and returns store as obj that will have a dispatch method and a getState(which returns the current state value) method.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;createStore(reducer, [preloadedState], [enhancer])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;preloadedState (any): Optional parameter that can define the initial state.&lt;br&gt;
enhancer (Function): Optional parameter that enhance the store. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;dispatch function:&lt;/strong&gt; Dispatches an action. This is the only way to trigger a state change.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dispatch(action)
dispatch({type: 'INCREASE_COUNT'})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  How redux works?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Note: Not actually using Redux yet just showing you how redux works(implementing redux not using redux library).&lt;/strong&gt;&lt;br&gt;
Redux dispatches action, dispatch evokes reducer and then with updated state it renders the view. The flows like down below image.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--t6Oqlbmv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://redux.js.org/assets/images/ReduxDataFlowDiagram-49fa8c3968371d9ef6f2a1486bd40a26.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--t6Oqlbmv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://redux.js.org/assets/images/ReduxDataFlowDiagram-49fa8c3968371d9ef6f2a1486bd40a26.gif" alt="alt Data flow"&gt;&lt;/a&gt; Diagram_link: &lt;a href="https://redux.js.org/tutorials/fundamentals/part-2-concepts-data-flow"&gt;https://redux.js.org/tutorials/fundamentals/part-2-concepts-data-flow&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's sum up everything we discussed in one example code. I will implement a bank account which shows in DataFlowDiagram above:&lt;/p&gt;
&lt;h3&gt;
  
  
  Example code,
&lt;/h3&gt;

&lt;p&gt;There is two buttons deposit $10 and withdraw $10, every time you click deposit $10 then the balance increase $10 on the other hands, whenever you click withdraw $10 then the balance decrease by $10.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//script.js
function createStore(reducder){
  let state;
  function dispatch(action){
    state=reducer(state, action);
    render();
  };
  function getState(){
    return state;
  };
  return {
    dispatch, getState
  };
};

function reducer(state ={
  balance: 0
}, action){
  switch (action.type) {
    case 'DEPOSIT':
      return {
        balance: state.balance+ action.payload
      };
    case 'WITHDRAW':
      return {
        balance: state.balance- action.payload
      };
     default:
      return state;
  };
};

function render(){
  const accountbalancetag=document.getElementById("output");
  accountbalancetag.innerText="Balance:" +store.getState().balance;
};

const handledeposit=(e)=&amp;gt;{
  store.dispatch({ type: 'DEPOSIT', payload:10 });
};

const handlewithdraw=(e)=&amp;gt;{
  store.dispatch({ type: 'WITHDRAW', payload:10 });
};

let store =createStore(reducer);
const depositbutton=document.getElementById("deposit");
depositbutton.addEventListener('click', handledeposit);
const withdrawbutton=document.getElementById("withdraw");
withdrawbutton.addEventListener('click', handlewithdraw);

//index.html
&amp;lt;div&amp;gt;
  &amp;lt;h1&amp;gt;Bank Account&amp;lt;/h1&amp;gt;
  &amp;lt;h2 id="output"&amp;gt;
  Balance: 0
  &amp;lt;/h2&amp;gt;
  &amp;lt;button id="deposit"&amp;gt;
    Deposit $10
  &amp;lt;/button&amp;gt;
  &amp;lt;br /&amp;gt;
  &amp;lt;button id="withdraw"&amp;gt;
    Withdraw $10
  &amp;lt;/button&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you want to see what is happening use this, &lt;br&gt;
link: &lt;a href="https://playcode.io/new/"&gt;https://playcode.io/new/&lt;/a&gt; &lt;br&gt;
Copy and paste code to the appropriate field to check what the app looks like. Whenever you modify the code then you have to wait 7sec but it's really good when you are doing quick check with complete code.&lt;/p&gt;

&lt;p&gt;I hope this helps you to understand Redux.&lt;/p&gt;

</description>
      <category>react</category>
      <category>redux</category>
    </item>
    <item>
      <title>Better to know before learning React</title>
      <dc:creator>Cicada0315</dc:creator>
      <pubDate>Tue, 15 Jun 2021 14:55:34 +0000</pubDate>
      <link>https://dev.to/cicada0315/better-to-know-before-learning-react-5h2p</link>
      <guid>https://dev.to/cicada0315/better-to-know-before-learning-react-5h2p</guid>
      <description>&lt;p&gt;I thought it would be nice to know some of the main terms or useful tools before learning React. &lt;/p&gt;

&lt;h2&gt;
  
  
  React
&lt;/h2&gt;

&lt;p&gt;React is front-end JavaScript library for building user interfaces or UI components.&lt;br&gt;
reterence:&lt;br&gt;
&lt;a href="https://en.wikipedia.org/wiki/React_(JavaScript_library)"&gt;https://en.wikipedia.org/wiki/React_(JavaScript_library)&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  React Tools
&lt;/h2&gt;
&lt;h3&gt;
  
  
  Node.js
&lt;/h3&gt;

&lt;p&gt;Node.js is a back-end JavaScript runtime environment (server environment) that executes JavaScript code outside a web browser. &lt;/p&gt;
&lt;h3&gt;
  
  
  npm (Node Package Manager)
&lt;/h3&gt;

&lt;p&gt;npm is a collection of software tools that automates the process of installing, upgrading, configuring, and removing computer programs for the javaScript. All npm packages are defined in files called package.json(must be written in JSON).&lt;br&gt;
reterence:&lt;br&gt;
&lt;a href="https://en.wikipedia.org/wiki/Npm_(software)"&gt;https://en.wikipedia.org/wiki/Npm_(software)&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  npx (Node Package eXecute)
&lt;/h3&gt;

&lt;p&gt;It comes with the npm 5.2.0 version. It is an npm package runner that can execute any package from npm registry.&lt;br&gt;
reterence:&lt;br&gt;
&lt;a href="https://www.geeksforgeeks.org/what-are-the-differences-between-npm-and-npx/"&gt;https://www.geeksforgeeks.org/what-are-the-differences-between-npm-and-npx/&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  npm vs npx
&lt;/h4&gt;

&lt;p&gt;If you want to run certain package with &lt;strong&gt;npm&lt;/strong&gt; then you have to specify that package to package.json and install it locally. But with &lt;strong&gt;npx&lt;/strong&gt; package will automatically installed.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install some-package
$ npm install -g create-react-app
$ create-react-app my-app
npx some-package
$ npx create-react-app my-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  yarn
&lt;/h3&gt;

&lt;p&gt;Yarn is new JavaScript Package Manager that is to solve a problems that has faced by teams(Facebook, Google, Exponent and Tilde) with npm.&lt;/p&gt;

&lt;h3&gt;
  
  
  JSX (JavaScript XML)
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;JSX is a syntax extension to javaScript.&lt;/strong&gt; It let us to write HTML elements in JavaScript. We don't have to use JSX, but it makes much easier to write react application as you can see in the below example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//This example provided in https://www.w3schools.com/react/react_jsx.asp
//With JSX
const output = &amp;lt;h1&amp;gt;With JSX&amp;lt;/h1&amp;gt;;
ReactDOM.render(output, document.getElementById('root'));

//Whitout JSX
const output  = React.createElement('h1', {}, 'Without JSX!');
ReactDOM.render(output , document.getElementById('root'));
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;reference:&lt;br&gt;
&lt;a href="https://www.w3schools.com/react/react_jsx.asp"&gt;https://www.w3schools.com/react/react_jsx.asp&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Babel
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Babel is a JavaScript compiler.&lt;/strong&gt; Transform ES6+ code into a backwards compatible version(older version) of JavaScript.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//This example provided in https://babeljs.io/docs/en/index.html
// Babel Input: ES6(ES2015) arrow function
[1, 2, 3].map(n =&amp;gt; n + 1);

// Babel Output: ES5 equivalent
[1, 2, 3].map(function(n) {
  return n + 1;
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;reference:&lt;br&gt;
&lt;a href="https://babeljs.io/docs/en/index.html"&gt;https://babeljs.io/docs/en/index.html&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Webpack
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Webpack is an open-source JavaScript module bundler.&lt;/strong&gt; When compiling a React application with Webpack, It will outputting a single file which 'bundle' up all of our files with with dependencies properly placed.&lt;br&gt;
reference:&lt;br&gt;
&lt;a href="https://webpack.js.org/"&gt;https://webpack.js.org/&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  React Router
&lt;/h3&gt;

&lt;p&gt;By default, React comes without routing so to use it we need to install it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install react-router-dom
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  BONUS tool
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Styling
&lt;/h3&gt;

&lt;h4&gt;
  
  
  React-Bootstrap
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install react-bootstrap bootstrap@4.6.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For detailed instruction of how to use visit the &lt;br&gt;
Link: &lt;a href="https://react-bootstrap.github.io/getting-started/introduction/"&gt;https://react-bootstrap.github.io/getting-started/introduction/&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  Material-UI (implement Google's Material Design specification)
&lt;/h4&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install @material-ui/core
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;For detailed instruction of how to use visit the&lt;br&gt;
Link: &lt;a href="https://material-ui.com/getting-started/usage/"&gt;https://material-ui.com/getting-started/usage/&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Create react app
&lt;/h2&gt;

&lt;p&gt;Now you have all the basic source, to make a new project use following command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ npm install -g create-react-app
$ create-react-app &amp;lt; APP-NAME &amp;gt;  
//Once you have npm installed you can run the following both to install and upgrade Yarn:
$ npm install --global yarn
//To start up the server
$ cd &amp;lt; APP-NAME &amp;gt;
$ npm start 
or 
$ yarn start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As I learn, I will add more to this blog if I find more useful tools. &lt;/p&gt;

</description>
      <category>react</category>
    </item>
    <item>
      <title>Hooks For Beginner</title>
      <dc:creator>Cicada0315</dc:creator>
      <pubDate>Thu, 10 Jun 2021 22:47:11 +0000</pubDate>
      <link>https://dev.to/cicada0315/hooks-for-beginner-5go7</link>
      <guid>https://dev.to/cicada0315/hooks-for-beginner-5go7</guid>
      <description>&lt;h2&gt;
  
  
  What is Hooks?
&lt;/h2&gt;

&lt;p&gt;Hooks are a new addition in React 16.8. They are JavaScript functions that let you use state and other React features without writing a class (Hooks don’t work inside classes).&lt;/p&gt;

&lt;h2&gt;
  
  
  State Hook ('useState')
&lt;/h2&gt;

&lt;p&gt;'useState' enables you to add state to functional components. We call this Hook inside a functional component to add some local state to it. React will preserve this state between re-renders.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const [state, setState] = useState(initialState);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Returns a stateful value(state), and a function(setState) to update it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Example
&lt;/h3&gt;

&lt;p&gt;In this example, we are making total state. It is initialize as 0. Whenever you click the Button then the total state will increment by 1 and page will re-render with updated total state.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React, { useState } from 'react';

function Example() {
  const [total, setTotal] = useState(0);
  return (
    &amp;lt;div&amp;gt;
      &amp;lt;h1&amp;gt;clicked {total} times&amp;lt;/h1&amp;gt;
      &amp;lt;button onClick={() =&amp;gt; setTotal(count + 1)}&amp;gt;Button&amp;lt;/button&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Using class: Equivalent with above code&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Example extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      total: 0
    };
  }

  render() {
    return (
      &amp;lt;div&amp;gt;
        &amp;lt;h1&amp;gt;clicked {this.state.total} times&amp;lt;/h1&amp;gt;
        &amp;lt;button onClick={() =&amp;gt; this.setState(previousState =&amp;gt; ({ total: previousState.total + 1 }))&amp;gt;
          Button
        &amp;lt;/button&amp;gt;
      &amp;lt;/div&amp;gt;
    );
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also use the State Hook more than once in a single component and the state can be any type unlike state in a class which is always be an object like example below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function ExampleWithManyStates() {
  // Declare multiple state variables!
  const [vegetable, setVegetable] = useState('onion');
  const [users, setUsers] = useState([{ Name: 'Jean' }]);
  // ...
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Effect Hook ('useEffect')
&lt;/h2&gt;

&lt;p&gt;Effect Hook serves the same purpose as componentDidMount, componentDidUpdate, and componentWillUnmount in React classes, but unified into a single API(simply working as all three combined). The function passed to useEffect will be called(run) after the render is committed to the screen. In other words, by using this Hook, you tell React that your component needs to do something after render.&lt;/p&gt;

&lt;h3&gt;
  
  
  With one parameter
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;useEffect(didUpdate);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Example
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React, { useState, useEffect } from 'react';
function Example() {
  const [total, setTotal] = useState(0);

  // Similar to componentDidMount and componentDidUpdate: 
  // Update the document title using the browser API   
useEffect(() =&amp;gt; {document.title = `clicked ${total} times`;});
  return (
    &amp;lt;div&amp;gt;
      &amp;lt;h1&amp;gt;clicked {total} times&amp;lt;/h1&amp;gt;
      &amp;lt;button onClick={() =&amp;gt; setTotal(total + 1)}&amp;gt;
        Button
      &amp;lt;/button&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In here userEffect is working as componentDidMount and componentDidUpdate combined as explained in the code above.&lt;/p&gt;

&lt;h3&gt;
  
  
  With two parameters
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;useEffect(didUpdate, [dependency array]);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;with one paremeter, useEffect run after every render which means it runs both after the first render and after every update. &lt;/p&gt;

&lt;p&gt;what if we want call this function when only certain value changes(update)? That is why we need second parameter which called as dependency array. &lt;br&gt;
&lt;strong&gt;Dependency array&lt;/strong&gt; is the second optional parameters in the useEffect function. The Effect will only executed when the second parameter value of array updated and inside the array we can put more then one value.&lt;/p&gt;
&lt;h4&gt;
  
  
  Example
&lt;/h4&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const App=()=&amp;gt;{
  const [value, handleChange] = useFrom({ email: "", password: ""});
  useEffect(()=&amp;gt;{
    console.log("render");
  }, [values.password]);

  return(
    &amp;lt;div&amp;gt;
    &amp;lt;&amp;gt;
      &amp;lt;input name="email" value={values.email} onChange={handleChange}/&amp;gt;
      &amp;lt;input type="password" name="password" value={values.password} onChange={handleChange} /&amp;gt;
    &amp;lt;/&amp;gt;
    &amp;lt;/div&amp;gt;
   );
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;So whenever {values.password} changes then the Effect fires off again and again.&lt;/p&gt;

&lt;p&gt;If you put second parameter as empty array [], it only implement componentDidMount not componentDidUpdate. So, it not doing to evoke when there any is changes. In other words, re-render is not going to call the Effect anymore and render only when component Mount.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;useEffect(()=&amp;gt;{
    console.log("render");
  }, []);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Effect Hook with cleanup
&lt;/h3&gt;

&lt;p&gt;Simply put return function inside userEffect will performs the cleanup when the component unmount which is similar to componentWillUnmount.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;useEffect(()=&amp;gt;{
    console.log("render");

    return ()=&amp;gt;{
      console.log("unmount");
    }
  }, []);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If we user second parameter for some value like previous example. then we can cleaning up the old value and getting new value.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;useEffect(()=&amp;gt;{
    console.log("render");

    return ()=&amp;gt;{
      console.log("unmount");
    }
}, [values.password]);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can have more then one useEffect in one component and it fired in order.&lt;/p&gt;

&lt;h3&gt;
  
  
  Keep in mind!
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Only call Hooks at the top level. Don’t call Hooks inside loops, conditions, or nested functions.&lt;/li&gt;
&lt;li&gt;Only call Hooks from React function components. Don’t call Hooks from regular JavaScript functions. (There is just one other valid place to call Hooks)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you are still confused leave a comment or recommend to watch youtube link that I put in below.&lt;/p&gt;

&lt;h3&gt;
  
  
  reference:
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://reactjs.org/docs/hooks-overview.html"&gt;https://reactjs.org/docs/hooks-overview.html&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.youtube.com/watch?v=j1ZRyw7OtZs"&gt;https://www.youtube.com/watch?v=j1ZRyw7OtZs&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>redux</category>
      <category>hooks</category>
    </item>
    <item>
      <title>JS spread operator (...)</title>
      <dc:creator>Cicada0315</dc:creator>
      <pubDate>Fri, 04 Jun 2021 15:41:17 +0000</pubDate>
      <link>https://dev.to/cicada0315/js-spread-operator-3hl1</link>
      <guid>https://dev.to/cicada0315/js-spread-operator-3hl1</guid>
      <description>&lt;h2&gt;
  
  
  Definition
&lt;/h2&gt;

&lt;p&gt;JavaScript ES6 introduced the spread operator and it only worked for arrays. ES2018 expands the spread operator (...) to make it works with own enumerable properties of an object. &lt;/p&gt;

&lt;p&gt;Spread syntax (...) allows an iterable such as an array expression or string to be expanded in places where zero or more arguments (for function calls) or elements (for array literals) are expected, or an object expression to be expanded in places where zero or more key-value pairs (for object literals) are expected. &lt;/p&gt;

&lt;p&gt;reference:&lt;br&gt;
&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax"&gt;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I feel like this definition is hard to understand. So let me put in other words, &lt;strong&gt;the spread operator takes an iterable such as array and expands it into elements.&lt;/strong&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Examples
&lt;/h2&gt;
&lt;h3&gt;
  
  
  Array
&lt;/h3&gt;
&lt;h4&gt;
  
  
  1. Merge Arrays
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Without spread operator, using Array.prototype.concat(),&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let array1 = [1, 2, 3];
let array2 = [4, 5, 6];

let newArray=array1.concat(array2);
newArray; //-&amp;gt; [1, 2, 3, 4, 5, 6]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;With spread operator,&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let array1 = [1, 2, 3];
let array2 = [4, 5, 6];

let mergeArray = [...array1, ...array2];
mergedArray; //-&amp;gt; [1, 2, 3, 4, 5, 6]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  2. Clone Array
&lt;/h4&gt;

&lt;p&gt;In JavaScript, arrays are reference types("pass by reference", it just copies address of that array), so you can't just create a new copy of an array using =. When you are change the new array or original array, it will also change the other another like example below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let original = [1, 2, 3];
let newArray = original;

newArray[0]=5;
newArray; //-&amp;gt; [5, 2, 3]
original; //-&amp;gt; [5, 2, 3]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Oh no, both of them changed. Let's try again with spread operator.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let original = [1, 2, 3];
let newArray = [...original];

newArray[0]=5;
newArray; //-&amp;gt; [5, 2, 3]
original; //-&amp;gt; [1, 2, 3]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, original array didn't affect when we changed the newArray,  only newArray was modified.&lt;/p&gt;

&lt;h4&gt;
  
  
  3. String to Array
&lt;/h4&gt;

&lt;p&gt;Using spread operator to a string, it will return an array of individual substrings (split into characters).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let st = 'hello';
let array = [...st];
array; //-&amp;gt; ['h', 'e', 'l', 'l', 'o']
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  4. Math
&lt;/h4&gt;

&lt;p&gt;The Math object in javascript, the array won't work but with spread operator it will work&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let array = [1,2,3,10];
console.log(Math.max(array)); //-&amp;gt;NaN
console.log(Math.max(...array)); //-&amp;gt;10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;reference:&lt;br&gt;
&lt;a href="https://www.samanthaming.com/tidbits/92-6-use-cases-of-spread-with-array/"&gt;https://www.samanthaming.com/tidbits/92-6-use-cases-of-spread-with-array/&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.geeksforgeeks.org/javascript-spread-operator/"&gt;https://www.geeksforgeeks.org/javascript-spread-operator/&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Object
&lt;/h3&gt;

&lt;p&gt;The spread operator (…) with objects is used to create copies of existing objects with new or updated values or to make a copy of an object with more properties.&lt;/p&gt;

&lt;p&gt;let's say we have 3 objects,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let user1 = {
    name: 'jean',
    age: 30
};
let user2 = {
    name: 'John',
    age: 20
};
let jean = {
    location: 'NY',
    hobby: 'coding'
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  1. Clone Object
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Using Object.assign()&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let clonedUser = Object.assign({}, user1);
clonedUser; //-&amp;gt; {name: 'jean', age: 30 }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Using Spread Operator&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let clonedUser = { ...user1 };
clonedUser; //-&amp;gt; {name: 'jean', age: 30 }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Both of them works same way.&lt;/p&gt;

&lt;h4&gt;
  
  
  2. Merge Objects (with different properties)
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Using Object.assign()&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;This will modify the user1 too.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let MergedUser = Object.assign(user1, jean);
MergedUser; //-&amp;gt; {name: "jean", age: 30, location: "NY", hobby: "coding"}
user1; //-&amp;gt; {name: "jean", age: 30, location: "NY", hobby: "coding"}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Making new Merged obj, won't modify the user1
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let MergedUser = Object.assign({}, user1, jean);
MergedUser; //-&amp;gt; {name: "jean", age: 30, location: "NY", hobby: "coding"}
user1; //-&amp;gt; {name: 'jean', age: 30 }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Without using {} empty object, it will modify the user1. Simply saying that first take the user1 and then add jean to the user1. If you don't want to mutate user1 then you must use empty obj. "let MergedUser = Object.assign({}, user1, jean);" this is saying that create the empty newobj and copy user1 to it and then add jean to that newobj. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Using Spread Operator&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let MergedUser = { ...user1, ...jean};
MergedUser; //-&amp;gt; {name: "jean", age: 30, location: "NY", hobby: "coding"}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  3. Merge Objects (with same properties)
&lt;/h4&gt;

&lt;p&gt;Using Object.assign&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let MergedUser = Object.assign({}, user1, user2);
MergedUser; //-&amp;gt; {name: "John", age: 30}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Using Spread Operator&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let MergedUser = { ...user1, ...user2};
MergedUser; //-&amp;gt; {name: "John", age: 30}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The properties are overwritten by other objects that have the same properties later in the parameters order.&lt;br&gt;
This overwriting will come in handy when you pass objects to other functions that update state.&lt;/p&gt;

&lt;h4&gt;
  
  
  Bonus Update property
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const obj = { hi: "x", hello: "y" };
const updatedObj = { ...obj, hi: "z" };
updatedObj; //-&amp;gt; {hi: z, hello: "b"}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is what I talked earlier when explaining with using Object.assign() with empty obj or not. So in this case, we update obj with new value.&lt;/p&gt;

&lt;h4&gt;
  
  
  Bonus Create new obj with Updated property of other obj
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//using Object.assign()
let user = {id: 1, name: 'jean', age: 30};
let YoungerUser = Object.assign({}, user, {age: user.age - 1})
//using spread operator
let user = {id: 1, name: 'jean', age: 30};
let YoungerUser = {...user, age: user.age - 1}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It's creating new obj, "YoungerUser". Start with a new empty object, copy over everything from the original user, then overwrite the age property with a new value.&lt;br&gt;
reference: &lt;br&gt;
&lt;a href="https://www.rockyourcode.com/use-the-spread-operator-to-update-objects/"&gt;https://www.rockyourcode.com/use-the-spread-operator-to-update-objects/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>spreadoperator</category>
    </item>
    <item>
      <title>MemoryCardGame</title>
      <dc:creator>Cicada0315</dc:creator>
      <pubDate>Tue, 18 May 2021 01:04:30 +0000</pubDate>
      <link>https://dev.to/cicada0315/memorycardgame-3kg8</link>
      <guid>https://dev.to/cicada0315/memorycardgame-3kg8</guid>
      <description>&lt;p&gt;"In some ways, programming is like painting. You start with a blank canvas and certain basic raw materials. You use a combination of science, art, and craft to determine what to do with them." - Andrew Hunt&lt;/p&gt;

&lt;h2&gt;
  
  
  Step1: Deciding type of website
&lt;/h2&gt;

&lt;p&gt;This is first project using javaScript so I didn't want to do complex project instead I decided to make simple memoryCardGame.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step2: Setting backend
&lt;/h2&gt;

&lt;h3&gt;
  
  
  table relation
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Category &amp;lt; ApplicationRecord
    has_many :cards
end

class Card &amp;lt; ApplicationRecord
  belongs_to :category
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Controller
&lt;/h3&gt;

&lt;p&gt;Use scaffold&lt;br&gt;
rails g scaffold Category name&lt;br&gt;
rails g scaffold Card name url category:belongs_to&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class CategoriesController &amp;lt; ApplicationController
  before_action :set_category, only: [:show, :update, :destroy]

  # GET /categories
  def index
    @categories = Category.all

    render json: @categories, only: [:id, :name], include: {
      cards: {
        only: [:id, :name, :url, :category_id] 
      }
    }
  end

  # GET /categories/1
  def show
    render json: @category, only: [:id, :name], include: {
      cards: {
        only: [:id, :name, :url] 
      }
    }
  end

  # POST /categories
  def create
    @category = Category.new(category_params)

    if @category.save
      render json: {
        status: 201,
        store: @category
      }, status: :created, location: category_path(@category)
    else
      render json: {
        status: 422,
        errors: @store.errors.full_messages.join(", ")
      }, status: :unprocessable_entity
    end
  end

  # PATCH/PUT /categories/1
  def update
    if @category.update(category_params)
      render json: @category
    else
      render json: @category.errors, status: :unprocessable_entity
    end
  end

  # DELETE /categories/1
  def destroy
    @category.destroy
  end

  private
    # Use callbacks to share common setup or constraints between actions.
    def set_category
      @category = Category.find(params[:id])
    end

    # Only allow a list of trusted parameters through.
    def category_params
      params.require(:category).permit(:name)
    end
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step3: Setting frontend
&lt;/h2&gt;

&lt;h3&gt;
  
  
  index.html
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Create form
&lt;/h4&gt;

&lt;p&gt;fetch post request to add new category with new 6 cards&lt;/p&gt;

&lt;h4&gt;
  
  
  Category-container
&lt;/h4&gt;

&lt;p&gt;fetch get request to show a list of category&lt;/p&gt;

&lt;h4&gt;
  
  
  Game
&lt;/h4&gt;

&lt;p&gt;When user clicks the play button next to the each list then event function will generate new Game with that category.&lt;/p&gt;

&lt;h3&gt;
  
  
  styles.css
&lt;/h3&gt;

&lt;p&gt;Since I have show the card flips to user. I put two different images (font-face and back-face) in the same location and made them 3d.&lt;br&gt;
&lt;a href="https://www.w3schools.com/cssref/css3_pr_transform.asp"&gt;https://www.w3schools.com/cssref/css3_pr_transform.asp&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.w3schools.com/cssref/css3_pr_transform-style.asp"&gt;https://www.w3schools.com/cssref/css3_pr_transform-style.asp&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.w3schools.com/cssref/css3_pr_transition.asp"&gt;https://www.w3schools.com/cssref/css3_pr_transition.asp&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#memory-game {
    width: 640px;
    height: 640px;
    margin-right: 5%;
    border-radius: 5px;
    display: flex;
    flex-wrap: wrap;
}

.memory-card {
    /*board is 640 we have 160 for each but we need somespace with each other so -10 and have margin 5px*/
    width: calc(25% - 10px);
    height: calc(33.333% - 10px);
    margin: 5px;
    position: relative;   
    transform: scale(1);
    /*preserve-3d: Specifies that child elements(.front-face and .back-face) will preserve its 3D position*/
    transform-style: preserve-3d;
    transition: transform .5s;
}

.memory-card.flip {
    transform: rotateY(180deg);
}

/*put front and back same spot*/
.front-face, .back-face {
    width: 100%;
    height: 100%;
    position: absolute;
    border-style: solid;
    border-color: wheat;
    border-width: 2px;
    border-radius: 5px;
    backface-visibility: hidden;
}

/*then rotate front 180deg to only see the back-face at first*/
.front-face {
    transform: rotateY(180deg);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  src/index.js
&lt;/h3&gt;

&lt;p&gt;This part is relatively easy then setting up the board. As long as I follow the logic everything is okay.&lt;br&gt;
Useful-1: style.order&lt;br&gt;
&lt;a href="https://www.w3schools.com/jsref/prop_style_order.asp"&gt;https://www.w3schools.com/jsref/prop_style_order.asp&lt;/a&gt;&lt;br&gt;
The order property specifies the order of a flexible item relative to the rest of the flexible items inside the same container.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function shuffle(){
    const cards = document.querySelectorAll('.memory-card');
    for(let i=0; i&amp;lt;cards.length; i++){
        let randomPos = Math.floor(Math.random() * 12);
        cards[i].style.order = randomPos
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Useful-2: classList&lt;br&gt;
&lt;a href="https://www.w3schools.com/jsref/prop_element_classlist.asp"&gt;https://www.w3schools.com/jsref/prop_element_classlist.asp&lt;/a&gt;&lt;br&gt;
classList.add(); Adds one or more class names to an element.&lt;/p&gt;

&lt;h2&gt;
  
  
  Future
&lt;/h2&gt;

&lt;p&gt;For now it only works 6 set of cards. I want to modify this project so that it can generate game with any sets of cards. &lt;/p&gt;

</description>
      <category>rails</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Rails: Up </title>
      <dc:creator>Cicada0315</dc:creator>
      <pubDate>Thu, 29 Apr 2021 20:41:50 +0000</pubDate>
      <link>https://dev.to/cicada0315/rails-up-330j</link>
      <guid>https://dev.to/cicada0315/rails-up-330j</guid>
      <description>&lt;h2&gt;
  
  
  Step1: Deciding type of website
&lt;/h2&gt;

&lt;p&gt;There is one website that I really enjoy which contains bunch of ramdom stories, images or gifs. I can even upload them by myself. Since I am practicing, I thought, it will be better to mimic one of the familiar website so I choose to make my version of this website.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step2: Plans
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Models
&lt;/h3&gt;

&lt;p&gt;I used below link do draw relational diagrams. I will have four models as you can find in  below as well. &lt;/p&gt;

&lt;h4&gt;
  
  
  link: &lt;a href="https://dbdiagram.io/home"&gt;https://dbdiagram.io/home&lt;/a&gt;
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Creating tables
Table users {
  id int [pk, increment]
  last_name string
  first_name string
  username string
  email string
  password string
}

Table posts {
  id int [pk, increment]
  user_id integer
  title string
  link string
  content text
  view integer

}

Table comments {
  id int [pk, increment]
  user_id integer
  post_id integer
  content text
}

Table likes {
  id int [pk, increment]
  user_id integer
  post_id integer
}

// Creating references
// You can also define relaionship separately
// &amp;gt; many-to-one; &amp;lt; one-to-many; - one-to-one
Ref: posts.user_id &amp;gt; users.id

Ref: comments.user_id &amp;gt; users.id
Ref: comments.post_id &amp;gt; posts.id

Ref: likes.user_id &amp;gt; users.id
Ref: likes.post_id &amp;gt; posts.id
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Controllers
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apllication_cotroller
comments_controller
likes_controller
posts_controller
users_controller
sessions_controller
static_controller
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Views
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;layouts: application
posts: new, edit, show, index, kups, topups, newups, _form, _post
sessions: new
static: about, _errors
users: new
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step3: Implement
&lt;/h2&gt;

&lt;h3&gt;
  
  
  static
&lt;/h3&gt;

&lt;p&gt;aboutUps- explained about the website&lt;/p&gt;

&lt;h3&gt;
  
  
  users
&lt;/h3&gt;

&lt;p&gt;signup&lt;/p&gt;

&lt;h3&gt;
  
  
  sessions
&lt;/h3&gt;

&lt;p&gt;login&lt;br&gt;
logout&lt;/p&gt;

&lt;h3&gt;
  
  
  posts
&lt;/h3&gt;

&lt;p&gt;user can upload files, write content, provide link for image or gif.&lt;br&gt;
user can modify or delete the post they uploaded.&lt;br&gt;
user can comment post.&lt;br&gt;
user can like(thumbsup) the post.&lt;br&gt;
whenever people see the post then the view is incremented.&lt;/p&gt;

&lt;h2&gt;
  
  
  Reference
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://getbootstrap.com/"&gt;https://getbootstrap.com/&lt;/a&gt;&lt;br&gt;
&lt;a href="https://guides.rubyonrails.org/v5.2.0/active_storage_overview.html"&gt;https://guides.rubyonrails.org/v5.2.0/active_storage_overview.html&lt;/a&gt;&lt;br&gt;
&lt;a href="https://github.com/Ejguzman3988/ft-020121-ImgTube"&gt;https://github.com/Ejguzman3988/ft-020121-ImgTube&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Comment
&lt;/h2&gt;

&lt;p&gt;There was a lot of different things that I need to consider. It was little bit confusing time to time but I managed to make decent website. It is always fun to make new website. One of my feature, uploading files view is not neat since I cannot use javascript. I am so excited for the future project that will be done using javascript. I will do much more and efficient way than this one.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Website: Poison</title>
      <dc:creator>Cicada0315</dc:creator>
      <pubDate>Sat, 27 Mar 2021 02:19:50 +0000</pubDate>
      <link>https://dev.to/cicada0315/website-poison-4foc</link>
      <guid>https://dev.to/cicada0315/website-poison-4foc</guid>
      <description>&lt;h2&gt;
  
  
  Step1: Deciding type of website
&lt;/h2&gt;

&lt;p&gt;I was thinking either making dog website or cocktail website since I love both of them. I ended up deciding cocktail website. &lt;/p&gt;

&lt;h4&gt;
  
  
  TheCocktailDB API: &lt;a href="https://www.thecocktaildb.com/api.php"&gt;https://www.thecocktaildb.com/api.php&lt;/a&gt;
&lt;/h4&gt;

&lt;h2&gt;
  
  
  Step2: Getting Data
&lt;/h2&gt;

&lt;p&gt;I want to get all the cocktails so I used my base as List all cocktails by first letter (&lt;a href="https://www.thecocktaildb.com/api/json/v1/1/search.php?f=a"&gt;https://www.thecocktaildb.com/api/json/v1/1/search.php?f=a&lt;/a&gt;) and changed f= as all the alphabet characters. I used gem 'httparty'.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@base_endpoint= "https://www.thecocktaildb.com/api/json/v1/1/search.php?f="
def get_cocktails_data
      char=[*('a'..'z')]
      #delete u and x since api doesn't contain any cocktail.
      char.delete('u') 
      char.delete('x')
      char.each do |alphabet|
        cocktail_url=@base_endpoint+alphabet
        cocktails_array=HTTParty.get(cocktail_url)["drinks"]
        self.create_cocktail_objects(cocktails_array)
      end
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step3: Making database
&lt;/h2&gt;

&lt;p&gt;Using rake and sqlite3, created tables(cocktails, users) and added data that I got from API.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rake db:create_migration NAME=create_cocktails
rake db:create_migration NAME=create_users
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class CreateCocktails &amp;lt; ActiveRecord::Migration[5.2]
  def change
    create_table :cocktails do |t|
      t.string :name
      t.string :glass
      t.string :ingredient
      t.string :instruction
      t.string :image
    end
  end
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class CreateUsers &amp;lt; ActiveRecord::Migration[5.2]
  def change
    create_table :users do |t|
      t.string :name
      t.date :birthday
      t.string :email
      t.string :password_digest

      t.timestamps
    end
  end
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rake db:migrate
rake db:seed
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step4: Building MVC
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Model
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;cocktail.rb (belongs_to user)&lt;/li&gt;
&lt;li&gt;user.rb (has_many cocktails)&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  View
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;layout.erb&lt;/li&gt;
&lt;li&gt;welcome.erb &lt;/li&gt;
&lt;li&gt;index.erb&lt;/li&gt;
&lt;li&gt;users: new.erb&lt;/li&gt;
&lt;li&gt;sessions: new.erb&lt;/li&gt;
&lt;li&gt;cocktails: &lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;edit.erb&lt;/li&gt;
&lt;li&gt;index.erb&lt;/li&gt;
&lt;li&gt;new.erb&lt;/li&gt;
&lt;li&gt;show.erb&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Controller
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;application_controller.rb&lt;/li&gt;
&lt;li&gt;cocktail_controller.rb&lt;/li&gt;
&lt;li&gt;sessions_controller.rb&lt;/li&gt;
&lt;li&gt;users_controller.rb&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Step5: CRUD(Create, Read, Update, Delete)
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Create
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;get '/cocktails/new' do
        redirect_if_not_logged_in
        erb :'cocktails/new'
end

post '/cocktails' do
        cocktail = current_user.cocktails.build(params[:cocktail])

        if cocktail.save
            redirect "/cocktails/#{cocktail.id}"
        else
            flash[:error] = "#{cocktail.errors.full_messages.join(", ")}"
            redirect "/cocktails/new"
        end
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Read
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;get '/cocktails' do
        @cocktails = current_user.cocktails
        erb :'cocktails/index'
end

get '/cocktails/:id' do
        @cocktail=Cocktail.find(params[:id])
        erb :'cocktails/show'
end

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Update
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;get '/cocktails/:id/edit' do
        erb :'cocktails/edit'
end

patch '/cocktails/:id' do
        redirect_if_not_logged_in
        redirect_if_not_authorized

        if @cocktail.update(params["cocktail"])
            redirect "/cocktails/#{@cocktail.id}"
        else
            redirect "/cocktails/#{@cocktail.id}/edit"
        end
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Delete
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;delete "/cocktails/:id" do
        @cocktail.destroy
        redirect "/cocktails"
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step6: Front-end (Making look nicer)
&lt;/h2&gt;

&lt;p&gt;I used below links mostly to make my website look nicer and I got help from Laura Berge and Eriberto Guzman (thank you).&lt;/p&gt;

&lt;h4&gt;
  
  
  Bootstrap: &lt;a href="https://getbootstrap.com/"&gt;https://getbootstrap.com/&lt;/a&gt;
&lt;/h4&gt;

&lt;h4&gt;
  
  
  W3schools: &lt;a href="https://www.w3schools.com/"&gt;https://www.w3schools.com/&lt;/a&gt;
&lt;/h4&gt;

&lt;h2&gt;
  
  
  Future
&lt;/h2&gt;

&lt;p&gt;I will make another join table called party which users can share their cocktail list to make a shopping list for the party. &lt;/p&gt;

</description>
    </item>
    <item>
      <title>MarvelBattle#ruby</title>
      <dc:creator>Cicada0315</dc:creator>
      <pubDate>Fri, 26 Feb 2021 14:36:20 +0000</pubDate>
      <link>https://dev.to/cicada0315/marvelbattle-ruby-2ka7</link>
      <guid>https://dev.to/cicada0315/marvelbattle-ruby-2ka7</guid>
      <description>&lt;p&gt;Keep thinking then you can find a better way to do things. But, if you stuck more than an hour for one thing, stop! You are not going to get anywhere. Try to rest for a while and try again. Fresh view will help you figure out. -Cicada&lt;/p&gt;

&lt;h2&gt;
  
  
  Day1
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Step1: Pick an API
&lt;/h3&gt;

&lt;p&gt;Deciding which API you are going to use is not esay yet, most important step. Try to see what is available to you and match with what you want to make. I want my program to be fun and efficient so I made my decision with Marvel API! &lt;/p&gt;

&lt;h5&gt;
  
  
  Marvel API: &lt;a href="https://developer.marvel.com/"&gt;https://developer.marvel.com/&lt;/a&gt;
&lt;/h5&gt;

&lt;h5&gt;
  
  
  API list link: &lt;a href="https://apilist.fun/"&gt;https://apilist.fun/&lt;/a&gt;
&lt;/h5&gt;

&lt;p&gt;NOTE: Some API is easy to access but some of them you need to sign-up&lt;/p&gt;

&lt;h3&gt;
  
  
  Step2: Make connection to Marvel API
&lt;/h3&gt;

&lt;h4&gt;
  
  
  1. Get an API Key:
&lt;/h4&gt;

&lt;p&gt;In order to use marvel API, you have to sign up and get a key&lt;/p&gt;

&lt;h4&gt;
  
  
  2. Creating url that can connect to marvel API:
&lt;/h4&gt;

&lt;p&gt;I want to get the list of all the marvel characters and this was what I used.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="n"&gt;base_endpoint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"https://gateway.marvel.com"&lt;/span&gt;
&lt;span class="n"&gt;ts&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="no"&gt;Time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;to_i&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;to_s&lt;/span&gt;
&lt;span class="n"&gt;url_hash&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="no"&gt;Digest&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="no"&gt;MD5&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;hexdigest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="n"&gt;ts&lt;/span&gt;&lt;span class="si"&gt;}#{&lt;/span&gt;&lt;span class="no"&gt;PRIVATEKEY&lt;/span&gt;&lt;span class="si"&gt;}#{&lt;/span&gt;&lt;span class="no"&gt;PUBLICKEY&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;base_endpoint&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="s2"&gt;"/v1/public/characters?ts=&lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="n"&gt;ts&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;&amp;amp;apikey=&lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="no"&gt;PUBLICKEY&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;&amp;amp;hash=&lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="n"&gt;url_hash&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  More info: &lt;a href="https://developer.marvel.com/documentation/generalinfo"&gt;https://developer.marvel.com/documentation/generalinfo&lt;/a&gt;
&lt;/h5&gt;

&lt;h2&gt;
  
  
  Day2 &amp;amp; 3
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Feature1: Display all the characters by it's name
&lt;/h3&gt;

&lt;p&gt;Using connection with marvel api, I made each character's object that contains below information.&lt;/p&gt;

&lt;h6&gt;
  
  
  Character {
&lt;/h6&gt;

&lt;h6&gt;
  
  
  id (int, optional): The unique ID of the character resource.,
&lt;/h6&gt;

&lt;h6&gt;
  
  
  name (string, optional): The name of the character.,
&lt;/h6&gt;

&lt;h6&gt;
  
  
  description (string, optional): A short bio or description of the character.,
&lt;/h6&gt;

&lt;h6&gt;
  
  
  modified (Date, optional): The date the resource was most recently modified.,
&lt;/h6&gt;

&lt;h6&gt;
  
  
  resourceURI (string, optional): The canonical URL identifier for this resource.,
&lt;/h6&gt;

&lt;h6&gt;
  
  
  urls (Array[Url], optional): A set of public web site URLs for the resource.,
&lt;/h6&gt;

&lt;h6&gt;
  
  
  thumbnail (Image, optional): The representative image for this character.,
&lt;/h6&gt;

&lt;h6&gt;
  
  
  comics (ComicList, optional): A resource list containing comics which feature this character.,
&lt;/h6&gt;

&lt;h6&gt;
  
  
  stories (StoryList, optional): A resource list of stories in which this character appears.,
&lt;/h6&gt;

&lt;h6&gt;
  
  
  events (EventList, optional): A resource list of events in which this character appears.,
&lt;/h6&gt;

&lt;h6&gt;
  
  
  series (SeriesList, optional): A resource list of series in which this character appears.
&lt;/h6&gt;

&lt;p&gt;}&lt;/p&gt;

&lt;h5&gt;
  
  
  link: &lt;a href="https://developer.marvel.com/docs#!/public/getCreatorCollection_get_0"&gt;https://developer.marvel.com/docs#!/public/getCreatorCollection_get_0&lt;/a&gt;
&lt;/h5&gt;

&lt;p&gt;Once you made character objects then simply calling down code will give you list of marvel characters&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;display_characters&lt;/span&gt;
  &lt;span class="no"&gt;Marvel_Characters&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;all&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;each&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;with_index&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;character&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;
    &lt;span class="nb"&gt;puts&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;. &lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="n"&gt;character&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;name&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
  &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;

&lt;span class="c1"&gt;#Welcome to MarvelBattle&lt;/span&gt;
&lt;span class="c1"&gt;#We always fight for justice!&lt;/span&gt;
&lt;span class="c1"&gt;#1. 3-D Man&lt;/span&gt;
&lt;span class="c1"&gt;#2. A-Bomb (HAS)&lt;/span&gt;
&lt;span class="c1"&gt;#3. A.I.M.&lt;/span&gt;
&lt;span class="c1"&gt;#4. Aaron Stack&lt;/span&gt;
&lt;span class="c1"&gt;#5. Abomination (Emil Blonsky)&lt;/span&gt;
&lt;span class="c1"&gt;#6. Abomination (Ultimate)&lt;/span&gt;
&lt;span class="c1"&gt;#7. Absorbing Man&lt;/span&gt;
&lt;span class="c1"&gt;#8. Abyss&lt;/span&gt;
&lt;span class="c1"&gt;#9. Abyss (Age of Apocalypse)&lt;/span&gt;
&lt;span class="c1"&gt;#10. Adam Destine&lt;/span&gt;
&lt;span class="o"&gt;...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;NOTE: when getting characters the default is only 20 but there is total of 1493 characters so if you want to get more characters you have to change offset.&lt;/p&gt;

&lt;h3&gt;
  
  
  Feature2: Show user choice of character's information
&lt;/h3&gt;

&lt;p&gt;Interact with user via termial. I gave options to user so that they can see detailed information of each of the character that they choose.&lt;/p&gt;

&lt;h6&gt;
  
  
  Character_information option:
&lt;/h6&gt;

&lt;h6&gt;
  
  
  Enter 1: Image
&lt;/h6&gt;

&lt;h6&gt;
  
  
  Enter 2: Abilities
&lt;/h6&gt;

&lt;h6&gt;
  
  
  Enter 3: Comics
&lt;/h6&gt;

&lt;h6&gt;
  
  
  Enter 4: Series
&lt;/h6&gt;

&lt;h6&gt;
  
  
  Enter 5: Description
&lt;/h6&gt;

&lt;h3&gt;
  
  
  Feature3: MarvelBattle (User vs Computer)
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Step1: Geting each of the character's ability.
&lt;/h4&gt;

&lt;p&gt;This was really tricky since I cannot get this information directly. I used 'nokogiri' to able to make it work (scraping). I tried add this ability to each of the object when I make the character's object for the first time but it took so long since I have total of 1493 characters. I end up deceide add ability only when user want to see the ability of the character or when they are ready to play. (which gives me 1 vs 1493 or 6 vs 1493) &lt;/p&gt;

&lt;h4&gt;
  
  
  Step2: Play setting
&lt;/h4&gt;

&lt;p&gt;When user select three character, computer will choose ramdom three characters as well. then user is ready to play!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;initialize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;player&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;computer&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="nb"&gt;puts&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="n"&gt;player&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;name&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; VS Computer"&lt;/span&gt;
  &lt;span class="nb"&gt;puts&lt;/span&gt; &lt;span class="s2"&gt;"Match1: &lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="n"&gt;player&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;my_characters_arr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;name&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; VS &lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="n"&gt;computer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;character_arr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;name&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
  &lt;span class="nb"&gt;puts&lt;/span&gt; &lt;span class="s2"&gt;"----------------------------------"&lt;/span&gt;
  &lt;span class="nb"&gt;puts&lt;/span&gt; &lt;span class="s2"&gt;"Match2: &lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="n"&gt;player&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;my_characters_arr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;name&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; VS &lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="n"&gt;computer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;character_arr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;name&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
  &lt;span class="nb"&gt;puts&lt;/span&gt; &lt;span class="s2"&gt;"----------------------------------"&lt;/span&gt;
  &lt;span class="nb"&gt;puts&lt;/span&gt; &lt;span class="s2"&gt;"Match3: &lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="n"&gt;player&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;my_characters_arr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;name&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; VS &lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="n"&gt;computer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;character_arr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;name&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
  &lt;span class="nb"&gt;puts&lt;/span&gt; &lt;span class="s2"&gt;"----------------------------------"&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="c1"&gt;#Username VS Computer&lt;/span&gt;
&lt;span class="c1"&gt;#Match1: A-Bomb (HAS) VS Agent Brand&lt;/span&gt;
&lt;span class="c1"&gt;#----------------------------------&lt;/span&gt;
&lt;span class="c1"&gt;#Match2: 3-D Man VS Air-Walker (Gabriel Lan)&lt;/span&gt;
&lt;span class="c1"&gt;#----------------------------------&lt;/span&gt;
&lt;span class="c1"&gt;#Match3: A.I.M. VS 3-D Man&lt;/span&gt;
&lt;span class="c1"&gt;#----------------------------------&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Day4
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Play
&lt;/h3&gt;

&lt;p&gt;Each of the marvel character has six abilities with rate. &lt;br&gt;
[durability, energy, fighting_skills, intelligence, speed, strength]&lt;br&gt;
Each match, program will compute each character's ability and tells you which character won for that match. When you enter 4 will tells you who won the battle.&lt;/p&gt;

&lt;h6&gt;
  
  
  Enter 1: Match1
&lt;/h6&gt;

&lt;h6&gt;
  
  
  Enter 2: Match2
&lt;/h6&gt;

&lt;h6&gt;
  
  
  Enter 3: Match3
&lt;/h6&gt;

&lt;h6&gt;
  
  
  Enter 4: Winner of this battle
&lt;/h6&gt;

&lt;h6&gt;
  
  
  Enter 5: Go back to option
&lt;/h6&gt;

&lt;h6&gt;
  
  
  Enter 6: To end the program
&lt;/h6&gt;

&lt;h3&gt;
  
  
  Future
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Impovement1: Able to show image in new browser when using wsl
&lt;/h4&gt;

&lt;p&gt;For now I made error handling block for the image, it's not working with wsl. I will keep working on that to able to show image in new browser even when using wsl.&lt;/p&gt;

&lt;h4&gt;
  
  
  Improvement2: Make a game more interactive
&lt;/h4&gt;

&lt;p&gt;For now porgram jsut computes each of the character's each of the character's ability and show the result. In the future I want to make it more interactive like give option to user so that they can choose ability they want to use for attack or defends.&lt;/p&gt;

&lt;p&gt;This was my first project using ruby. Some of the part was hard but most of time it was fun. I hope this blog helps when you are acutally runing my program or trying to make new program with Marvel API.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Why Software Engineering?</title>
      <dc:creator>Cicada0315</dc:creator>
      <pubDate>Sat, 06 Feb 2021 15:29:46 +0000</pubDate>
      <link>https://dev.to/cicada0315/why-software-engineering-53mc</link>
      <guid>https://dev.to/cicada0315/why-software-engineering-53mc</guid>
      <description>&lt;p&gt;System.out.println("Hello")&lt;br&gt;
puts "My name is Jean."&lt;br&gt;
print "Nice to see you"&lt;/p&gt;

&lt;p&gt;I learned Java last few years and I am learning Ruby and Python nowadays. Every language seems similar but different. It's interesting to learn how each language works. I enjoy the ability to create an actual working, moving program from lines of code. It’s really fascinating that everything associated with programs on computers work through lines of code. &lt;/p&gt;

&lt;p&gt;Coding is sometimes challenging. It's like a puzzle. Sometime, I stuck whole day to try to figure out how to make it work and try to make it more efficient. I really enjoy the journey of trying to figure out how to make a program work. I'm over the moon when the program that I worked on whole day finally working! I bet all the programmers feel the same:)&lt;/p&gt;

&lt;p&gt;"Welcome every problem as an opportunity. Each moment is the great challenge, the best thing that ever happened to you. The more difficult the problem, the greater the challenge in working it out." - Grace Speare, Author&lt;/p&gt;

&lt;p&gt;As the technology industry growing, computers have become a major part of our lives today. Privacy and security are becoming major concerns as well. In the future, I want to contribute to making a safe networking environment for people when they use their computers.&lt;/p&gt;

&lt;p&gt;P.S. this is my first blog. I hope you have more understanding about me.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
