<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Koçfinans Tech - Medium]]></title>
        <description><![CDATA[Koçfinans teknoloji ekibi olarak, gündelik hayatta karşılaştığımız sorunları ve ürettiğimiz çözümleri paylaşıyoruz. Keyifli okumalar … https://www.youtube.com/channel/UC53JjHAd3C1gf8_tiZQfPJw - Medium]]></description>
        <link>https://medium.com/kocfinanstech?source=rss----69145647485---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Koçfinans Tech - Medium</title>
            <link>https://medium.com/kocfinanstech?source=rss----69145647485---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 00:31:21 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/kocfinanstech" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Query Service with Spring Data Specification And Factory Design Pattern]]></title>
            <link>https://medium.com/kocfinanstech/query-service-with-spring-data-specification-and-factory-design-pattern-c7059c8ff27c?source=rss----69145647485---4</link>
            <guid isPermaLink="false">https://medium.com/p/c7059c8ff27c</guid>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[factory-pattern]]></category>
            <category><![CDATA[dynamic-query]]></category>
            <category><![CDATA[spring-data]]></category>
            <category><![CDATA[specifications]]></category>
            <dc:creator><![CDATA[Baris Eroglu ]]></dc:creator>
            <pubDate>Thu, 29 Jun 2023 18:36:52 GMT</pubDate>
            <atom:updated>2023-06-29T18:36:52.260Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qp_TmPYzInW4gixIrdv5zw.png" /></figure><h3>Introduction</h3><p>In big software architectures, mostly there are huge tables which stores important data and usually more than one applications connect and execute database queries to communicate with it. Since several projects connect to the same table, this creates code duplications (entity, repository classes etc.) in different applications. When we think about huge tables with hundreds of columns, those duplications become a nightmare.</p><p>In this article, I will try to give you an alternate solution for this problem and we will be doing that with a <strong><em>db-query-service</em></strong>.</p><h3>Service Architecture</h3><p>The name of the service (db-query-service) indicates that we will be executing different and complicated database queries. It will be a restful API using Spring Boot with Spring Data Specification.</p><h3>Spring Data Specification vs Spring Data JPA</h3><p>If you used Spring Boot before, you probably used Spring Data JPA to execute database queries. It is really simple and fast to learn. You just create a repository class and write some methods to create database queries.</p><pre>interface PlayerRepository extends JpaRepository&lt;Player, Long&gt; {<br>  <br>  List&lt;Player&gt; findAll();<br><br>  List&lt;Player&gt; findAllByNameLike(String name);<br><br>}</pre><p>However, it becomes a nightmare for developers when it comes to read complicated queries like this:</p><pre>interface PlayerRepository extends JpaRepository&lt;Player, Long&gt; {<br><br>  List&lt;Player&gt; findByNameStartingWithAndSurnameLikeAndAgeAndHeightGreaterThanAndTeamIn(String name,<br>                                                                                       String surname,<br>                                                                                       int age,<br>                                                                                       double height,<br>                                                                                       List&lt;String&gt; teams);<br>}</pre><p>We can simplify the query execution process with specifications and make them more flexible.</p><p>When using Spring Data Specifications, we create every part of the query one by one. For example, to query an attribute with “<strong><em>like”</em></strong> , we can create a method like:</p><pre>Specification&lt;Product&gt; nameLike = <br>      (root, query, criteriaBuilder) -&gt; <br>         criteriaBuilder.like(root.get(Product_.NAME), &quot;%&quot;+name+&quot;%&quot;);</pre><p>Specification strategy makes it flexible to create complicated queries, because we can define each criteria separately and combine them as we want. (For further readings about Spring Data Specifications, you can visit the <a href="https://reflectoring.io/spring-data-specifications/">Spring Data Specification Reading</a>.)</p><h3>Creating db-query-service</h3><p>Firstly, I want to show you the entity we are working on. This entity has the information of some NBA players.</p><pre>@Getter<br>@NoArgsConstructor<br>@Entity<br>public class Player {<br><br>    @Id<br>    @GeneratedValue(strategy = GenerationType.IDENTITY)<br>    private long id;<br>    private String name;<br>    private String surname;<br>    private String team;<br>    private int age;<br>    private double height;<br>    private int weight;<br>}</pre><p>In our service, we aim to generate complex db-queries for the Player entity from a json request like:</p><pre>{<br>    &quot;filterList&quot;: [<br>        {<br>            &quot;name&quot;: &quot;team&quot;,<br>            &quot;value&quot;: &quot;Celtics&quot;,<br>            &quot;operation&quot;: &quot;EQUALS&quot;<br>        }<br>    ]<br>}</pre><ul><li>“name” attribute indicates the column name.</li><li>“value” attribute will be the value to associate with column</li><li>“operation” will be the association type like equals, greater, less, in, like etc.</li></ul><p>For the definition of operations, we will be using the following enum class. These are the first operations that come to mind when writing select SQL queries.</p><pre>@AllArgsConstructor<br>@Getter<br>public enum OperationType {<br><br>    CONTAINS(ContainsCriteria.class),<br>    NOT_CONTAIN(NotContainsCriteria.class),<br>    EQUALS(EqualsCriteria.class),<br>    NOT_EQUAL(NotEqualsCriteria.class),<br>    BEGINS_WITH(BeginsWithCriteria.class),<br>    NOT_BEGIN_WITH(NotBeginsWithCriteria.class),<br>    ENDS_WITH(EndsWithCriteria.class),<br>    NOT_ENDS_WITH(NotEndsWithCriteria.class),<br>    NULL(NullCriteria.class),<br>    NOT_NULL(NotNullCriteria.class),<br>    GREATER_THAN(GreaterCriteria.class),<br>    GREATER_THAN_EQUAL(GreaterEqualsCriteria.class),<br>    LESS_THAN(LessCriteria.class),<br>    LESS_THAN_EQUAL(LessEqualCriteria.class),<br>    AFTER(AfterCriteria.class),<br>    BEFORE(BeforeCriteria.class);<br><br>    private final Class&lt;?&gt; criteria;<br>}</pre><p>You will see a criteria parameter for enum class. This is the connection between criteria and operation names. For every SQL operation, there is a criteria method to execute and those methods are in criteria classes. For example here is the ContainsCriteria class:</p><pre>public class ContainsCriteria extends Criteria {<br><br>    @Override<br>    public Predicate build(CriteriaModel model) {<br>        return model.cb().like(<br>                model.root().get(model.filterInfo().getName()),<br>                &quot;%&quot; + model.filterInfo().getValue() + &quot;%&quot;<br>        );<br>    }<br>}</pre><p>We have a Criteria model which simplifies the method parameters. It has criteria builder and root objects to define criteria and FilterInfo object to access requested values. Here is the CriteriaModel record.</p><pre>public record CriteriaModel(CriteriaBuilder cb,<br>                             Root&lt;?&gt; root,<br>                             FilterInfo filterInfo) {<br>                            <br>}</pre><p>Since our solution is to create dynamic SQL operations, we are using a creational design pattern: <strong><em>Factory Design Pattern</em></strong>. OperationType enum class has the information that which operation type will be created due to the requested operation. To use that information and create the criteria classes, we are going to create a factory class like:</p><pre>@Override<br>public Criteria createCriteria(OperationType operationType) {<br>    Class&lt;?&gt; criteriaClass = operationType.getCriteria();<br><br>    return (Criteria) criteriaClass.getConstructor().newInstance();<br>}</pre><p>Factory pattern is successful and we create the operations now. (If you want to learn a bit more about Factory Pattern you can visit the <a href="https://refactoring.guru/design-patterns/factory-method">link</a>) Then, we are going to create the Specification class which will be executing created criteria methods and returns to the service layer. (We are still in the repository layer if we think about the project architecture)</p><pre>@AllArgsConstructor<br>public class PlayerSpecification implements Specification&lt;Player&gt; {<br><br>    private final FilterInfo filterInfo;<br><br>    @Override<br>    public Predicate toPredicate(@NonNull Root&lt;Player&gt; root, @NonNull CriteriaQuery&lt;?&gt; query, @NonNull CriteriaBuilder criteriaBuilder) {<br><br>        try {<br>            Criteria criteria = new PlayerCriteriaFactory().createCriteria(filterInfo.getOperation());<br>            return criteria.build(new CriteriaModel(criteriaBuilder, root, filterInfo));<br>        } catch ( Exception e ) {<br>            throw new CriteriaBuildException(filterInfo);<br>        }<br>    }<br>}</pre><p>Finally here it is, the service layer. It obtains the request, then dynamically creates specifications and combine them. As you can see, operations combined with <strong><em>“and”</em></strong> operator. Maybe it can be made dynamic due to the request as well, but we are not going to do that in this article 😂.</p><p>In the last step, PlayerRepository executes the findAll method to find all those created specifications.</p><pre>@AllArgsConstructor<br>public class PlayerSpecification implements Specification&lt;Player&gt; {<br><br>    private final FilterInfo filterInfo;<br><br>    @Override<br>    public Predicate toPredicate(@NonNull Root&lt;Player&gt; root, @NonNull CriteriaQuery&lt;?&gt; query, @NonNull CriteriaBuilder criteriaBuilder) {<br><br>        try {<br>            Criteria criteria = new PlayerCriteriaFactory().createCriteria(filterInfo.getOperation());<br>            return criteria.build(new CriteriaModel(criteriaBuilder, root, filterInfo));<br>        } catch ( Exception e ) {<br>            throw new CriteriaBuildException(filterInfo);<br>        }<br>    }<br>}</pre><pre>public interface PlayerRepository extends JpaRepository&lt;Player, Long&gt;, JpaSpecificationExecutor&lt;Player&gt; {<br>}</pre><p>Now let’s do some testing.</p><h3>Tests</h3><p>I created a docker container to start a PostgreSQL database and created a table which includes some information about the NBA players.</p><p>When we want to find NBA Players which are older than 25, the JSON request should be like this:</p><pre>{<br>    &quot;filterList&quot;: [<br>        {<br>            &quot;name&quot;: &quot;age&quot;,<br>            &quot;value&quot;: 25,<br>            &quot;operation&quot;: &quot;GREATER_THAN&quot;<br>        }<br>    ]<br>}</pre><p>The result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6ofK4ylWRoebXDFXJhy8Fw.png" /></figure><p>When we want to find the NBA Players, which has the name that begins with “D” letter, the JSON request should be:</p><pre>{<br>    &quot;filterList&quot;: [<br>        {<br>            &quot;name&quot;: &quot;name&quot;,<br>            &quot;value&quot;: &quot;D&quot;,<br>            &quot;operation&quot;: &quot;BEGINS_WITH&quot;<br>        }<br>    ]<br>}</pre><p>The result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j-b1mgo1jPBK-gLx9Edh4Q.png" /></figure><h3>Conclusion</h3><p>In this article, I try to explain how to create SQL operations dynamically in a Spring Boot project with the use of Spring Data Specification and Factory Design Pattern. Also, I explained the advantages of Data Specification over Data JPA in some scenarios. If you want to see all code, you can check the <a href="https://github.com/ErogluBaris/db-query-service">github repository</a>.</p><p>The mock database which I queried in my tests was created manually and there are really little data. In order to make some more realistic tests and compare the performance of the db-query-service, we will be using real NBA data in future articles.</p><p>Thanks for reading,</p><p>I wish you happy coding.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c7059c8ff27c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/kocfinanstech/query-service-with-spring-data-specification-and-factory-design-pattern-c7059c8ff27c">Query Service with Spring Data Specification And Factory Design Pattern</a> was originally published in <a href="https://medium.com/kocfinanstech">Koçfinans Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using Zustand as a state management library]]></title>
            <link>https://medium.com/kocfinanstech/using-zustand-as-a-state-management-library-6893bd969526?source=rss----69145647485---4</link>
            <guid isPermaLink="false">https://medium.com/p/6893bd969526</guid>
            <category><![CDATA[state-management]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[zustand]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Mert Genç]]></dc:creator>
            <pubDate>Fri, 30 Dec 2022 06:49:47 GMT</pubDate>
            <atom:updated>2022-12-30T06:49:47.895Z</atom:updated>
            <content:encoded><![CDATA[<p>Hi, friends.</p><p>In this article, I’m going to explain one of the best state management library for React projects. It’s <a href="https://github.com/pmndrs/zustand"><em>Zustand</em></a>. It means “state” in German :)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*XH2TqZCW2n_nsNDR" /></figure><p>Firstly, zustand created by developers of <a href="https://jotai.org/">jotai</a> and <a href="https://react-spring.dev/">React-Spring</a>. Before the implementation of that, I want to talk about some features about Zustand.</p><h3>Features:</h3><ul><li>Compared to others, zustand is very simple and readable. It easy to use and install.</li><li>Zustand is modern. It uses modern React Hooks API.</li><li>Less boilerplate code</li><li>Providing clean code architecture</li><li>Fully written typescript. Which makes it typesafe.</li><li>It’s easy to write test cases</li><li>It supports micro states</li><li>Don’t need to wrap your app bunch of providers unlike Context API, Redux</li></ul><h3>Setting up an app</h3><p>Create a react app with CRA:</p><pre>yarn create react-app zustand-example --template typescript<br>cd zustand-example<br>yarn add zustand</pre><p>While using zustand, you don’t need to use providers. Your state is a hook:</p><pre>// useCounterState.ts<br>import create from &quot;zustand&quot;;<br>type CounterStore = {<br>  count: number;<br>  increment: () =&gt; void;<br>  decrement: () =&gt; void;<br>};<br>// using the create with generics<br>export const useCounterStore = create&lt;CounterStore&gt;((set) =&gt; ({<br>  count: 0,<br>  increment: () =&gt; set((state) =&gt; ({ count: state.count + 1 })),<br>  decrement: () =&gt; set((state) =&gt; ({ count: state.count - 1 })),<br>}));<br>// import { combine } from &#39;zustand/middleware&#39;<br>// using the combine api to combine multiple stores<br>// export const useCounterStore = create(<br>//   combine({ count: 0 as number }, (set) =&gt; ({<br>//     increment: () =&gt; set((state) =&gt; ({ count: state.count + 1 })),<br>//     decrement: () =&gt; set((state) =&gt; ({ count: state.count - 1 })),<br>//   }))<br>// );</pre><p>After the creating your state setup, you can easily access your state:</p><pre>import { useCounterStore } from &quot;../store/useCounterStore&quot;;<br>type Props = {};<br>const Counter: React.FC&lt;Props&gt; = (props) =&gt; {<br>  const counterStore = useCounterStore();<br>  return (<br>    &lt;div className=&quot;counter-container&quot;&gt;<br>      &lt;h1&gt;Zustand API Example ✨&lt;/h1&gt;<br>      &lt;div&gt;<br>        &lt;h1 className=&quot;counter-title&quot;&gt;Counter: {counterStore.count}&lt;/h1&gt;<br>        &lt;button className=&quot;counter-button&quot; onClick={counterStore.increment}&gt;<br>          +<br>        &lt;/button&gt;<br>        &lt;button className=&quot;counter-button&quot; onClick={counterStore.decrement}&gt;<br>          -<br>        &lt;/button&gt;<br>      &lt;/div&gt;<br>    &lt;/div&gt;<br>  );<br>};<br>export default Counter;</pre><p>Zustand has an amazing type system. You’re able to write an interface or type and put it into diamond operators. Another option is, creating your store with zustand/combine API. Combine API will infer types from your state object.</p><pre>// useCounterState.ts<br>import create from &quot;zustand&quot;;<br><br>import { combine } from &#39;zustand/middleware&#39;<br>// using the combine api to combine multiple stores<br>export const useCounterStore = create(<br>  combine({ count: 0 as number }, (set) =&gt; ({<br>    increment: () =&gt; set((state) =&gt; ({ count: state.count + 1 })),<br>    decrement: () =&gt; set((state) =&gt; ({ count: state.count - 1 })),<br>  }))<br>);</pre><p>using the combine API</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sYHQVAnfyAuZ7_i3GiilGw.png" /><figcaption>using the combine API inferring types from state object</figcaption></figure><h3>Nested States</h3><p>You can use nested state tree with <a href="https://github.com/immerjs/immer">immer</a>:</p><pre>type State = {<br>  deep: {<br>    nested: {<br>      obj: { count: number };<br>    };<br>  };<br>  increment: () =&gt; void;<br>};</pre><p>you need to merge state:</p><pre>import { produce } from &quot;immer&quot;;<br><br>const useNestedObjectStore = create&lt;State&gt;((set) =&gt; ({<br>  deep: {<br>    nested: {<br>      obj: {<br>        count: 0,<br>      },<br>    },<br>  },<br>  increment: () =&gt;<br>    set(<br>      produce((draft: State) =&gt; {<br>        draft.deep.nested.obj.count++;<br>      })<br>    ),<br>}));</pre><h3>Persisting States</h3><p>With zustand you can easily persist state with persist middleware. All you need to do is use persist function:</p><pre>import create from &quot;zustand&quot;;<br>import { persist } from &quot;zustand/middleware&quot;;<br><br>type CreditStore = {<br>  credit: number;<br>  increaseCredit: () =&gt; void;<br>};<br><br>export const useCreditStore = create(<br>  persist&lt;CreditStore&gt;(<br>    (set, get) =&gt; ({<br>      credit: 0,<br>      increaseCredit: () =&gt; set({ credit: get().credit + 1 }),<br>    }),<br>    {<br>      name: &quot;new-key&quot;, // unique name for this store <br>      getStorage: () =&gt; sessionStorage, // default is localStorage<br>    }<br>  )<br>);</pre><p>changing key and storage is so easy. For example you can easily use React Native AsyncStorage with persist middleware.</p><pre>getStorage: () =&gt; AsyncStorage, // default is localStorage</pre><h3>Using Redux-Like Actions</h3><p>If you are used to using redux, keep calm and use zustand:</p><pre>import create from &quot;zustand&quot;;<br><br>type NameStore = {<br>  firstName: string;<br>  lastName: string;<br>};<br><br>type Action = {<br>  updateFirstName: (firstName: string) =&gt; void;<br>  updateLastName: (lastName: string) =&gt; void;<br>};<br><br>export const useNameStore = create&lt;NameStore &amp; Action&gt;((set) =&gt; ({<br>  firstName: &quot;John&quot;,<br>  lastName: &quot;Doe&quot;,<br>  updateFirstName: (firstName: string) =&gt; set({ firstName }),<br>  updateLastName: (lastName: string) =&gt; set({ lastName }),<br>}));<br><br></pre><p>or:</p><pre>const types = { increase: &#39;INCREASE&#39;, decrease: &#39;DECREASE&#39; }<br><br>const reducer = (state: , { type, by = 1 }):  =&gt; {<br>  switch (type) {<br>    case types.increase:<br>      return { count: state.count + by }<br>    case types.decrease:<br>      return { count: state.count - by }<br>  }<br>}<br><br>const useStore = create((set) =&gt; ({<br>  count: 0,<br>  dispatch: (args) =&gt; set((state) =&gt; reducer(state, args)),<br>}))<br><br>const dispatch = useStore((state) =&gt; state.dispatch)<br>dispatch({ type: types.increase, by: 2 })</pre><h3>Using Devtools</h3><p>As in redux or react-query you can use devtools as middleware:</p><pre>import create from &quot;zustand&quot;;<br>import { devtools } from &quot;zustand/middleware&quot;;<br><br>type DevtoolsStore = {<br>  showDevtools: boolean;<br>  setShowDevtools: (showDevtools: boolean) =&gt; void;<br>};<br><br>const useDevtoolsStore = create(<br>  devtools&lt;DevtoolsStore&gt;( // using devtools middleware<br>    (set) =&gt; ({<br>      showDevtools: false,<br>      setShowDevtools: (showDevtools: boolean) =&gt; set({ showDevtools }),<br>    }),<br>    {<br>      enabled: process.env.NODE_ENV === &quot;development&quot;,<br>    }<br>  )<br>);<br><br>export default useDevtoolsStore;</pre><h3>Async actions</h3><p>Unlike redux or context API you don’t need to add any boilerplate code to using async actions. You can use normal javascript functions:</p><pre>import create from &quot;zustand&quot;;<br><br>const user = {<br>  id: 1,<br>  name: &quot;Leanne Graham&quot;,<br>  username: &quot;Bret&quot;,<br>  email: &quot;Sincere@april.biz&quot;,<br>  address: {<br>    street: &quot;Kulas Light&quot;,<br>    suite: &quot;Apt. 556&quot;,<br>    city: &quot;Gwenborough&quot;,<br>    zipcode: &quot;92998-3874&quot;,<br>    geo: {<br>      lat: &quot;-37.3159&quot;,<br>      lng: &quot;81.1496&quot;,<br>    },<br>  },<br>  phone: &quot;1-770-736-8031 x56442&quot;,<br>  website: &quot;hildegard.org&quot;,<br>  company: {<br>    name: &quot;Romaguera-Crona&quot;,<br>    catchPhrase: &quot;Multi-layered client-server neural-net&quot;,<br>    bs: &quot;harness real-time e-markets&quot;,<br>  },<br>};<br><br>type User = typeof user;<br><br>interface UserStore {<br>  user?: User;<br>  setUser: (user: User) =&gt; void;<br>  loading: boolean;<br>  fetchUser: () =&gt; Promise&lt;void&gt;;<br>  hasError: boolean;<br>}<br><br>export const useUserStore = create&lt;UserStore&gt;((set) =&gt; ({<br>  user: user,<br>  setUser: (user: User) =&gt; set({ user }),<br>  fetchUser: async () =&gt; {<br>    try {<br>      const response = await fetch(<br>        &quot;https://jsonplaceholder.typicode.com/users/1&quot;<br>      );<br>      const user = await response.json();<br>      set({ user });<br>    } catch (error) {<br>      set({ hasError: true });<br>    } finally {<br>      set({ loading: false });<br>    }<br>  },<br>  loading: false,<br>  hasError: false,<br>}));</pre><p>That’s so easy and readable.</p><h3>Accessing the state outside of components</h3><p>In zustand you can access state outside of component and even you can update your state outside of component.</p><p>For example, in this case let’s assume you need to access your accessToken inside state object and add to http header.</p><pre>import create from &quot;zustand&quot;;<br>import { combine } from &quot;zustand/middleware&quot;;<br>import axios from &quot;axios&quot;;<br><br>const useAuthStore = create(<br>  combine({ token: &quot;&quot; }, (set) =&gt; ({<br>    setToken: (token: string) =&gt; set({ token }),<br>    logout: () =&gt; set({ token: &quot;&quot; }),<br>  }))<br>);<br><br>const client = axios.create({<br>  baseURL: &quot;http://localhost:3000&quot;,<br>  headers: {<br>    &quot;Content-Type&quot;: &quot;application/json&quot;,<br>  },<br>});<br><br>const injectToken = client.interceptors.request.use(<br>  async (config) =&gt; {<br>    const token = useAuthStore.getState().token;<br>    config.headers.set(&quot;Authorization&quot;, `Bearer ${token}`);<br>    return config;<br>  },<br>  (error) =&gt; {<br>    return Promise.reject(error);<br>  }<br>);<br><br>const responseInterceptor = client.interceptors.response.use(<br>  (response) =&gt; {<br>    return response;<br>  },<br>  (error) =&gt; {<br>    if (error.response.status === 401) {<br>      useAuthStore.getState().logout();<br>    }<br>    return Promise.reject(error);<br>  }<br>);</pre><p>This is so simple and readable. Also you can subscribe to store:</p><pre>const useAuthStore = create(<br>  subscribeWithSelector(<br>    combine({ token: &quot;&quot; }, (set) =&gt; ({<br>      setToken: (token: string) =&gt; set({ token }),<br>      logout: () =&gt; set({ token: &quot;&quot; }),<br>    }))<br>  )<br>);</pre><p>You can subscribe a field with subcribeWithSelector API.</p><pre>const unsub1 = useAuthStore.subscribe(<br>  (state) =&gt; state.token,<br>  (token) =&gt; {<br>    console.log(&quot;token&quot;, token);<br>    // do something with token<br>  }<br>);<br><br>unsub(); // unsubscribe<br>// or <br>useAuthStore.destroy(); // unsubscribe all</pre><p>As you see it’s so simple to manage states with zustand. If you want to see more detail docs, you can read from <a href="https://docs.pmnd.rs/zustand/getting-started/introduction">here</a>.</p><p>See you next article!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6893bd969526" width="1" height="1" alt=""><hr><p><a href="https://medium.com/kocfinanstech/using-zustand-as-a-state-management-library-6893bd969526">Using Zustand as a state management library</a> was originally published in <a href="https://medium.com/kocfinanstech">Koçfinans Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to add React Navigation in current project with Typescript]]></title>
            <link>https://medium.com/kocfinanstech/how-to-add-react-navigation-in-current-project-with-typescript-b7862b532c9b?source=rss----69145647485---4</link>
            <guid isPermaLink="false">https://medium.com/p/b7862b532c9b</guid>
            <category><![CDATA[react-navigation-stack]]></category>
            <category><![CDATA[react-navigation]]></category>
            <category><![CDATA[react-native]]></category>
            <dc:creator><![CDATA[Derya Yalcinkaya]]></dc:creator>
            <pubDate>Thu, 17 Nov 2022 07:53:39 GMT</pubDate>
            <atom:updated>2022-11-17T07:53:39.402Z</atom:updated>
            <content:encoded><![CDATA[<p>React Navigation is a library that helps with routing and navigation.</p><p>It is easy to use and it supports both ios and android. It is also a customizable, and extensible platform.</p><h3>Installation</h3><p><em>Install the react-navigation package.</em></p><pre>$ yarn add @react-navigation/native</pre><p><em>2. Install dependencies..</em></p><pre>$ yarn add react-native-reanimated react-native-gesture-handler react-native-screens react-native-safe-area-context @react-native-community/masked-view</pre><pre><strong>react-native-reanimated</strong> <strong>-&gt;</strong> It provides a more comprehensive, low level abstraction for the Animated library API to be built on top of and hence allow for much greater flexibility especially when it comes to gesture based interactions.</pre><pre><strong>react-native-gesture-handler -&gt; </strong>It<strong> </strong>provides native-driven gesture management APIs for building best possible touch-based experiences in React Native.</pre><pre><strong>react-native-safe-area-context -&gt; </strong>A flexible way to handle safe area, also works on Android and Web!</pre><pre><strong>@react-native-community/masked-view -&gt; </strong><em>React Native MaskedView is not currently supported by Expo unless you &quot;eject&quot;.</em></pre><p><em>3. Add the following at the top of index.js or App.tsx.</em></p><pre><em>import</em> &#39;react-native-gesture-handler&#39;;</pre><p>If you’re developing for iOS, run the pod-install script.</p><pre>$ npx pod-install ios</pre><h3>Stack navigation</h3><p>Stack Navigator provides a way for your app to transition between screens where each new screen is placed on top of a stack.</p><pre>$ yarn add @react-navigation/stack</pre><p>Make ‘screens’ directory to contain screens.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ciNVzbjkD90-nhwj97JThA.png" /></figure><p>RootStackParams defines the screens on the Root path</p><h4><strong>MainNavigator.tsx</strong></h4><p>The createDrawerNavigator makes Stack navigator and screen component. Because we set the RootStackParams as generic, we can config each screen props easily .</p><p>We set initialRoute as Dashboard and the other screens in menus.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/971/1*F9rn8ncuMFkG9t95KGRyYA.png" /></figure><p><strong>Dashboard.tsx</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D1voQcj_hk6UiJouolr2HQ.png" /></figure><p><strong>IconButton.tsx</strong></p><p>We created a new component to redirect the dashboard to other screens.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-t2u-N3by9e6XTaldpDZDQ.png" /></figure><p>When you re-run the app , navigation is shown!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1014/1*9yuQFnBy2DMFbCNCbrhPXw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b7862b532c9b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/kocfinanstech/how-to-add-react-navigation-in-current-project-with-typescript-b7862b532c9b">How to add React Navigation in current project with Typescript</a> was originally published in <a href="https://medium.com/kocfinanstech">Koçfinans Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Performance Testing with JMeter]]></title>
            <link>https://medium.com/kocfinanstech/jmeter-ile-performans-testi-e1e23c311307?source=rss----69145647485---4</link>
            <guid isPermaLink="false">https://medium.com/p/e1e23c311307</guid>
            <dc:creator><![CDATA[Emre Dogangun]]></dc:creator>
            <pubDate>Tue, 21 Jun 2022 14:03:15 GMT</pubDate>
            <atom:updated>2022-06-21T14:03:15.051Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*tQN7s2Wl1Mf9QREayQpKhg.jpeg" /></figure><h3>Performance Test What is it?</h3><p>Performance testing is for detecting bottlenecks in the application, not bugs of software applications. It measures the performance quality of the application. Basically, a software; It focuses on certain features such as speed, stability and scalability.</p><p>Our first step is to download JMeter. You can download it from this address. <a href="https://jmeter.apache.org/download_jmeter.cgi">https://jmeter.apache.org/download_jmeter.cgi</a></p><p>Extract the downloaded zip to the folder and unzip the bin file and click Jmeter to open it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e18NaQ2Mgot9fMAS4IMlbw.png" /></figure><p>Right click on existing Test Plan and create a Thread Group.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ewrl7VYSqC94CJtA5vH29w.png" /></figure><p>In this section we will make some configs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ujXW7FzJ0boCKj5h7IUDdg.png" /></figure><ul><li><strong>Number of Threads (users): </strong>The number of users connecting to the target server.</li><li><strong>Ramp-up period (seconds): </strong>The time it takes for all users to log into the system and end the test.</li><li><strong>Loop Count: </strong>Defines how many times the test will be run.</li></ul><p>In the above part; It is seen that with 10 users, 10 requests will be sent to the server every second and each user will enter the system 10 times.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PyaJJ4Ovaf1jHx2u2pfXPw.png" /></figure><p>If we choose Infinite, it means that it will send requests to the system until we stop the test. That way the tests are more realistic.</p><p>Let’s continue by creating HTTP Request Default.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bSv_7MI_ZXxAUrzM0vjWYA.png" /></figure><p>In this section, we give my swagger address. Let’s test the post method in <a href="https://petstore.swagger.io/v2/pet">https://petstore.swagger.io/v2/pet</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WKxxU_8r1ZrobnABcruPmQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2OGnojkTrRPqO7MsYPg_Pw.png" /></figure><p>In the next step, we create the HTTP Request.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Yli94qH0N3TQaVKNNRwdbg.png" /></figure><p>We write the Request ,Path and HTTP method here.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XCw-jZhdpN7OBlM2wiRxew.png" /></figure><p>In the next step, we create the HTTP Header Manager.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a3jBlOKpMxcZzCAQ0aHinw.png" /></figure><p>We can click the Add button and then write the headers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*asotehOaqUURgTUlOBcM1g.png" /></figure><p>Request is now ready. When we run it, we need a listener that has the quality of a report. You can add whatever you want in the Listener section.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mAt-T1GfZAdeFivDGNxy-A.png" /></figure><p>View Results Tree in this way you can examine the request and response.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*syWRmDherT7olljpQE5BYQ.png" /></figure><p>View Results in Table this way you can view times and sizes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8O5o7LKJM7Qhy0t3dikSXg.png" /></figure><p>Aggregate Graph is like this, you can use the values here if you want to keep a report. Average,Median,max,min etc. is located here.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FAismR1mgEO18jLEwhmRjw.png" /></figure><p>You can generate random values for requests from Random Variables.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bea0otyTK5igd6DdjbFQbQ.png" /></figure><p>If we want to create a random id, we need to separate it between 00001 and 99999 like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8fnoG4uH3bOdJg9DGR4r6Q.png" /></figure><p>If we want a string value, it is sufficient to write the Output Format in quotation marks.</p><p>Its usage and output is like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/606/1*edaeCshXa-H_w8vaZjA3HQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uLy2rv6alL9IWJ5yGxuI8Q.png" /></figure><p>When we want to read data from a file, it is sufficient to add Data Set Config.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zn_5lVQ4oEa8Ue7g0WzUAA.png" /></figure><p>This is how it is set up and used. It is sufficient to separate the csv file with a comma.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3M05Nb13NBV8LVxW_0GSrA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/860/1*HSONy_cv30j8h7ovzQ0oGg.png" /></figure><p>To add static values, we just need to add User Defined Variables.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bmf02oVu7iZzn15GiAHCoA.png" /></figure><p>Github link: <a href="https://github.com/dogangunemre/JmeterPerformanceTestiing">https://github.com/dogangunemre/JmeterPerformanceTestiing</a></p><p>Thanks!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e1e23c311307" width="1" height="1" alt=""><hr><p><a href="https://medium.com/kocfinanstech/jmeter-ile-performans-testi-e1e23c311307">Performance Testing with JMeter</a> was originally published in <a href="https://medium.com/kocfinanstech">Koçfinans Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Spring Annotations]]></title>
            <link>https://medium.com/kocfinanstech/spring-annotations-11351936e704?source=rss----69145647485---4</link>
            <guid isPermaLink="false">https://medium.com/p/11351936e704</guid>
            <dc:creator><![CDATA[Ebru]]></dc:creator>
            <pubDate>Tue, 29 Mar 2022 12:52:26 GMT</pubDate>
            <atom:updated>2022-03-29T12:55:14.763Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello everyone, I would like to focus on what is the difference between a @controller, @component, @repository, @service, and these kinds of annotations in the Spring.</p><p><strong>@Component</strong></p><p>It signifies the fact that something is a being that needs to be managed by Spring. It means “Spring, you are in control of this bean.”</p><p>@component is the most generic abstraction. When we talk about Web applications, we would talk about multiple layers. We can use @component on any of the components in any of these layers. So it’s very generic.</p><pre>@Component<br>public class ContactResource {<br>...<br>}</pre><p><strong>@Controller</strong></p><p>It is typically used in the web layer @controller signifies something which is using the MVC pattern, model view controller part.</p><pre>@Controller<br>public class CompanyController {<br>...<br>}</pre><p><strong>@Repository</strong></p><p>We would use @repository typically on things like a DAO (data access object ). So these are the things that are related to getting the data from our database.</p><p>Therefore when we tag any component with @repository, Spring would automatically add the exception Translation for JDBC exceptions.<br>Whenever a JDBC exception happens, then it needs to be translated into the specific spring exception.<br>Thus if we put @repository on top of any component, then that happens automatically.</p><pre>@Repository<br>public class CompanyDAOImpl implements CompanyDAO {<br>...<br>}</pre><p><strong>@Service</strong></p><p>It is typically used in the business layer. In our business logic, the most important function that we would want to provide is transaction management, For all our facade objects which are present in the business layer, we would use @service.</p><pre>@Service<br>public class CompanyServiceImpl implements CompanyService {<br>...<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/194/1*Nv_PrfLMoo-dUFZDbdkGBA.png" /><figcaption>Web Applications Multiple Layers</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=11351936e704" width="1" height="1" alt=""><hr><p><a href="https://medium.com/kocfinanstech/spring-annotations-11351936e704">Spring Annotations</a> was originally published in <a href="https://medium.com/kocfinanstech">Koçfinans Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Socket.IO with Node.Js + Express]]></title>
            <link>https://medium.com/kocfinanstech/socket-io-with-node-js-express-5cc75aa67cae?source=rss----69145647485---4</link>
            <guid isPermaLink="false">https://medium.com/p/5cc75aa67cae</guid>
            <category><![CDATA[socketio]]></category>
            <category><![CDATA[sockets]]></category>
            <category><![CDATA[node]]></category>
            <category><![CDATA[express]]></category>
            <dc:creator><![CDATA[Sude Kılıç]]></dc:creator>
            <pubDate>Thu, 16 Dec 2021 13:37:05 GMT</pubDate>
            <atom:updated>2021-12-16T13:37:05.393Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LXMQ6NojZj6uJSgMCBBdxQ.png" /></figure><p>Nowadays, most web developers want to develop real-time web applications or customize their existing applications to become real-time in order to increase user satisfaction. Therefore, Websockets are becoming very common in the modern web development environment. Especially in areas like Chat Applications and Push Notifications, this need has become even more prominent.</p><h4>What is WebSocket?</h4><blockquote><a href="https://en.wikipedia.org/wiki/WebSocket#:~:text=WebSocket%20is%20a%20computer%20communications,WebSocket%20is%20distinct%20from%20HTTP.">WebSocket</a> is a computer communications protocol, providing full-duplex communication channels over a single TCP connection.</blockquote><p>WebSocket promotes real-time communication between the Client and the Web Server. It has the significant advantage of providing full-duplex communication over an HTTP connection. WebSocket also increases the accuracy and efficiency of stream events.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2Z60UCXgOmbENe6CXpX5ug.png" /></figure><h4>What is Socket.io?</h4><blockquote><a href="https://socket.io/">Socket.IO</a> enables real-time, bidirectional and event-based communication. It works on every platform, browser or device, focusing equally on reliability and speed.</blockquote><p>Socket.IO is a JavaScript library for real-time web applications. It has two parts: a client-side library that runs in the browser, and a server-side library for Node.js. Socket.IO automatically upgrades the requirement to WebSocket if needed.</p><h4>Difference Between WebSocket and Socket.io</h4><p>It’s important to note that Socket.IO is not a WebSocket implementation. The authors state that:</p><blockquote>“Socket.IO indeed uses WebSocket as a transport when possible, but a WebSocket client will not be able to connect to a Socket.IO server, and a Socket.IO client will not be able to connect to a WebSocket server”.</blockquote><p>Here are some of the key differences between WebSocket and Socket.io</p><ol><li>WebSocket is the protocol that is established over the TCP connection, Socket.io is the library to work with WebSocket.</li><li>WebSocket provides full-duplex communication on TCP connections, Socket.io provides the event-based communication between browser and server.</li><li>WebSocket does not support Proxy and load balancer, with Socket.io a connection can be established in the presence of proxies and load balancers.</li><li>WebSocket doesn’t support broadcasting, Socket.io supports broadcasting.</li><li>WebSocket doesn’t have a fallback option, Socket.io supports fallback options.</li></ol><h4>Integrating Socket.io</h4><p>You will need Node and npm installed before you can start creating apps with Socket.IO. You can run the following lines in your terminal to confirm that node and npm are installed.</p><pre>node --version<br>npm --version</pre><p>After making sure that Node and npm are downloaded, create a new file and set up the npm package to create a package.json configuration file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YlTzSDCbEzPMJ0l-Q7bsiA.png" /></figure><p>Now we are ready to install Express and Socket.io</p><pre>npm i --save express socket.io</pre><p>Instead of using the node command, you can use <strong>nodemon</strong> to avoid restarting the server whenever a file changes.</p><pre>npm i -g nodemon</pre><p>If all these steps are done, let’s create a simple file called <strong>server.js</strong>.</p><pre>const app = require(&#39;express&#39;)();<br>const server = require(&#39;http&#39;).createServer(app);<br>const io = require(&#39;socket.io&#39;)(server);</pre><pre>const port = process.env.PORT || 8080;</pre><pre>app.get(&#39;/&#39;, function(req, res) {<br>  res.sendfile(&#39;index.html&#39;);<br>});</pre><pre>server.listen(port, function() {<br>  console.log(`Listening on port ${port}`);<br>});</pre><p>And, we need an <strong>index.html</strong> file.</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html&gt;<br>   &lt;head&gt;<br>      &lt;title&gt;Hello!&lt;/title&gt;<br>   &lt;/head&gt;<br>   &lt;body&gt;Integrating Socket.io with Node.js and Express&lt;/body&gt;<br>&lt;/html&gt;</pre><p>You can test it by running the <strong>nodemon </strong>command, this command will run the server on localhost:8080. If you go to your browser and enter localhost:8080, you can see that the application is running. Now, let’s continue with socket.io.</p><pre>io.on(&#39;connection&#39;, (socket) =&gt; {<br>    socket.emit(&#39;connect&#39;, {message: &#39;a new client connected&#39;})<br>})</pre><p>The critical parts of this code block are the<strong> io.on</strong> and <strong>socket.emit</strong> functions.</p><p>The io.on function triggers a sequence of actions when a connection arrives. The codes in this function will only work if the connection is received. This event handler uses the socket object to handle connection, disconnection, events, and more.</p><p>The Socket.IO API is inspired by the Node.js <a href="https://nodejs.org/docs/latest/api/events.html#events_events">EventEmitter</a>, which means you can emit events on one side and register listeners on the other. The socket.emit function takes an emit name as its first argument. You can specify this name and listen to it on the client-side according to this name. The second argument should be the data you want to send.</p><p>For example, you may add features like broadcasting a message to the entire chat group. In other words, a message can be sent to all users who are currently connected to the socket port.</p><pre>socket.on(&#39;chat&#39;, message =&gt; {<br>    // console.log(&#39;From client: &#39;, message)<br>    io.emit(&#39;chat&#39;, message)<br> })</pre><p>Of course, the client has to listen to the event emitted by the server.</p><pre>socket.on(&#39;chat&#39;, message =&gt; {<br>  console.log(&#39;From server: &#39;, message)})</pre><p>For now, let’s move on with logging to see if it works properly. The final version of server.js is as follows.</p><pre>const app = require(&#39;express&#39;)();<br>const server = require(&#39;http&#39;).createServer(app);<br>const io = require(&#39;socket.io&#39;)(server);<br>const port = process.env.PORT || 8080;</pre><pre>app.get(&#39;/&#39;, function(req, res) {<br>   res.sendfile(&#39;index.html&#39;);<br>});</pre><pre>io.on(&#39;connection&#39;, (socket) =&gt; {<br>  console.log(&#39;user connected&#39;);</pre><pre>  socket.on(&#39;disconnect&#39;, function () {<br>    console.log(&#39;user disconnected&#39;);<br>  });<br>})</pre><pre>server.listen(port, function() {<br>  console.log(`Listening on port ${port}`);<br>});</pre><p>After logging messages on connections and disconnections, the client script must be included to initialize the socket object so that clients can create connections as needed. io server serves the script at <strong>‘/socket.io/socket.io.js’</strong>.</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html&gt;<br>   &lt;head&gt;<br>      &lt;title&gt;Hello!&lt;/title&gt;<br>   &lt;/head&gt;<br>   &lt;script src = &quot;/socket.io/socket.io.js&quot;&gt;&lt;/script&gt;<br>   &lt;script&gt;<br>      const socket = io();<br>   &lt;/script&gt;<br>   &lt;body&gt;Integrating Socket.io with Node.js and Express&lt;/body&gt;<br>&lt;/html&gt;</pre><p>All set! If you go to your browser and enter localhost:8080, you can see that the server logs the message ‘user connected’. Each time you refresh your browser, it will first disconnect the socket connection(‘user disconnected’) and then recreate a new one (‘user connected’).</p><p>It’s that easy to connect to Socket.io with Node.js and Express. The Socket.io also offers different features that you can use according to your own needs such as a few examples below.</p><p><strong>socket.to($client-id):</strong> sending a message from a client to just one client <br><strong>io.sockets:</strong> sending messages to all clients connected to the server with Socket.io<br><strong>socket.brodcast:</strong> communicating with other clients from a client with Socket.io.</p><p>You can find more detailed information in the <a href="https://socket.io/docs/v4/">documentation</a>.</p><p>Thanks to the features and methods in Socket.IO, real-time applications can be developed easily. However, when there is a problem on the server and client-side, it will be beneficial to take good action without reflecting this problem on the user.</p><p>Take care!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5cc75aa67cae" width="1" height="1" alt=""><hr><p><a href="https://medium.com/kocfinanstech/socket-io-with-node-js-express-5cc75aa67cae">Socket.IO with Node.Js + Express</a> was originally published in <a href="https://medium.com/kocfinanstech">Koçfinans Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is API Testing ?]]></title>
            <link>https://medium.com/kocfinanstech/what-is-api-testing-3a3deb551570?source=rss----69145647485---4</link>
            <guid isPermaLink="false">https://medium.com/p/3a3deb551570</guid>
            <category><![CDATA[qa]]></category>
            <category><![CDATA[api-testing]]></category>
            <category><![CDATA[postman]]></category>
            <dc:creator><![CDATA[Selen Gönen]]></dc:creator>
            <pubDate>Mon, 15 Nov 2021 11:27:51 GMT</pubDate>
            <atom:updated>2021-11-15T11:27:51.044Z</atom:updated>
            <content:encoded><![CDATA[<h3>What is API Testing ?</h3><p>Hi everyone,</p><p>In this article, I will give some information about API testing and its advantages in software life cycle. First, let’s better understand what API testing is.</p><h4>What is API Testing?</h4><p>API (Application Programming Interface) testing is a kind of software testing and it is written to verify the APIs still meet the expectations of functionality, reliability, performance, and security after a code change. Below, I will give some API testing examples by using data accuracy, HTTP status codes, data format, and error codes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rPJoUOCDbudm_eJD4S93nw.png" /></figure><h4>Why do we need to perform API testing?</h4><p>API testing verifies that the services still return successful responses after the development teams push a new code to the service and that means API testing provides less maintenance effort to UI automation and manual testing.</p><h4>Postman for API Testing</h4><p>We prefer Postman for API testing. It is a browser plugin, which is available for both Windows and Mac operating systems. It is excellent for QA team that are not interested in dealing with integrated development environment coding, the same language that the developers used.</p><h4>API Testing Examples</h4><p>API testing requires both positive and negative tests to ensure that the API is working correctly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r26PAuM-A__tAXJxDWrpnw.png" /><figcaption>The response of web service</figcaption></figure><blockquote><em>Lets see some tests according the response above :</em></blockquote><ul><li>Verification the response status code. Here, you can check either it returns a 2xx as positive or error code as negative.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/955/1*b7nA_bU9KaqI9JzNAYcVlA.png" /></figure><ul><li>Verification the requirement of a data.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/721/1*d8v3gqQWYM2IV-VxhUDBJg.png" /></figure><ul><li>Verification the type of a data.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/653/1*zD4jCZ0uNgi-gXTfbRWioQ.png" /></figure><ul><li>Verification true/false situation of a data.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/666/1*7WVHX_HzkJaGCliIQc4xOA.png" /></figure><ul><li>Verification the response time is less than 200ms</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/709/1*utyPa7ZWTOpR0NhiI3NnTQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3a3deb551570" width="1" height="1" alt=""><hr><p><a href="https://medium.com/kocfinanstech/what-is-api-testing-3a3deb551570">What is API Testing ?</a> was originally published in <a href="https://medium.com/kocfinanstech">Koçfinans Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Clean Code II: React]]></title>
            <link>https://medium.com/kocfinanstech/clean-code-ii-react-fb7a56d6a0a4?source=rss----69145647485---4</link>
            <guid isPermaLink="false">https://medium.com/p/fb7a56d6a0a4</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[clean-code]]></category>
            <dc:creator><![CDATA[Sude Kılıç]]></dc:creator>
            <pubDate>Fri, 02 Apr 2021 08:43:42 GMT</pubDate>
            <atom:updated>2021-04-02T08:43:42.315Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/603/1*5u9xzoJLggfuPXZkhbNirg.png" /></figure><p>Hello everyone, it’s me again! This post can be thought of as a continuation of the previous one. So, without further ado, let’s return to our subject.</p><p>I love removing dead codes and writing as simple as possible. It satisfies me as a developer and also provides convenience in many ways. For this reason, I wanted to share with you a few suggestions that made my React development life easier and cleaner. However, I must warn you that some suggestions are not the best scenario for every situation. Therefore, there will be several points open to interpretation.</p><h3>1.Conditional Rendering: One Condition</h3><p>In programming we always need conditions but if we only need one for conditional rendering, then it is better to use &amp;&amp; operator instead of the ternary operators.</p><pre>isGreetingVisible ? &quot;Hello!&quot; : null   -- Bad</pre><pre>isGreetingVisible &amp;&amp; &quot;Hello!&quot;   <strong>-- Good</strong></pre><p><em>Warning: This also appears to be a controversial issue because falsy values need more attention.</em></p><h3>2.Conditional Rendering: Either Condition</h3><p>If you have one condition and you want to render different things due to its satisfaction, then it is better to use a ternary operator instead of the&amp;&amp; operator. Also, by splitting these out into two separate conditionals using the &amp;&amp; operator, it obfuscates the fact that the two pieces of UI are related and that they are opposites of each other.</p><pre>isConditionSatisfied &amp;&amp; &quot;Yes!&quot;   <strong><br></strong>!isConditionSatisfied &amp;&amp; &quot;No!&quot;   <strong>-- Bad</strong></pre><pre>isConditionSatisfied ? &quot;Yes!&quot; : &quot;No!&quot;   <strong>-- Good</strong></pre><h3>3. Props: Boolean</h3><p>If you need a boolean props parameter and its value is true then there is no need to write its value.</p><pre>&lt;TurkishMessage isTurkish={true} /&gt;  <strong>-- Bad</strong></pre><pre>&lt;TurkishMessage isTurkish /&gt;   <strong>-- Good</strong></pre><h3>4. Props: String</h3><p>If you need a string props parameter then you don’t need to use curly braces or backticks. Double quotes will be enough.</p><pre>&lt;GreetingMessage name={&quot;Sude&quot;} /&gt;  <strong>-- Bad<br></strong>&lt;GreetingMessage name={&#39;Sude&#39;} /&gt;  <strong>-- Bad<br></strong>&lt;GreetingMessage name={`Sude`} /&gt;  <strong>-- Bad</strong></pre><pre>&lt;GreetingMessage name=&quot;Sude&quot;/&gt;   <strong>-- Good</strong></pre><h3>5. Props: Event Handler Functions</h3><p>If you need an event handler that needs a single argument for the Event, then you don’t need to wrap the function.</p><pre>&lt;NameInput onChange={e =&gt; handleChange(e)} /&gt;  <strong>-- Bad</strong></pre><pre>&lt;NameInput onChange={handleChange} /&gt;   <strong>-- Good</strong></pre><h3>6. Props: Component</h3><p>If you need to pass a component as a props to another component and it is the only props, then you don’t need to wrap the passed component.</p><pre>&lt;ComponentWithOtherComponent OtherComponent={Other} /&gt;  <strong>-- Bad</strong></pre><pre>&lt;ComponentWithOtherComponent OtherComponent={() =&gt; &lt;Other/&gt;}/&gt; -<strong>Good</strong></pre><h3>7. Setting state that depends on the previous state</h3><p>In React, state updates can be batch processed. Therefore, if the new state is dependent on the previous state, then set state as a function of the previous state.</p><pre>const [isDisabled, setIsDisabled] = useState(false)</pre><pre>const disableButton = () =&gt; setIsDisabled(!isDisabled) <strong>--Bad</strong><br>const disableButton = () =&gt; setIsDisabled(isDisabled =&gt; !isDisabled) <strong>--Good</strong></pre><h3>8. Fragment Shortcut</h3><pre>&lt;React.Fragment&gt;&lt;/React.Fragment&gt;  <strong>--Long</strong><br>&lt;&gt;&lt;/&gt;   <strong>--Short</strong></pre><h3><strong>9. super() in Constructor</strong></h3><p>You can safely remove your super() from your constructor if you’re not doing anything with your props in it.</p><p><em>Warning: However, pay attention to the derived state warnings.</em></p><h3>10. Functional Components</h3><p>This is definitely something that most developers won’t like but this is like a trick. If you have functional components, then you can call them like functions.</p><pre>&lt;SomeComponent/&gt; =&gt; SomeComponent()</pre><h3>11. Assigning Keys to Children</h3><p>In React, when creating a list of elements key is necessary to identify them, but you can also use React.Children.toArray()which has a built-in method that automatically assigns the keys.</p><pre>{someData.map(element =&gt; &lt;div key={element.id}&gt;Hello!&lt;/div&gt;)}</pre><pre>{React.Children.toArray(someData.map(element =&gt; &lt;div&gt;Hello!&lt;/div&gt;)}</pre><p><em>Warning: </em><em>map() index not recommended.</em></p><h3>12. Code Format: Prettier</h3><p><a href="https://prettier.io/">Prettier</a> is a tool that makes it easier for you and your team to maintain code formatting consistency. It also enforces clean code practices, which you can customize based on your opinion.</p><p>This <a href="https://medium.com/free-code-camp/these-tools-will-help-you-write-clean-code-da4b5401f68e">gif of Adeel Imran </a>pretty much explains the context:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/669/1*SqRZTC9JRX4l20upOl5Jfw.gif" /></figure><h3>13. Order Imports</h3><p>Although ordering varies from person to person, it will also be beneficial to standardize it. Order can also be decided within the team, but generally, preferred ordering is as follows:</p><ol><li>React import</li><li>Library imports</li><li>Absolute imports from the project</li><li>Relative imports</li><li>import * as</li><li>import &#39;./somefile.ext&#39;</li></ol><p>That’s all, I really hope you have enjoyed reading it. Please feel free to share some of your tips and tricks with me :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fb7a56d6a0a4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/kocfinanstech/clean-code-ii-react-fb7a56d6a0a4">Clean Code II: React</a> was originally published in <a href="https://medium.com/kocfinanstech">Koçfinans Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Clean Code: Write better, simple and cleaner]]></title>
            <link>https://medium.com/kocfinanstech/clean-code-write-better-simple-and-cleaner-aadd51f7cd93?source=rss----69145647485---4</link>
            <guid isPermaLink="false">https://medium.com/p/aadd51f7cd93</guid>
            <category><![CDATA[uncle-bob]]></category>
            <category><![CDATA[clean-code]]></category>
            <dc:creator><![CDATA[Sude Kılıç]]></dc:creator>
            <pubDate>Fri, 02 Apr 2021 08:42:09 GMT</pubDate>
            <atom:updated>2021-04-02T08:42:09.255Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rz_RXNYHw_Zs0G9y_L1KdA.png" /></figure><p>Some books change the way we code, one of the best examples for me (and probably many developers) is “Clean Code” by Robert C. Martin.</p><p>You may think that technical debt should be left but I believe messy code tends to get messier and it becomes hard to clean. Decreasing repetitive codes and preferring understandable/extensible code principles will speed up the decision process. The clean code principles will not only give you personal satisfaction but also your teammates and future self will thank you.</p><blockquote>Code is not how you tell the computer what to do; it is how you tell another programmer what you want the computer to do.</blockquote><p>In this article, I’ll discuss a few issues that are also addressed in the “Clean Code” Bible. Although most of us have mastered these rules, I wrote this article because I believe it would be good to remember and remind each other from time to time. I hope you enjoy reading!</p><h3>1. Meaningful Names</h3><blockquote><em>There are only two hard things in Computer Science: cache invalidation and naming things.</em><strong><em> — </em>Phil Karlton</strong></blockquote><p>You have probably heard of Phil Karlton’s famous phrase. Although it is difficult to find meaningful names, it is one of the most important elements underlying the clean code principles. The name of a variable, function or class should tell why it exists, what it does, and how it is used. If a name requires a comment, the name has not been selected properly.</p><p>Let’s look at some examples.</p><p><strong><em>Variable names should have meaning and should be </em>easily pronounceable<em>:</em></strong></p><blockquote><em>“You should name a variable using the same care with which you name a first-born child.” — Robert C. Martin, </em><strong><em>Clean Code: A Handbook of Agile Software Craftsmanship</em></strong></blockquote><pre>int x = products.size();  <strong>-- Wrong</strong></pre><pre>int prdctSize = products.size();  <strong>-- Wrong</strong></pre><pre>int productSize = products.size(); -- <strong>Right</strong></pre><p><strong><em>Singular and Plural:</em></strong></p><pre>List&lt;String&gt; name = Arrays.asList(&quot;Sude&quot;,&quot;Selen&quot;,&quot;Mert&quot;,&quot;Kerim&quot;);<br>String name1 = name.get(0);  <strong>-- Wrong</strong></pre><pre>List&lt;String&gt; names = Arrays.asList(&quot;Sude&quot;,&quot;Selen&quot;,&quot;Mert&quot;,&quot;Kerim&quot;);<br>String name = names.get(0);  <strong>-- Right</strong></pre><p><strong><em>Functions should be verbs, classes should be nouns: </em></strong>Use a verb as the first word in the method and use a noun for class. Use camelCase for variables and function names. Classes should start with a capital letter.</p><pre>function price()  <strong>-- Wrong</strong></pre><pre>function calculatePrice()  <strong>-- Right</strong></pre><pre>class CalculatePrice  <strong>-- Wrong</strong></pre><pre>class Price   <strong>-- Right</strong></pre><p><strong><em>Booleans are “to be are not be”:</em></strong></p><pre>boolean nameValid = !StringUtils.<em>isBlank(name);</em>   <strong>-- Wrong</strong></pre><pre>boolean isNameValid = !StringUtils.<em>isBlank(name);</em> -- <strong>Right</strong></pre><p><strong><em>Consistency: </em></strong>Chose similar words for similar functions. If you used “get” in one class, do not use “fetch” in another.</p><h3>2. Testing</h3><blockquote><em>If it is not tested, it is broken</em></blockquote><p>Write a lot of tests and make sure you have enough to cover your core business functionality. Writing clean code will automatically make writing unit tests faster and easier.</p><p>In addition, there are a few points mentioned in the book.</p><blockquote>Dirty tests are worse than no tests!</blockquote><p>They will be more difficult to understand and it takes more time to fix it. I don’t think we should stick to the “one assertion per test” rule dogmatically but as the name implies it is “unit” testing.</p><p>Good tests should be readable and follow to <a href="https://dzone.com/articles/writing-your-first-unit-tests#:~:text=Fast%3A%20Tests%20should%20be%20fast,be%20discouraged%20from%20using%20them.&amp;text=This%20allows%20you%20to%20run,see%20what%20is%20going%20wrong.">FIRST</a> rules:</p><p><strong>Fast</strong>: Tests should be fast enough that you won’t be discouraged from using them.</p><p><strong>Independent</strong>: Tests should not depend on each other, when needed you should be able to run each test separately.</p><p><strong>Repeatable</strong>: Tests should be repeatable in any environment without varying results.</p><p><strong>Self-Validating: </strong>Each test will have a single pass/fail boolean output. It should not be your responsibility to check whether the method’s output is correct every time the test is run.</p><p><strong>Timely</strong>: Unit tests should be written right before the production code that makes the test pass. This is something you would do if you were doing TDD (Test Driven Development), but it may not be applicable in other cases.</p><h3>3. Separation of Concerns (Single Responsibility Principle)</h3><blockquote><em>The Single Responsibility Principle (SRP) is a computer programming principle that states that every module or class should have responsibility over a single part of the functionality provided by the software, and that responsibility should be entirely encapsulated by the class. All its services should be narrowly aligned with that responsibility.</em></blockquote><p>Basically, keep it simple! Classes and functions should be small and do one thing(one purpose). Surely, if an error occurs, it will be easier to find.</p><p>Robert C. Martin in <em>Clean Code</em> provides a parallel definition about this subject:</p><blockquote>The Single Responsibility Principle (SRP) states that each software module should have one and only one reason to change.Gather together the things that change for the same reasons. Separate those things that change for different reasons.</blockquote><p>It’s critical to divide responsibilities into different functions, classes, and modules because code smells like Fragility and Viscosity can result from misplaced responsibilities. There are multiple techniques to achieve this separation. In this context, the reason for the change and whose responsibility it is are important. Uncle Bob comments on this situation as follows: <em>“The code is not responsible for bug fixes or refactoring. Those things are the responsibility of the programmer, not of the program.”</em></p><h3>4. Reusable Codes instead of Duplication</h3><blockquote>Duplicate code is the root of all evil in software design. When a system is littered with many snippets of indentical, or nearly identical code, it is indicative of sloppiness, carelessness, and sheer unprofessionalism. It is the guilt-edged responsibility of all software developers to root out and eliminate duplication whenever they find it.<strong> <em>— Robert C. Martin</em></strong></blockquote><p>Removing code duplications keeps your code clean and allows you to provide faster feature support and new updates. It simplifies the code structure and also improves the code’s maintainability while reducing technical debt over time. It helps to reduce the number of security vulnerabilities.</p><p>You can see some of the treatments in the following:</p><p><strong><em>If the same code appears in two or more methods in the same class: </em></strong>Use the Extract Method and call the new method from both locations.</p><p><strong><em>If the same code appears in two subclasses of the same level:</em></strong> Use the Extract Method for both classes and Pull it Up.</p><p><strong><em>If the same code appears in two different classes: </em></strong>If the classes don’t belong to a hierarchy, use Extract Superclass; if creating a superclass is impossible, use Extract Class in one class and use the new component in the other.</p><p><strong><em>Do not hardcode: </em></strong>Instead of hardcoding values define constants or use variables. Using variables will not only make the code more readable, but it will also make it easy to modify if it is being used at multiple places.</p><p>Also an important point, have you ever heard of <a href="https://en.wikipedia.org/wiki/Don%27t_repeat_yourself">DRY</a> principles?</p><p><em>“It basically aims to reduce the repetition of software patterns by replacing them with abstractions or using data normalization to avoid redundancy.”</em></p><p>Although it is one of the most valuable principles of common development wisdom, it can often be misunderstood. Even if two pieces of code appear to be identical, they may represent different concepts and different abstractions. In such examples, duplication may be a more logical choice.</p><blockquote>Duplication is far cheaper than the wrong abstraction<em> </em><strong><em>– Sandi Metz</em></strong></blockquote><h3>5. Design Decisions</h3><blockquote>The hardest part of design … is keeping features out.<strong> — Donald A. Norman</strong></blockquote><p><strong><em>Keep Configurable Data at High Levels: </em></strong>If you have a constant such as a default or configuration value that is known and expected at a high level of abstraction, do not bury it in a low-level function. Expose it as an argument to that low-level function called from the high-level function.</p><p><strong><em>A class should know only its direct dependencies: </em></strong>Follow<strong> <em>Law of Demeter.</em></strong></p><p><strong><em>Use dependency injection:</em> </strong>Dependency injection makes it possible to eliminate unnecessary dependencies and makes it easier to reuse in a different context. It reduces dependency carrying and increases testability. Inversion of Control supports the SPR.</p><p><strong><em>Functions should have no side effects.</em></strong></p><p><strong><em>Prefer to use as few parameters as possible and no flag arguments.</em></strong></p><p><strong><em>Prefer polymorphism to if/else or switch/case: </em></strong>Switch statements are commonly used because they are the most obvious brute force solution, not because they are the best solution. That is why this heuristic exists to remind us to consider polymorphism before using a switch. In addition, cases, where functions are more unpredictable than types, are uncommon. Therefore, any switch statement should be regarded as suspicious.</p><h3>6. Code Smells</h3><p>We all know what code smells means but I still wanted to share its definition on <a href="https://en.wikipedia.org/wiki/Code_smell#:~:text=In%20computer%20programming%2C%20a%20code,%2C%20developer%2C%20and%20development%20methodology.&amp;text=It%20is%20also%20a%20term%20used%20by%20agile%20programmers.">Wikipedia</a>:</p><p><em>“In computer programming, a code smell is any characteristic in the source code of a program that possibly indicates a deeper problem. Code smells are usually not bugs; they are not technically incorrect and do not prevent the program from functioning.”</em></p><p>We all are familiar with the concept and most part of this post is related to or covers this topic. But, since the book specifically mentions it, I wanted to quote a few points here.</p><p><strong>Rigidity: </strong><em>The software is difficult to change. A small change causes a cascade of subsequent changes.</em></p><p><strong>Fragility</strong>: <em>The software breaks in many places due to a single change.</em></p><p><strong>Immobility: </strong>Y<em>ou cannot reuse parts of the code in other projects because of involved risks and high effort.</em></p><p><strong>Opacity: </strong><em>The code is hard to understand.</em></p><p>Thank you for reading, let’s take our corona days as a warning and always pay attention to cleanliness :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aadd51f7cd93" width="1" height="1" alt=""><hr><p><a href="https://medium.com/kocfinanstech/clean-code-write-better-simple-and-cleaner-aadd51f7cd93">Clean Code: Write better, simple and cleaner</a> was originally published in <a href="https://medium.com/kocfinanstech">Koçfinans Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Laravel & Homestead]]></title>
            <link>https://medium.com/kocfinanstech/laravel-homestead-c91a344f5646?source=rss----69145647485---4</link>
            <guid isPermaLink="false">https://medium.com/p/c91a344f5646</guid>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[virtualbox]]></category>
            <category><![CDATA[php]]></category>
            <category><![CDATA[vagrant]]></category>
            <category><![CDATA[homestead]]></category>
            <dc:creator><![CDATA[Tunahan Çakıl]]></dc:creator>
            <pubDate>Thu, 01 Apr 2021 13:43:37 GMT</pubDate>
            <atom:updated>2021-04-01T13:43:37.144Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello everyone,</p><p>Today I will talk about Homestead and Laravel.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JJ3pIntDPC8xzWHRlRSgzA.png" /></figure><p>Let’s start with Laravel. Laravel is a framework that will make your PHP application development more enjoyable. Full-stack offers us many processes that we need while creating a web application in the form of ready-made libraries. I will give an example how to write code in Laravel that I use and Homestead involves here :)</p><p>Homestead is a vagrant box provides you an advancing enviroment that you don’t need a web server PHP for your local machine and any set up web software Homestead operating system operates free and includes NGNIX, Redis, PHP, PostgreSQL etc. more several apps. Vagrant can named a very simple container to manage virtual machine.</p><h3>Homestead Setup</h3><p>Homestead needs a virtual server can support Vagrant and I use virtualbox which is free. We download and set up Vagrant after virtualbox.</p><p><strong>Note:</strong> You need to install Vagrant of the appropriate operating system.</p><p>We will create Vagrant after the setup ad we will add <strong>laravel/homestead </strong>inside box.</p><pre>vagrant box add laravel/homestead</pre><p>We have finished virtual server after we run the command.</p><p><strong>Note:</strong> Windows user might need to change their <strong>BIOS </strong>settings. You have to enabled <strong>VIRTUALIZATION.</strong></p><p>As for the Homestead installation, Homestead is open source project in github.com.</p><pre>git clone https://github.com/laravel/homestead.git ~/Homestead</pre><p>For use last release;</p><pre>git checkout release</pre><p>After installing, In PhpStorm, you need to open Homestead and introduce your project from Homestead.yaml file. Your project directory where is it;</p><pre>folders:<br>    - map: ~/code/project1<br>      to: /home/vagrant/project1</pre><p>After setting project directory;</p><pre>vagrant up --provision</pre><p>By running the command, you can see the changes in the Homestead.yaml file and transfer them to the virtual server. The sites you add here,</p><pre>sites:<br>    - map: homestead.test<br>      to: /home/vagrant/project1/public</pre><p>You can view it via domain and directory browser.</p><h3>Getting Started With Laravel</h3><p>What you need to do to start a project with Laravel</p><pre>composer global require laravel/installer<br><br>laravel new example-app</pre><p>It is as simple as execute above commands, you can define the project you created here to Homestead and perform environment-independent improvements. In the next article, I want to make the Telescope and Compass, which are the tools I like in Laravel, stay tuned.</p><p><em>Talk is cheap, show me the code.</em></p><p>Thanks for reading, stay healthy.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c91a344f5646" width="1" height="1" alt=""><hr><p><a href="https://medium.com/kocfinanstech/laravel-homestead-c91a344f5646">Laravel &amp; Homestead</a> was originally published in <a href="https://medium.com/kocfinanstech">Koçfinans Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>