<?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: Delyce Twizeyimana</title>
    <description>The latest articles on DEV Community by Delyce Twizeyimana (@delyc).</description>
    <link>https://dev.to/delyc</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%2F941933%2Fcb877276-d858-481b-acf0-6aa951ae7f94.jpeg</url>
      <title>DEV Community: Delyce Twizeyimana</title>
      <link>https://dev.to/delyc</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/delyc"/>
    <language>en</language>
    <item>
      <title>PROXY PATTERN</title>
      <dc:creator>Delyce Twizeyimana</dc:creator>
      <pubDate>Mon, 27 Feb 2023 09:01:58 +0000</pubDate>
      <link>https://dev.to/delyc/proxy-pattern-372b</link>
      <guid>https://dev.to/delyc/proxy-pattern-372b</guid>
      <description>&lt;p&gt;What is a proxy.&lt;br&gt;
A proxy is a stand-in for someone else, similar to JavaScript,  instead of interacting with the target object directly, we'll interact with the Proxy object.&lt;/p&gt;

&lt;p&gt;A proxy takes two arguments, the first is the object its representing whereas the second is the handler where all behaviors of how to interact with the target object are defined.&lt;/p&gt;

&lt;p&gt;Additionally, there are two methods get() which is invoked when trying to access a property and set() which is invoked when trying to modify a property.&lt;/p&gt;

&lt;p&gt;As the get() method takes two arguments, set() takes three, where the third is the value that you want to set&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const person = {
    name: "Anonymous",
    age: 21
}

const handler = {
    get: (obj, prop) =&amp;gt; {
        console.log(`hello`, obj[prop])
    },
    set: (obj, prop, value) =&amp;gt; {
             console.log(`Changed ${prop} from ${obj[prop]} to ${value}`);
        obj[prop] = value

        }

    }
}

const personProxy = new Proxy(person, handler)
personProxy.name
personProxy.age = 23

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

&lt;/div&gt;



