<?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: Lawwee</title>
    <description>The latest articles on DEV Community by Lawwee (@lawwee).</description>
    <link>https://dev.to/lawwee</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F910100%2F719bb1a1-92e5-44c3-add3-6c2816fc7665.jpeg</url>
      <title>DEV Community: Lawwee</title>
      <link>https://dev.to/lawwee</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/lawwee"/>
    <language>en</language>
    <item>
      <title>Understanding Regex, being an HNG-11 Intern.</title>
      <dc:creator>Lawwee</dc:creator>
      <pubDate>Sat, 29 Jun 2024 16:53:00 +0000</pubDate>
      <link>https://dev.to/lawwee/understanding-regex-being-an-hng-11-intern-462j</link>
      <guid>https://dev.to/lawwee/understanding-regex-being-an-hng-11-intern-462j</guid>
      <description>&lt;p&gt;As a developer, I have to admit that regex is one of the most confusing and rather annoying topics I have had to deal with, and I believe it is the same for most developers out there. In case you don't know what regex expressions are, let's get down to it.&lt;/p&gt;

&lt;p&gt;Regular Expressions(Regex) are sequences of characters that specify a match pattern in text. - &lt;em&gt;Google&lt;/em&gt;. This means that; a regex value is a search pattern you can build/construct to match specific characters or patterns in a given text. For example, we have probably the most used/common regex pattern which is the pattern used for checking if a text is an email address or not, here is what it looks like; &lt;code&gt;^([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5})$&lt;/code&gt;. Honestly, it just looks like a bunch of random stuff but we both know it's not random.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;So, how can one construct a valid regex? Here is a guide to how I was able to create my first regex value.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  The Problem
&lt;/h2&gt;

&lt;p&gt;It always starts with a problem, doesn't it? While working on a poll feature that required the user to put in the duration of the poll, I needed to convert that duration which would be in string values, to a time unit(seconds) to block voting on the poll once the time was elapsed. The idea was pretty basic; when a user types in something like &lt;strong&gt;"20 days"&lt;/strong&gt;, I want to be able to convert that string to seconds equivalent to its value, meaning I want to get the value of 20 days in seconds. Also, keep in mind that the string can be as dynamic as ever, meaning it could read &lt;strong&gt;"5 weeks"&lt;/strong&gt; or &lt;strong&gt;"80 hours"&lt;/strong&gt;, and I needed to be able to satisfy every instance.&lt;/p&gt;

&lt;h2&gt;
  
  
  Solving the Problem
&lt;/h2&gt;

&lt;p&gt;The first thing I did was identify the time units to be expected from the user, being [second, minute, hour, day, or week], there was no reason for having month or year for a poll duration. &lt;br&gt;
Ideally, no matter what value is sent in, it must be in two words(the numeric value and the time unit). The time unit needed to be converted to seconds, and the numeric value was to assist in that conversion, so I created an object to identify what values I would be multiplying the numeric value against to get the value in seconds, came up with this;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const timeUnitinSeconds = {
            "second": 1,
            "minute": 60,
            "hour": 3600,
            "day": 86400,
            "week": 604800
        };

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

&lt;/div&gt;



&lt;p&gt;So if there is a value that reads "20 days", multiplying 20 by the value of "day"(86400) would get the value in seconds. All that was needed was knowing what value to multiply by.&lt;/p&gt;

&lt;p&gt;Firstly, I needed to make sure the incoming string was in the format being expected(e.g. 20 days), identify what the time unit is, and then multiply it accordingly. Here is where my regex comes in.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Constructing the regex pattern for this was significantly not the most important part of the feature, but it was definitely the most difficult part to get done.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In all honesty, I did not know how to create a regex pattern, so I did a Google search, clicked a few links, and found this &lt;a href="https://www.geeksforgeeks.org/write-regular-expressions/"&gt;link&lt;/a&gt; to be most useful. Now that I had basic knowledge, all that was left was to implement it.&lt;/p&gt;

