avatarStephen Dalton

Free AI web copilot to create summaries, insights and extended knowledge, download it at here

3786

Abstract

arison operators, and bitwise operators on this type too.</p><p id="c4da">It’s important to note that there is another type, called <code>bytes</code> which is different from the above in that it is a dynamically sized array, and not a value type but a reference type. It is basically shorthand for <code>byte[]</code>.</p><p id="ad39">When you can limit the length of your data to a predefined amount of bytes, it is always good practice to use some of <code>bytes1</code> to <code>bytes32</code> because it is much cheaper.</p><h2 id="0118">Enums</h2><p id="aea7"><b>Enums</b> in Solidity are a way to create user-defined types. Enums are explicitly convertible to integer types, but not implicitly. Enum values are numbered in the order they are defined, starting from 0.</p><p id="ed00">Enums are not part of the ABI (Application Binary Interface — more on this in a later lesson, but it’s basically how you encode Solidity code for the Ethereum Virtual Machine, and how you get data back). This means that if your function returns an <code>enum</code> for example, it will be automatically converted to a <code>uint8</code> behind the scenes. The integer returned is just large enough to hold all enum values. With more values, the size gets increased too (<code>uint16</code> and up).</p><p id="cdb6">The below code, taken from the <a href="https://docs.soliditylang.org/en/v0.4.24/index.html">Solidity docs</a>, defines an enum with four possible values, creates a variable of that enum named <code>choice</code> and a constant called <code>defaultChoice</code>that will hold a default value.</p><div id="cf29"><pre><span class="hljs-keyword">enum</span> <span class="hljs-title class_">ActionChoices</span> { GoLeft, GoRight, GoStraight, SitStill } ActionChoices choice; ActionChoices <span class="hljs-type">constant</span> <span class="hljs-variable">defaultChoice</span> <span class="hljs-operator">=</span> ActionChoices.GoStraight;</pre></div><p id="66a9">Now we can define some functions to interact with our <code>enum</code>.</p><div id="c0bb"><pre><span class="hljs-title function_"><span class="hljs-keyword">function</span> <span class="hljs-title">setGoStraight</span></span>() <span class="hljs-keyword">public</span> { choice = ActionChoices.GoStraight; }

<span class="hljs-title function_"><span class="hljs-keyword">function</span> <span class="hljs-title">setChoice</span></span>(ActionChoices <span class="hljs-keyword">new</span><span class="hljs-type">Choice</span>) <span class="hljs-keyword">public</span> { choice = <span class="hljs-keyword">new</span><span class="hljs-type">Choice</span>; }</pre></div><p id="6bc2">The first one simply sets the <code>choice</code> to <code>GoStraight</code> while the second one sets it to the choice that the caller passes into the function. As we can see after deployment, the <code>setChoice</code> function expects a <code>uint8</code> value, which corresponds to the <code>enum</code> value declared at that number.</p><figure id="e997"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*1pKNPVy4UUBCSLi2-SIckg.png"><figcaption>Testing enums in Remix</figcaption></figure><p id="7917">If we want to get the value of <code>choice</code> and <code>defaultChoice</code>, we can define the following functions:</p><div id="1f02"><pre><span class="hljs-keyword">function</span> <span class="hljs-title">getChoice</span>() public view returns (ActionChoices) { <span class="hljs-keyword">return</span> <span class="hljs-type">choice</span>; }</pre></div><div id="43e7"><pre><span class="hljs-function">function <span class="hljs-title">getDefaultChoice</span>() <span class="hljs-keyword">public</span> pure <span class="hljs-title">returns</span> (<span class="hljs-params"><span class=

Options