&lt;p&gt;Not only proxies helping us to directly interact with our target object, it can also help us in validation in order to avoid changing the target object with wrong values.&lt;br&gt;
for instance on set method we can have something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;set: (obj, prop, value) =&amp;gt; {

        if(value &amp;lt; 20){
            console.log("Small value")
        }
        else{
             console.log(`Changed ${prop} from ${obj[prop]} to ${value}`);
        obj[prop] = value

        }

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

&lt;/div&gt;



&lt;p&gt;And user age won't accept any value less than 20&lt;/p&gt;

&lt;p&gt;As you have seen above we are accessing or changing values using obj[props], However, there is Reflect built in method which makes it easier for us to manipulate the target object when working with proxies.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;set: (obj, prop, value) =&amp;gt; {
    console.log(`Changed ${prop} from ${obj[prop]} to ${value}`);
    Reflect.set(obj, prop, value);
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Proxies are a powerful way to add control over the behavior of an object.&lt;/p&gt;

</description>
      <category>nextjs</category>
      <category>react</category>
      <category>webdev</category>
      <category>performance</category>
    </item>
    <item>
      <title>Nanotechnology</title>
      <dc:creator>Delyce Twizeyimana</dc:creator>
      <pubDate>Thu, 15 Dec 2022 14:08:13 +0000</pubDate>
      <link>https://dev.to/delyc/nanotechnology-18nh</link>
      <guid>https://dev.to/delyc/nanotechnology-18nh</guid>
      <description>&lt;p&gt;Nanotechnology is the term given to those areas of science and engineering where phenomena that take place at dimensions in the nanometer scale are utilized in the design, characterization, production and application of materials, structures, devices and systems.&lt;/p&gt;

&lt;p&gt;There are different opinions around nanotechnology where scientists and engineers believe nanotechnology can be used to benefit human health now and in the future through applications such as better filters for improving water purification, more effective methods of delivering drugs in medicine and new ways of repairing damaged tissues and organs.&lt;/p&gt;

&lt;p&gt;However, Improved control over materials does not just mean better products. As with any new technology, there are concerns about unknown effects – and perhaps some extra ones, simply because nanotechnologies are so incredibly small.&lt;br&gt;
This is not just because they seem insidious due to their invisibility. The properties of materials are influenced by different effects at very small scales, where quantum mechanical laws trump classical physics. And biological systems, in particular, may respond to nanomaterials in ways we don’t like.&lt;/p&gt;

&lt;p&gt;Many areas in which nanotechnology can be applied and be beneficial has been identified, such as&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Future Transportation Benefits&lt;/li&gt;
&lt;li&gt;Environmental Remediation&lt;/li&gt;
&lt;li&gt;Energy Applications&lt;/li&gt;
&lt;li&gt;Medical and Healthcare Applications &lt;/li&gt;
&lt;li&gt;Electronics and IT Applications&lt;/li&gt;
&lt;li&gt;Everyday Materials and Processes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Nanotechnology will help improve in different areas as mentioned above, Although it has some pros and cons. Some of the pros are:  It offers the potential for new and faster kinds of computers, more efficient power sources and life-saving medical treatments, there are Invisible particles that fight cancer cells, faster microprocessors that consume less energy, batteries that last 10 times longer or solar panels that yield twice as much energy. But the disadvantage of it is that those Nanoparticles can get into the body through the skin, lungs and digestive system. This may help create 'free radicals' which can cause cell damage and damage to the DNA.&lt;/p&gt;

&lt;p&gt;To sum up, In the future, nanotechnology might help us make electrical lines, solar cells, and biofuels more efficient, and make nuclear reactors safer. Nanotechnology might lead to huge advances in health care, improving methods for detecting and treating diseases like cancer.&lt;/p&gt;

&lt;p&gt;While there are many nanotech uses, three areas of nanotech are paving the way to our future: Materials Science, Nanomedicine and Device Engineering.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Converting big strings of number into Number</title>
      <dc:creator>Delyce Twizeyimana</dc:creator>
      <pubDate>Tue, 15 Nov 2022 08:41:59 +0000</pubDate>
      <link>https://dev.to/delyc/converting-big-strings-of-number-into-number-5ggc</link>
      <guid>https://dev.to/delyc/converting-big-strings-of-number-into-number-5ggc</guid>
      <description>&lt;p&gt;there are several ways used to convert a string to number such as &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Number(str)&lt;/li&gt;
&lt;li&gt;parseInt(str, 10)&lt;/li&gt;
&lt;li&gt;(+str)&lt;/li&gt;
&lt;li&gt;(str * 1) and so on.. where str is a number string like str = "123"
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;str = "123"
'123'
console.log(+str)
Output: 123

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

&lt;/div&gt;



&lt;p&gt;However, the above ways don't work when you have a very big string&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let str = "6145390195186705543"
console.log(Number(str))
Output: 6145390195186705000

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

&lt;/div&gt;



&lt;p&gt;Here We get unexpected output, because we are dealing with a big string number.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Walk around:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;BigInt values represent numeric values which are too large to be represented by the number primitive.&lt;/p&gt;

&lt;p&gt;Using BigInt to convert a big string number&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let str = "6145390195186705543"
console.log(BigInt(str))
6145390195186705543n
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And here we get the expected output with n appended at the end &lt;br&gt;
In case you want to do some mathematical operations on your output, yeah, it's possible e.g output + 1n&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;6145390195186705543n + 1n

6145390195186705544n

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

&lt;/div&gt;



&lt;p&gt;You can check how I used this to solve a problem on leetcode: &lt;br&gt;
&lt;strong&gt;Question link:&lt;/strong&gt; &lt;a href="https://leetcode.com/problems/plus-one/"&gt;https://leetcode.com/problems/plus-one/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;My Solution&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;var plusOne = function(digits) {
    let fin=[]
    let comb =singleValue(digits)
    comb = BigInt(comb)
    comb = comb +1n
    let arr = comb.toString().split('')
    for(let i=0; i&amp;lt;arr.length; i++){
        fin.push(Number(arr[i]))
    }
    return fin

};


 function singleValue(arr){
    let str = ""
    for(let i=0; i&amp;lt;arr.length; i++){
        str +=arr[i]
    }
    return str

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

&lt;/div&gt;



&lt;p&gt;Read more about BigInt on : &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt"&gt;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
    </item>
    <item>
      <title>CSS transition ...</title>
      <dc:creator>Delyce Twizeyimana</dc:creator>
      <pubDate>Mon, 14 Nov 2022 11:46:48 +0000</pubDate>
      <link>https://dev.to/delyc/css-transition--585m</link>
      <guid>https://dev.to/delyc/css-transition--585m</guid>
      <description>&lt;p&gt;When animating your CSS elements, you can prevent the effects from occurring immediately by delaying or slowing down by controlling the animation speed. That is &lt;strong&gt;transition&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Transition has up to 6 properties which are:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;transition&lt;/p&gt;

&lt;p&gt;transition-delay&lt;/p&gt;

&lt;p&gt;transition-duration&lt;/p&gt;

&lt;p&gt;transition-property&lt;/p&gt;

&lt;p&gt;transition-timing-function&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;N.B:&lt;/strong&gt; If you don't specify the transition duration, no effect will occur since the default value is 0&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;transition-timing-function&lt;/strong&gt; specifies  the speed curve of the transition effect&lt;/p&gt;

&lt;p&gt;it has the following values that :&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;ease: slow start, goes fast then ends slowly&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;linear: same speed from start to end&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;ease-in: a slow start&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;ease-out: a slow end&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;ease-in-out: a slow start and end&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;cubic-bezier(n,n,n,n): lets you define your own values in a cubic-bezier function N.B: n value must be between 0 and 1&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Adding delay in transition&lt;/p&gt;

&lt;p&gt;transition-delay specifies a delay in seconds for the transition effect&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div class="box"&amp;gt;

&amp;lt;/div&amp;gt;

&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;.box{
  width: 10rem;
  height: 10rem;
  background: red;
  transition-duration: 1000ms;
  transition-property: background, width;
  transition-timing-function: ease-in;
  transition-delay: 200ms;
}



.box:hover{
  background:blue;
  width: 20rem;

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

&lt;/div&gt;



&lt;p&gt;for transition-property, when you have a lot of properties to transition its possible to write &lt;strong&gt;transition-property: all&lt;/strong&gt;, However it is not recommended, it's better to specify them as its shown in the code snippet above.&lt;/p&gt;

&lt;p&gt;Codepen link: &lt;a href="https://codepen.io/delyc/pen/poKwWmx"&gt;https://codepen.io/delyc/pen/poKwWmx&lt;/a&gt;&lt;/p&gt;

</description>
      <category>css</category>
    </item>
    <item>
      <title>Why is push() and pop() array methods said to be faster than shift() and unshift() array methods ?</title>
      <dc:creator>Delyce Twizeyimana</dc:creator>
      <pubDate>Mon, 14 Nov 2022 09:24:18 +0000</pubDate>
      <link>https://dev.to/delyc/lets-analyze-the-time-complexity-of-some-array-methods-fcp</link>
      <guid>https://dev.to/delyc/lets-analyze-the-time-complexity-of-some-array-methods-fcp</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jK-dA_HA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n87q45hr3e2ad5hjke5o.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jK-dA_HA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n87q45hr3e2ad5hjke5o.PNG" alt="Image description" width="800" height="397"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Shift() and unshift() array methods are methods that occurs at the beginning of an array while pop() and push() operates at the back. &lt;/p&gt;

&lt;p&gt;pop() and push() are said to be faster than shift() and unshift() but why is that so? Let's discuss it more down below.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;let's discuss their time complexities&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;consider having an array of 10 elements&lt;/p&gt;

&lt;p&gt;arr = [10, 12, 2, 3, 7, 100, 8, 28, 10, 1]&lt;/p&gt;

&lt;p&gt;the first element is at index 0 as arrays are zero-indexed once you want to do any operation at the front of the array either adding or removing the rest of the array elements will have to be indexed &lt;/p&gt;

&lt;p&gt;e.g * add 15 at index 0 &lt;/p&gt;

&lt;p&gt;when you do &lt;strong&gt;arr.unshift(15)&lt;/strong&gt;, the element that was at index 0 will need to be pushed one value behind so that the newly added value get index 0 and so on for other elements re-indexing &lt;/p&gt;

&lt;p&gt;which is similar to &lt;strong&gt;arr.shift()&lt;/strong&gt; which removed 10 and have 12 be pushed forward to occupy index 0 and so on&lt;/p&gt;

&lt;p&gt;thus, this re-indexing will occur &lt;strong&gt;n number of times&lt;/strong&gt; where n is the number of array elements&lt;/p&gt;

&lt;p&gt;However, for &lt;strong&gt;push&lt;/strong&gt; and &lt;strong&gt;pop&lt;/strong&gt; since we are affecting at the back there is no need to re-index thus its on a &lt;strong&gt;single operation&lt;/strong&gt; that we are doing i.e if you push something at the end the elements that existed in the array won't be affected&lt;/p&gt;

&lt;p&gt;To sum up, we have seen that for push and pop the operation will occur only once at constant time hence their &lt;strong&gt;time complexity&lt;/strong&gt; is &lt;strong&gt;O(1)&lt;/strong&gt; and for shift and unshift whose operations occurs n number of times their time complexity is &lt;strong&gt;O(n)&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;which means &lt;strong&gt;pop&lt;/strong&gt; and &lt;strong&gt;push&lt;/strong&gt; are faster than &lt;strong&gt;shift&lt;/strong&gt; and &lt;strong&gt;unshift&lt;/strong&gt; because they have an efficient** time complexity** of &lt;strong&gt;O(1)&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>algorithms</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