&lt;p&gt;There was a lot of back and forth, a few hisses, and power naps, but in the end, I was able to come up with this;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/^(\d+)\s*(second|minute|hour|day|week)s?$/i
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here is what it means;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;/^ - This indicates the start of the pattern.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;(\d+) - This indicates the numeric value to be expected&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;\s* - This checks if there is a whitespace/tab or not&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;(second|minute|hour|day|week) - This checks if the time unit matches any of the values in the bracket.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;s? - This checks whether the time unit is in plural or not (day or days)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;$ - This indicates the end of the pattern&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;/i - This makes the pattern case insensitive so "20 days" would still be regarded as "20 Days".&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now that I am writing this article, it feels rather simple, but I spent almost 2 days trying to understand the whole thing and making it work. Such is the path of a developer(laughs in tiredness). &lt;br&gt;
The regex would match patterns/strings like "20 days", "3Hours" or "5  weeks", all irrespective of the spacing in between, or the case sensitivity.&lt;/p&gt;

&lt;p&gt;Here is my implementation of it;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;        const matches = durationString.match(/^(\d+)\s*(second|minute|hour|day|week)s?$/i);
        console.log("mat: ", matches);

        if (!matches) return this.process_failed_response("Invalid duration");

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

&lt;/div&gt;



&lt;p&gt;It was rather frustrating to work on, but still pretty interesting.&lt;/p&gt;

&lt;p&gt;Being a Backend Developer presents quite several challenges along the line, like this one, and of course, I love challenges, it is the reason why I became a Backend developer in the first place. Plus, it is also the reason why I joined in on the &lt;a href="https://hng.tech/internship"&gt;HNG-11&lt;/a&gt; internship program. I have heard about it a lot in my recent years as a developer but always learned about the registration late. Well, not anymore, and it's got me pretty excited.&lt;/p&gt;

&lt;p&gt;If you want to challenge yourself in your tech stack, I implore you to join the most fast-paced and challenging internship(HNG). &lt;br&gt;
Not just that, if you are someone looking to hire a tech talent, HNG has a pool of them available, you can check it out &lt;a href="https://hng.tech/hire"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;So, there you have it, I hope you have learned a thing or two about Regex(hopefully more), my name is Lawwee, and thank you for reading my post, you can connect with me via the information below, and send a DM if there is anything you’d like to talk about or ask.&lt;/p&gt;

&lt;p&gt;Have a good day.&lt;/p&gt;

&lt;p&gt;LinkedIn: &lt;a href="https://www.linkedin.com/in/mohammed-lawal/"&gt;https://www.linkedin.com/in/mohammed-lawal/&lt;/a&gt;&lt;br&gt;
Twitter: &lt;a href="https://twitter.com/lawaldafuture1"&gt;https://twitter.com/lawaldafuture1&lt;/a&gt;&lt;br&gt;
Email: &lt;a href="mailto:lawalmohammed567@gmail.com"&gt;lawalmohammed567@gmail.com&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>The Blockchain enDAOment</title>
      <dc:creator>Lawwee</dc:creator>
      <pubDate>Tue, 30 Aug 2022 01:07:00 +0000</pubDate>
      <link>https://dev.to/lawwee/the-blockchain-endaoment-nc3</link>
      <guid>https://dev.to/lawwee/the-blockchain-endaoment-nc3</guid>
      <description>&lt;p&gt;There is little to no doubt that the Web3/Blockchain space has brought about several implementations, and not just limiting it to the digital space, but also intertwining into our own physical space. One of those several implementations is the concept of Decentralized Autonomous Organization, popularly known as DAO.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is a DAO?&lt;/strong&gt;&lt;br&gt;