"hljs-built_in">uint</span></span>)</span> { <span class="hljs-keyword">return</span> <span class="hljs-built_in">uint</span>(defaultChoice); }</pre></div><p id="c2f2">As we can see if we try this out in Remix, the first function returns a <code>uint8</code> while the second returns a <code>uint256</code>.</p><figure id="e514"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*jmaOFb9GhXz7FWC4ONMa_A.png"><figcaption>Testing enums in Remix</figcaption></figure><h2 id="3c7c">Fixed point numbers</h2><p id="2ecc"><b>Fixed point numbers </b>represent fractional numbers by storing a fixed number of digits of their fractional part. No matter how large or small the fractional part is, it will always use the same number of bits.</p><p id="cdcd" type="7">Fixed point numbers are not fully supported by Solidity yet. They can be declared, but cannot be assigned to or from.</p><p id="f872">We can differentiate between signed fixed point numbers, declared with the <code>fixed</code> keyword, and unsigned fixed point numbers, declared with the <code>ufixed</code> keyword.</p><p id="3c1c">It can also be declared as <code>fixedMxN</code> or <code>ufixedMxN</code> where <code>M</code> represents the number of bits the type takes, and <code>N</code> represents the number of decimal points. <code>M</code> has to be divisible by 8 and a number between 8 and 256. <code>N</code> has to be a number between 0 and 80.</p><p id="96e1">They function with the following operators:</p><ul><li>Comparisons: <code><=</code>, <code><</code>, <code>==</code>, <code>!=</code>, <code>>=</code>, <code>></code> (evaluate to <code>bool</code>)</li><li>Arithmetic operators: <code>+</code>, <code>-</code>, unary <code>-</code>, unary <code>+</code>, <code>*</code>, <code>/</code>, <code>%</code> (remainder)</li></ul><h2 id="09b7">Conclusion</h2><p id="bd3a">In this lesson, we looked at what value types are available in Solidity and how each one works.</p><p id="28de">Thank you for staying with us till the end. If you enjoyed reading this piece please keep in touch and follow Solidify to keep up with our lessons on Solidity. In the upcoming articles, we will deep dive into the intricacies of the language, progressing from beginner to advanced level.</p><p id="067c">If you are new to Solidity, check out the previous lessons about setting up a local development environment and writing your first smart contract.</p><div id="6b76" class="link-block"> <a href="https://readmedium.com/how-to-setup-your-local-solidity-development-environment-c4c8195810f3"> <div> <div> <h2>How to Setup Your Local Solidity Development Environment</h2> <div><h3>Get started with smart contract development</h3></div> <div><p>medium.com</p></div> </div> <div> <div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/1*HHko-o9m1sVngmTeRVYgKA.jpeg)"></div> </div> </div> </a> </div><div id="3ad1" class="link-block"> <a href="https://readmedium.com/lesson-1-your-first-solidity-smart-contract-1ba7e641f9a3"> <div> <div> <h2>Lesson 1: Your First Solidity Smart Contract</h2> <div><h3>In the previous lesson, we looked at how to set up your local Solidity development environment. Here we will continue…</h3></div> <div><p>medium.com</p></div> </div> <div> <div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/1*7r7HSYkbn73NrmR_skvh5w.jpeg)"></div> </div> </div> </a> </div></article></body>

LIFE LESSONS ABOUT WORK-LIFE BALANCE

How to Create a Better Life-Work Balance

Notice how I put life first in the title, where most articles you read on the internet talk about a work-life balance?

Photo by Anastasiya Gepp from Pexels

We must flip the scenario. Put life before work, and family and friends before that second job. Sure, money is essential to a good life, but life should be the priority.

If you Google work-life balance, you will discover hundreds of thousands of articles on the subject. If you invert it, you will not find many search results. Google will change it to work-life balance because that is the keyword most will search for because most put work before life. What we need to do to achieve a better balance is to put life first.

Dolly Parton, in her book, Dolly: My Life and Other Unfinished Business, said, “Don’t get so busy making a living that you forget to make a life.”

In many households where both parents work, it can be nearly impossible to find the right balance between family and work. The threat of losing your job makes it even easier to work longer hours and devote more time to work, which means less with your family.

According to a report in Psychology Today, roughly 95 percent of top breadwinners in the family work more than 50 hours per week and nearly half work 65 or more hours per week.

The experts agree on this, the stress of a seemingly never-ending workweek will not only damage your health but relationships and your chance at happiness. The Japanese have a name for this. It’s called karoshi, which literally translates to “death from working too much.”

Whereas I cannot propose a way to get you to leave work every day at 5 pm or whatever time signals the end of your working day, I can provide these 5 tips to improve your life-work balance.