A Decentralized Autonomous Organization (DAO) can best be defined as an organizational entity, or company that has no central authority. The rules governing such organizations are constructed by computer programs. These rules can only be influenced or controlled solely by the members of such an organization and no outside body or person(s).&lt;br&gt;
To exemplify, if Twitter were to be a DAO, whatever update is being done to the platform won't be decided by its owners or managers, such updates would be decided by the users of the platforms.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Little bit of history&lt;/strong&gt;&lt;br&gt;
The first ever DAO was created in April 2016, called the DAO, by &lt;a href="https://www.linkedin.com/in/cjentzsch/?originalSubdomain=de"&gt;Christoph Jentzsch&lt;/a&gt; as a token sale. It was built on the Ethereum blockchain network and. was classified as a business model for commercial and non-profit enterprises&lt;br&gt;
Then by June, users had found a bug in the code and used that chance to carry home a substantial amount of their funds, which later led to a hard-fork of the ethereum blockchain.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How does a DAO work / function?&lt;/strong&gt;&lt;br&gt;
Well, as most things run on the blockchain space, DAOs are also run by nothing but several programs also known as smart contracts, each modified to serve whatever purpose the creator chooses.&lt;br&gt;
To give a typical example on how it works, in a DAO platform, if one of the users think it would be a good idea to give off a sum of their funds to charity, this idea is introduced and submitted as a proposal where each user has a right to vote for or against the idea. And as it is in the normal view of democratic elections, those with the major counts would be the ones whose choices are accepted, that easy.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Are DAOs safe?&lt;/strong&gt;&lt;br&gt;
To speak on a personalized view in regards to experience, the idea of DAOs are safe, but it has been showcased from the first ever created DAO, that any vulnerability in the source code of such a project can lead to massive fallouts. So, technically, a DAO can only be as safe as the developer that creates it and as thorough as the team that tests it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Benefits of a DAO&lt;/strong&gt;&lt;br&gt;
The creation of DAOs has been one of the major highlights of the Web3 space, it has introduced governance into a system without a point of authority, herein providing a different kind of order to a kind of chaos. Here are some benefits of a DAO that make them awesome:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;No single person or entity has control over it, hence there is no central point of failure.&lt;/li&gt;
&lt;li&gt;The Automated structure of DAOs make the rules always enforced without any human interference or input.&lt;/li&gt;
&lt;li&gt;Unlike the usual organizations with a top-down structure that makes management difficult, DAOs are community based, hence having no issue with management&lt;/li&gt;
&lt;li&gt;DAOs provide a valid sense of trust and transparency to its users, there is no need for familiarity amongst the creators or possible investors, as far as one understands the source code, and also believes in the project, strangers would always be at ease.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Headaches of a DAO&lt;/strong&gt;&lt;br&gt;
As we have all possibly guessed by now, every creation with a good side always has its headaches that one needs to deal with, here are a few points that make DAOs a not so awesome creation:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The first issue would definitely be the code vulnerability, even though DAOs provide a trustless and transparent environment, this still heavily depends on the source code of such DAO, so if the code has a weakness, then it can be exploited and put the company in a real pinch.&lt;/li&gt;
&lt;li&gt;Another issue which people would not believe to be one, is the transaction time it takes for DAO to enforce decisions. As stated earlier that proposals are submitted and then voted upon in order to make changes, this may become a very major setback in terms of actions that need to be taken immediately such as detection of a security threat. The voting period could take a considerable amount of time, hereby causing slow and ineffective decision making&lt;/li&gt;
&lt;li&gt;Although having a voting system in place seems cool, this may also prove to be rather dangerous, if majority of the holders can choose to use the DAO to their own advantage, the concentration of voting power would fall in their favor.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Examples of a DAO&lt;/strong&gt;&lt;br&gt;
Over the creation of the first DAO in 2016, there are now thousands of existing DAOs around, here are some of them.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Uniswap&lt;/li&gt;
&lt;li&gt;Aave&lt;/li&gt;
&lt;li&gt;Gitcoin&lt;/li&gt;
&lt;li&gt;Aragon&lt;/li&gt;
&lt;li&gt;Flamingo and so on.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Summary&lt;/strong&gt;&lt;br&gt;
DAOs (Decentralized Autonomous Organizations) are community based organizations that have no central point of authority. The first ever DAO was called The DAO, and was created by a great guy known as Christoph Jentzsh in April 2016. DAOs are created and run through smart contracts, while using a voting system to enforce its decision making. They can only be as safe as those involved with the initial creation and public release. It has several benefits such as decentralization, trustless environment and so on. Although it also comes with its own disadvantages such as slow decision making and code vulnerability. There are several thousands of available DAO available on the internet, such as Uniswap and Aave.&lt;/p&gt;

&lt;p&gt;So, there you have it, i hope you have learnt a thing or two about DAOs (hopefully more), my name is Lawwee and thank you for reading my post, you can connect with me via the information below, and send a DM if there is anything you’d like to talk about or ask.&lt;/p&gt;

&lt;p&gt;Have a good day.&lt;/p&gt;

&lt;p&gt;LinkedIn: &lt;a href="https://www.linkedin.com/in/mohammed-lawal/"&gt;https://www.linkedin.com/in/mohammed-lawal/&lt;/a&gt;&lt;br&gt;
Twitter: &lt;a href="https://twitter.com/lawaldafuture1"&gt;https://twitter.com/lawaldafuture1&lt;/a&gt;&lt;br&gt;
Email: &lt;a href="mailto:lawalmohammed567@gmail.com"&gt;lawalmohammed567@gmail.com&lt;/a&gt;&lt;/p&gt;

</description>
      <category>blockchain</category>
      <category>web3</category>
      <category>smartcontracts</category>
      <category>ethereum</category>
    </item>
    <item>
      <title>The Sol of Programming</title>
      <dc:creator>Lawwee</dc:creator>
      <pubDate>Thu, 18 Aug 2022 22:32:23 +0000</pubDate>
      <link>https://dev.to/lawwee/the-sol-of-programming-4l1b</link>
      <guid>https://dev.to/lawwee/the-sol-of-programming-4l1b</guid>
      <description>&lt;p&gt;With the high rise of interested participants in the blockchain and Web3 space, there has been a number of demanding skills flying around, skills for developers, designers, writers, you name it. That’s just how massive this space is. But today, we are going to talk about a skill for the developers, one I believe to be the most basic and required tool for any blockchain developer, and that is of course, the Solidity programming language.&lt;/p&gt;

&lt;h2&gt;
  
  
  Little bit of History Lesson
&lt;/h2&gt;

&lt;p&gt;Solidity was first proposed (publicly) in August, 2014 by none other, than the genius mind of one out of the two founders of the Ethereum Blockchain, &lt;a href="https://en.wikipedia.org/wiki/Gavin_Wood"&gt;Gavin Wood&lt;/a&gt;, and was later developed by the Ethereum project’s Solidity team led by another genius, &lt;a href="https://www.linkedin.com/in/dr-christian-reitwiessner-594b0982/?originalSubdomain=de"&gt;Dr. Christian Reitwiessner&lt;/a&gt;. (Pardon my continuous use of genius). Lo and behold, the Solidity language was born. Thank you Dr. Christian and Mr. Gavin and everyone at Ethereum.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Solidity?
&lt;/h2&gt;

&lt;p&gt;Solidity is a high-level, object-oriented programming language, which basically means its structure is based on the concept of Objects in programming. It was specifically designed for the Ethereum Blockchain network, and its programs are being run on the Ethereum Virtual Machine (EVM).&lt;br&gt;
The one true sole purpose of the solidity is for creating unique blockchain programs(my words), otherwise commonly known as Smart Contracts.&lt;br&gt;
Other alternatives to the Solidity language are Rust, Vyper, Yul and even Javascript can be considered as a smart contract language, if you know how to use it.&lt;/p&gt;

&lt;h2&gt;
  
  
  How difficult is it to learn Solidity?
&lt;/h2&gt;

&lt;p&gt;To be honest, I would say Solidity is one of the easiest languages to learn, its syntax is a combination of earlier languages such as JavaScript, Python and C++. It has a very friendly approach to developers, anyone with little to no experience in programming could definitely learn without much of a hassle.&lt;/p&gt;

&lt;h2&gt;
  
  
  Features of Solidity.
&lt;/h2&gt;

&lt;p&gt;Just as any programming language, Solidity has a ton of features as well, which cannot all be listed in this article, so few which i believe are unique features of the language would be listed:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Contract Inheritance&lt;/li&gt;
&lt;li&gt;Specification of value and gas for function calls.&lt;/li&gt;
&lt;li&gt;Function modifiers&lt;/li&gt;
&lt;li&gt;Conversion between string and hash types&lt;/li&gt;
&lt;li&gt;Fallback functions&lt;/li&gt;
&lt;li&gt;Visibility specifiers&lt;/li&gt;
&lt;li&gt;Interface contracts&lt;/li&gt;
&lt;li&gt;Overloading  functions&lt;/li&gt;
&lt;li&gt;And so on.
Some of these functions may have similar names or use cases in regards to other programming languages, considering the origin story of the Solidity language, this is quite expected, but their uniqueness can only truly be felt when used.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Solidity Frameworks
&lt;/h2&gt;