#1 — Unwind & Unplug

After work, let your mind slip out of the work mode and into family or social mode. You don’t have to unplug the phone but unplug from the need to hover over it, waiting for it to ring. Set aside a time in the evening to respond to work emails, not while you are spending time with your family. You need to devote as much attention to your family while you are with them as you do work while you are there.

According to Dr. Robert Brooks in The Power of Resilience, you can build a better work-life balance by cultivating your inner strength and self-confidence. Don’t allow work or your employer to monopolize your time.

Unwind and enjoy the time with your family.

#2 — Not Everything “Must” Be Perfect

Life as an adult is much more complicated than as a student, even those that have an afterschool job have much fewer responsibilities.

As students, we learned to make everything we do perfect, we want that 4.0 GPA to get scholarships so that we can continue our schooling and make a better life.

As an adult, if we spend the time to make everything perfect, we will most likely fail at something else. Instead of trying to make everything perfect, settle instead for excellence in everything you do. Trying to make everything perfect can be destructive and filled with self-induced stress.

#3 — Meditation & Exercise

Make time for yourself. Exercise breeds energy, so make time to get your exercise. Make time for yourself. Normally, when we are busy, the first thing to get eliminated from our calendar is exercise. That’s unwise because exercise will give us more energy to complete the tasks we have on our calendar.

What’s more, a good 15–20 minutes of meditation can clear our minds of the clutter. You might believe sitting in front of the TV is a good relaxation tool. Sometimes it is OK for 30 minutes or an hour, even a two-hour movie with family can be beneficial. However, our minds need to get cleansed of all that rubbish through soul-searching meditation.

Typically, the best time to get some “me” time is early in the morning before everyone else gets up, and things start happening. Getting up while everyone else still sleeps typically means you can get in a 45-minute workout or walk. Not only will you get that “me” time, but you’ll have plenty of hot water.

#4 — Limit Activities that Waste Your Time

Social media and our phones, for many, have become a necessity, or at least we think they are. When you stop and think about how much time you spend mindlessly scrolling through your Newsfeed on Facebook or chatting with friends on the phone, it is probably a lot more than you would like.

Identify and prioritize what is most important in your life, such as family, work, and friends, reading, and writing. Then, limit how much time you spend doing things that are not in those categories, such as TV, email, phone chatting, Facebook (except to promote your writing), and other social media. Spending too much time on any of these activities detracts from those things many people identify as the most essential things in life.

You can better use that time reading a few articles and catching some ideas for future articles you should write. Limit your phone time or Facebook time to one hour per day. 30 Minutes in the morning and 30 minutes in the evening, or whatever schedule you decide for yourself. Then, you will have more quality time for your family, reading & writing, or other vital things on your list.

#5 — Start with the Little Things to Build a Better Life

We must make the changes gradually to be successful. Think about what happens when you slam on the brakes in your car. Even our co-workers, partners, and employers will think something wrong if we try to cut back from 65 to 40 too abruptly.

If we try to change too much too rapidly, we can ruin our chances of success at a life-work balance before we even get started. We didn’t go from working 40 hours a week to working 65 hours a week overnight, and trying to cut back from 65 to 40 will not happen overnight either.

Start by delegating or outsourcing more of the work you should not have on your plate. Certainly, there are things that you are doing at work that are not in your job description, but when you got promoted, you just continued to do those because you were good at it or you enjoyed doing it. Stop! You cannot do everything, and you need to make more time for your family.

Takeaways

To create a better life-work balance, unwind and unplug, remember not everything has to be perfect, take more time to meditate and exercise, limit the activities that waste your precious time, and start slowly by changing the little things to build a better life.

More Essays by the Author

About the Author Photo by Jean Springs from Pexels

Stephen Dalton is a retired US Army First Sergeant with a degree in journalism from the University of Maryland and a Certified US English Chicago Manual of Style Editor. Currently living in the Philippines, Stephen is a Top Writer in Virtual Reality.

You can see his portfolio here. Email [email protected]

Website | Facebook | Twitter | Instagram | Reddit

Life
Work Life Balance
Life Lessons
Lifestyle
Meditation
Recommended from ReadMedium