&lt;p&gt;As is the case with many other languages, Solidity of course has its own frameworks. These frameworks are mainly centered on writing scripts for the smart contracts created, and also creating test cases for them. &lt;br&gt;
The most common and probably dominant of them is &lt;strong&gt;Hardhat&lt;/strong&gt;. It is a javascript and solidity-based framework for the development of Smart Contracts. We’ve also got :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Brownie ⇒ Python based. (Also supports Vyper)&lt;/li&gt;
&lt;li&gt;Truffle ⇒ Javascript based.&lt;/li&gt;
&lt;li&gt;Waffle ⇒ Javascript based.&lt;/li&gt;
&lt;li&gt;Dapp.tools ⇒ Haskell based. &lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Pros of Solidity
&lt;/h2&gt;

&lt;p&gt;Having rolled out the features of the Solidity language, let’s talk about the good stuff, why anyone should learn this language, what makes the language so jolly to developers.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;It has a similar syntax to Javascript, C++ and Python, making 
it easy to learn and understand for developers with the 
background of either languages.&lt;/li&gt;
&lt;li&gt;Although it was originally developed for the Ethereum 
blockchain, Solidity can still be used to program smart 
contracts on other blockchains.&lt;/li&gt;
&lt;li&gt;Being the first smart contract programming language, it has a 
wide and accessible community.&lt;/li&gt;
&lt;li&gt;Due to the implementation of the Application Binary Interface ( 
ABI), it is able to support multiple type-safe functions.&lt;/li&gt;
&lt;li&gt;It allows for the development of secure and reliable platforms 
involved in settlement or agreement between two parties without 
the inclusion of a third party.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Cons of Solidity
&lt;/h2&gt;

&lt;p&gt;Just like any aspect of technology, the solidity language also has its downsides and limitations, and perhaps reasons why certain developers would refuse to touch down on the language use cases.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Even though it has a large community where libraries and tools are created to help with its development, it is still a new language with so much to be done that programmers would have to find a way and complete themselves.&lt;/li&gt;
&lt;li&gt;The language is strictly niched to one aspect of software development, which means anything out of blockchain development, the language becomes useless.&lt;/li&gt;
&lt;li&gt;There is also the issue of overflow and underflow which is a prominent solidity security issue, due to the fixed size of integer data types that the EVM can support. &lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;The Solidity language is an Object Oriented programming language developed for the Ethereum blockchain, but can still perform its functions for other blockchain networks. Its syntax is derived from previous languages like Javascript and C++, making it very easy to learn and understand.&lt;br&gt;
Its features include Contract inheritance, function modifiers, contract interfaces and so on.&lt;br&gt;
Solidity based frameworks are mainly for testing smart contracts, and writing scripts. Examples are Hardhat, Truffle, Brownie and so on.&lt;br&gt;
Although the language has a lot of cool features to its advantage, it has a number of disadvantages that make development quite tiresome.&lt;/p&gt;

&lt;p&gt;So, there you have it, i hope you have learnt a thing or two about Solidity (hopefully more), my name is Lawwee and thank you for reading my post, you can connect with me via the information below, and send a DM if there is anything you’d like to talk about or ask.&lt;/p&gt;

&lt;p&gt;Have a good day.&lt;/p&gt;

&lt;p&gt;LinkedIn: &lt;a href="https://www.linkedin.com/in/mohammed-lawal/"&gt;https://www.linkedin.com/in/mohammed-lawal/&lt;/a&gt;&lt;br&gt;
Twitter: &lt;a href="https://twitter.com/lawaldafuture1"&gt;https://twitter.com/lawaldafuture1&lt;/a&gt;&lt;br&gt;
Email: &lt;a href="mailto:lawalmohammed567@gmail.com"&gt;lawalmohammed567@gmail.com&lt;/a&gt;&lt;/p&gt;

</description>
      <category>solidity</category>
      <category>web3</category>
      <category>blockchain</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
