<?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[Stories by Younis Jad on Medium]]></title>
        <description><![CDATA[Stories by Younis Jad on Medium]]></description>
        <link>https://medium.com/@younisjad?source=rss-57da83c15db4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*QnRzyk_3wVHYOfZ90-u8Bw.png</url>
            <title>Stories by Younis Jad on Medium</title>
            <link>https://medium.com/@younisjad?source=rss-57da83c15db4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 00:15:25 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@younisjad/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Breaking the Silence: A Modern Approach to Workplace Mental Health]]></title>
            <link>https://younisjad.medium.com/breaking-the-silence-a-modern-approach-to-workplace-mental-health-1c471ab1743b?source=rss-57da83c15db4------2</link>
            <guid isPermaLink="false">https://medium.com/p/1c471ab1743b</guid>
            <category><![CDATA[workplace-culture]]></category>
            <category><![CDATA[mental-health]]></category>
            <category><![CDATA[mental-health-awareness]]></category>
            <category><![CDATA[startup]]></category>
            <dc:creator><![CDATA[Younis Jad]]></dc:creator>
            <pubDate>Mon, 18 Aug 2025 22:06:41 GMT</pubDate>
            <atom:updated>2025-08-18T22:06:41.309Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4QgiqZ3jOf_wW8lH" /><figcaption>Photo by <a href="https://unsplash.com/@lazizli?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash">Lala Azizli</a> on <a href="https://unsplash.com/photos/man-in-gray-long-sleeve-shirt-1MUzmoQSd3w?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash">Unsplash</a></figcaption></figure><p>In today’s high-pressure work environment, mental health has become the elephant in the room — one that’s crushing productivity while we pretend not to notice.</p><h3>The Sobering Reality of Workplace Mental Health</h3><ul><li>The average employee spends 3 hours per workday feeling burnt out</li><li>Only 1 in 4 employees feels comfortable discussing mental health with managers</li><li>$4,900 per employee lost annually to stress-related productivity declines</li><li>Average of 12 workdays per employee lost annually due to anxiety</li><li>Teams with high stress levels experience 40% more turnover</li></ul><p>We’re creating a mental health crisis while maintaining a culture of silence. This isn’t just a human cost — it’s a significant business liability.</p><h3>A New Paradigm for Workplace Wellbeing</h3><p>Progressive organizations are reimagining how mental health support integrates into the workplace ecosystem. The most effective approaches operate on a three-pillar framework:</p><h3>1. Pre-Intervention Assessment and Support</h3><ul><li><strong>Daily Check-ins:</strong> Brief, guided check-ins that take less than 2 minutes but provide valuable insights into employee mental states</li><li><strong>Early Warning System:</strong> Identifying patterns that may indicate developing stress, anxiety, or burnout</li><li><strong>Resource Matching:</strong> Connecting employees with appropriate resources based on their specific needs</li></ul><h3>2. Ongoing Support Systems</h3><ul><li><strong>Digital Companions:</strong> Available 24/7 for employees to discuss concerns in a judgment-free space</li><li><strong>Micro-Interventions:</strong> Evidence-based exercises delivered at the right moment to prevent escalation</li><li><strong>Anonymous Aggregate Reporting:</strong> Helps organizations identify systemic issues while maintaining individual privacy</li></ul><h3>3. Post-Therapy Integration</h3><ul><li><strong>Therapy Reinforcement:</strong> Helping employees practice and integrate tools learned in therapy</li><li><strong>Progress Tracking:</strong> Measuring improvement over time with concrete metrics</li><li><strong>Relapse Prevention:</strong> Identifying when someone might be slipping back into old patterns</li></ul><h3>The Dual Responsibility Approach</h3><p>Effective mental health support requires both organizational commitment and personal responsibility.</p><h3>For Organizations:</h3><ul><li><strong>Cultural Transformation:</strong> Moving beyond token wellness programs to true mental health integration</li><li><strong>Leadership Training:</strong> Equipping managers to recognize, respond to, and prevent mental health challenges</li><li><strong>Data-Driven Improvements:</strong> Using anonymous insights to create healthier work environments</li></ul><h3>For Individuals:</h3><ul><li><strong>Self-Advocacy Tools:</strong> Resources to help employees set boundaries and communicate needs</li><li><strong>Personalized Strategies:</strong> Custom approaches based on individual working styles and stressors</li><li><strong>Stigma Reduction:</strong> Safe pathways to seek help without fear of career repercussions</li></ul><h3>Measurable Benefits of a Comprehensive Approach</h3><p>Organizations implementing comprehensive mental health solutions have seen remarkable improvements:</p><ul><li>32% reduction in absenteeism</li><li>28% increase in employee retention</li><li>43% of users report improved work satisfaction</li><li>64% of users feel better equipped to manage workplace stress</li></ul><h3>Breaking the Silence: A Call to Action</h3><p>The truth is that mental health requires both structural support and individual action. Progressive companies are already moving forward with:</p><ul><li>Mental health days as standard policy</li><li>Comprehensive therapy benefits</li><li>Stress management programs</li><li>Open conversations about wellness</li></ul><p>But employees must also take steps:</p><ul><li>Set clear boundaries around work hours and availability</li><li>Take regular breaks throughout the workday</li><li>Seek help when needed — early intervention is key</li><li>Refuse to suffer in silence</li></ul><h3>The Future of Work is Mentally Healthy</h3><p>We envision workplaces where mental health is not just acknowledged but actively supported. Where productivity rises not through pressure but through wellbeing. Where the elephant in the room is finally addressed, making space for everyone to thrive.</p><h3>Innovative Solutions in the Market</h3><p><a href="http://feneri.xyz/">Feneri</a> is one company leading innovation in this space. Their AI-powered platform, developed by a multidisciplinary team of mental health professionals, AI specialists, and workplace culture experts, serves as both a preventative tool and post-therapy support system. This integrated approach is making mental health support accessible, effective, and seamlessly embedded into daily work life.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/745/1*znjGG4NrZTxfKzTxEIsxFw.png" /><figcaption><a href="https://feneri.xyz/">F</a>eneri</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1c471ab1743b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From the Edge of Despair to AI Innovation: My Mental Health Startup Journey]]></title>
            <link>https://younisjad.medium.com/from-the-edge-of-despair-to-ai-innovation-my-mental-health-startup-journey-678a6a1f6eb0?source=rss-57da83c15db4------2</link>
            <guid isPermaLink="false">https://medium.com/p/678a6a1f6eb0</guid>
            <category><![CDATA[mental-health-awareness]]></category>
            <category><![CDATA[mental-health]]></category>
            <category><![CDATA[startup]]></category>
            <category><![CDATA[mental]]></category>
            <dc:creator><![CDATA[Younis Jad]]></dc:creator>
            <pubDate>Sun, 17 Aug 2025 13:48:39 GMT</pubDate>
            <atom:updated>2025-08-17T13:48:39.325Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*iqMOoDZOmzIXKE0t" /><figcaption>Photo by <a href="https://unsplash.com/@martzzl?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash">Marcel Strauß</a> on <a href="https://unsplash.com/photos/text-plC4Gb9C0C4?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash">Unsplash</a></figcaption></figure><p>The day my world collapsed remains vivid in my memory. A layoff notice without warning, and my professional career stopped within hours. This came after losing people close to me, and within days, those I had considered friends showed their true colors. I stood at the precipice of depression, staring into what seemed like a bottomless abyss.</p><p>This isn’t just another story about mental health struggles. It’s the origin story of how I started Feneri as a solo, broken founder, the AI platform that emerged from my darkest moments.</p><h3>When Everything Fell Apart</h3><p>The isolation that followed my layoff was profound. Sleepless nights became my routine. Days blended together in a haze of rejection emails and unanswered messages. I recognized the classic symptoms of depression settling in, but felt powerless to stop their advance.</p><p>What struck me most during this period wasn’t just my own suffering, but the realization of how difficult it was to reach out for help. The mental health systems in place seemed designed to help only after you’d hit rock bottom — not to catch you on the way down. and the symptoms of struggle were already there months even before the layoff, but i was so blind thinking this is caused by burnout.</p><h3>The Spark That Changed Everything</h3><p>It was during one particularly dark night, staring at my computer screen at 3 AM, that the first glimmer of Feneri appeared. What if technology could recognize emotional patterns before we even acknowledged them ourselves? What if AI could serve as an early warning system for mental health challenges?</p><p>For the first time in months, I felt the need for a solution. The next morning, instead of pulling the covers over my head as had become my habit, I opened my laptop and began to research.</p><p>I became obsessed with understanding how AI could detect emotional patterns through voice, text, and facial expressions. I talked to therapists, mental health researchers, and others who had struggled like me. Everyone agreed on one thing — early intervention was where the system failed most people.</p><h3>Building From Personal Experience</h3><p>I named my platform “Feneri” — the Turkish word for “lighthouse” — because that’s what I needed most during my darkest times: a guiding light. Every feature was designed to address a barrier I had personally encountered.</p><p>The real-time emotional analysis grew from my realization that subtle shifts in my own communication had preceded my depressive episode — changes I hadn’t recognized until looking back.</p><p>The privacy-first approach came from my own reluctance to share vulnerable feelings in a world where data breaches make headlines weekly.</p><p>The multilingual support emerged from recognizing that in diverse communities, language barriers often prevented people from accessing mental health resources in their native tongue.</p><h3>More Than Just Another App</h3><p>I didn’t want to create just another app. The world doesn’t need more technology for technology’s sake. I wanted to create a bridge — between those suffering and those who could help, between early warning signs and timely intervention, between AI capabilities and human compassion.</p><p>The development wasn’t smooth. There were funding challenges, technical hurdles, and moments when my own mental health wavered under the pressure. But the mission drove me forward.</p><p>Every time I felt like giving up, I remembered what it felt like to stand on that edge. I remembered wishing for someone or something to recognize my pain before I had to name it myself.</p><h3>A Lighthouse for Others</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/745/1*znjGG4NrZTxfKzTxEIsxFw.png" /><figcaption><a href="https://feneri.xyz/">Feneri</a></figcaption></figure><p>Today, Feneri is more than just my personal redemption story. It represents a new approach to mental health — one that combines technological innovation with deep empathy.</p><p>The most rewarding moments are the messages from users. People who say the platform will help them recognize they needed support. Therapists who tell us the will be able to intervene earlier and more effectively. HR professionals who sees healthier workplace dynamics.</p><p>Each conversation feels like validation — not just of the technology, but of the pain that birthed it. Every person who finds help through Feneri means one less person standing where I once stood, alone at the edge.</p><h3>The Journey Continues</h3><p>I don’t know if I would have chosen this path if I hadn’t experienced those months of darkness. But I know that the view from that edge showed me what was missing in the world. And now, perhaps fewer people will have to stand where I stood.</p><p>Mental health challenges don’t discriminate. They can affect anyone — executives, employees, students, parents. Through Feneri, I’m trying to create a world where technology serves as the first line of defense, identifying struggles before they become crises.</p><p>My journey from the edge of despair to founding Feneri taught me that our deepest wounds can become our greatest gifts to the world — if we’re brave enough to transform our pain into purpose.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=678a6a1f6eb0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Go 1.21: Generic Functions Comprehensive guide]]></title>
            <link>https://medium.com/lyonas/go-1-21-generic-functions-comprehensive-guide-6528b37feb5c?source=rss-57da83c15db4------2</link>
            <guid isPermaLink="false">https://medium.com/p/6528b37feb5c</guid>
            <category><![CDATA[golang-tutorial]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[golang-tools]]></category>
            <category><![CDATA[go]]></category>
            <category><![CDATA[golang-development]]></category>
            <dc:creator><![CDATA[Younis Jad]]></dc:creator>
            <pubDate>Sun, 30 Jul 2023 10:44:10 GMT</pubDate>
            <atom:updated>2023-08-06T00:59:03.720Z</atom:updated>
            <content:encoded><![CDATA[<h3>Go 1.21: Generic Functions Comprehensive Revisit</h3><h4>Exploring the Versatility of Generic Functions — A Deep Dive into Go 1.21</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f4HS8AcdYWYgreh7rK6s3A.png" /></figure><p>Generics have long been a highly anticipated feature in the Go programming language. With the release of Go 1.21.</p><p>This comprehensive guide aims to provide a detailed exploration of generics in Go 1.21, shedding light on their benefits, syntax, implementation, and best practices.</p><p>Check out My Notes on upcoming go version: <a href="https://younisjad.medium.com/whats-new-in-go-1-21-a-comprehensive-notes-96017750b390">What’s New in Go 1.21 a Comprehensive Notes</a></p><h4>Generics Basic Syntax in Go 1.21</h4><p>To define a generic function or type, we use the type T keyword followed by the name of the generic parameter enclosed in square brackets []. For instance, to create a generic function that takes in a slice of any type and returns the first element, we can define it as follows:</p><pre>func First[T any](items []T) T {<br>    return items[0]<br>}</pre><p>In the example above, [T any] denotes the type parameter T, which represents any type. The any keyword indicates that the T type can be any valid type.</p><p>We can then call the First function with any slice type, and the function will return the first element of that slice. For example:</p><pre>package main<br><br>func main() {<br>  intSlice := []int{1, 2, 3, 4, 5}<br>  firstInt := First[int](intSlice) // returns 1<br>  <br>  println(firstInt)<br>  <br>  stringSlice := []string{&quot;apple&quot;, &quot;banana&quot;, &quot;cherry&quot;}<br>  firstString := First[string](stringSlice) // returns &quot;apple&quot;<br>  <br>  println(firstString)<br>}</pre><p>Note that when calling a generic function, we specify the type argument in square brackets []. This allows the compiler to generate specific code for that type during compilation.</p><p>We can also add constraints to the generic type parameter to restrict it to certain types. For instance, if we want to limit the type T to only types that implement the Stringer interface, we can use a constraint like this:</p><pre>func PrintString[T Stringer](value T) {<br>    fmt.Println(value.String())<br>}</pre><p>The Stringer constraint ensures that the type T must have a String() method. This constraint allows us to safely call the String() method on the value parameter within the function.</p><h4>Generics with various types in Go 1.21</h4><p>In another example, let’s write function SumGenerics that performs addition operations on various numeric types such as int, int16, int32, int64, int8, float32, and float64.</p><pre>func SumGenerics[T int | int16 | int32 | int64 | int8 | float32 | float64](a, b T) T {<br>    return a + b<br>}</pre><p>Let’s see how we can utilize this generic function:</p><pre>package main<br><br>func main() {<br>  sumInt := SumGenerics[int](2, 3) // returns 5<br>  <br>  sumFloat := SumGenerics[float32](2.5, 3.5) // returns 6.0<br>  <br>  sumInt64 := SumGenerics[int64](10, 20) // returns 30<br>}</pre><p>In the code above, we can see that by specifying the type argument in square brackets [] when calling the generic function, we can perform addition operations on different numeric types. The type constraint ensures that only the specified types [T int, int16, int32, int64, int8, float32, or float64] can be used as type arguments.</p><p>Using generics in this manner allows us to write concise and reusable code without sacrificing type safety. The function can be called with various numeric types, and the compiler will generate specific code for each type, ensuring that the addition operation is performed correctly.</p><h4>Generics with arbitrary data types in Go 1.21</h4><p>generics can be used for serialization and deserialization of arbitrary data types, using the provided Serialize and Deserialize functions:</p><pre>type Person struct {<br> Name    string<br> Age     int<br> Address string<br>}<br><br>func Serialize[T any](data T) ([]byte, error) {<br>  buffer := bytes.Buffer{}<br>  encoder := gob.NewEncoder(&amp;buffer)<br>  err := encoder.Encode(data)<br>  if err != nil {<br>    return nil, err<br>  }<br>  return buffer.Bytes(), nil<br>}<br><br>func Deserialize[T any](b []byte) (T, error) {<br>  buffer := bytes.Buffer{}<br>  buffer.Write(b)<br>  decoder := gob.NewDecoder(&amp;buffer)<br>  var data T<br>  err := decoder.Decode(&amp;data)<br>  if err != nil {<br>    return data, err<br>  }<br>  return data, nil<br>}</pre><p>In this example, we have two generic functions, Serialize and Deserialize, which utilize Go’s gob package to convert arbitrary data types to bytes and vice versa.</p><pre><br>func DeserializeUsage() {<br>  person := Person{<br>  Name:    &quot;John&quot;,<br>  Age:     30,<br>  Address: &quot;123 Main St.&quot;,<br>  }<br><br>  serialized, err := Serialize(person)<br>  if err != nil {<br>    panic(err)<br>  }<br>  <br>  deserialized, err := Deserialize[Person](serialized)<br>  if err != nil {<br>    panic(err)<br>  }<br>  <br>  fmt.Printf(&quot;Name: %s, Age: %d, Address: %s&quot;, deserialized.Name, deserialized.Age, deserialized.Address)<br>}</pre><p>Output: Name: John, Age: 30, Address: 123 Main St.</p><p>In the above code, we create a Person instance with some data. We then use the Serialize function to convert the person object into a byte array. Later, using the Deserialize function, we convert the byte array back to the Person object.</p><p>By defining the Serialize and Deserialize functions as generic functions with the T any type parameter, we can serialize and deserialize any data type that supports encoding and decoding with the gob package.</p><h4>Custom Validators in Go Using Generics and the Validate Function</h4><p>let’s write a generic Validate function with custom validators.</p><pre>type Validator[T any] func(T) error<br><br>func Validate[T any](data T, validators ...Validator[T]) error {<br> for _, validator := range validators {<br>  err := validator(data)<br>  if err != nil {<br>   return err<br>  }<br> }<br> return nil<br>}</pre><p>In this example, we have a generic Validate function that performs data validation using custom validators. The Validator type represents a function that takes in a value of any type T and returns an error.</p><pre>func StringNotEmpty(s string) error {<br> if len(strings.TrimSpace(s)) == 0 {<br>  return fmt.Errorf(&quot;string cannot be empty&quot;)<br> }<br> return nil<br>}<br><br>func IntInRange(num int, min, max int) error {<br> if num &lt; min || num &gt; max {<br>  return fmt.Errorf(&quot;number must be between %d and %d&quot;, min, max)<br> }<br> return nil<br>}</pre><p>Additionally, we have two example custom validators: StringNotEmpty and IntInRange.</p><p>StringNotEmpty ensures that a string is not empty, and IntInRange checks if an integer is within a specified range.</p><pre>package main<br><br>func main() {<br>  person := Person{<br>    Name:    &quot;John&quot;,<br>    Age:     30,<br>    Address: &quot;123 Main St.&quot;,<br>  }<br>  <br>  err := Validate(person, func(p Person) error {<br>    return StringNotEmpty(p.Name)<br>  }, func(p Person) error {<br>    return IntInRange(p.Age, 0, 120)<br>  })<br>  <br>  if err != nil {<br>    println(err.Error())<br>    panic(err)<br>  }<br>  <br>  println(&quot;Person is valid&quot;)<br>}</pre><p>in this example, we create a Person instance and pass it through the Validate function. We define two custom validators for the Person struct, checking that the Name field is not empty and the Age field is within a valid range. If any of the validators return an error, the validation process is halted, and the respective error is returned.</p><p>By using generics and custom validators, the Validate function allows for flexible and reusable data validation across different data types, enhancing code reusability and making it easy to add or modify validation rules.</p><p><strong>Let’s write another example using the validator function:</strong></p><pre>type LoginForm struct {<br>    Username string<br>    Password string<br>}<br><br>func (f *LoginForm) Validate() error {<br>    return Validate(f,<br>        func(l *LoginForm) error {<br>            return StringNotEmpty(l.Username)<br>        },<br>        func(l *LoginForm) error {<br>            return StringNotEmpty(l.Password)<br>        },<br>    )<br>}<br><br>func ValidateUsage2() {<br>    loginForm := LoginForm{<br>        Username: &quot;John&quot;,<br>        Password: &quot;123&quot;,<br>    }<br><br>    err := loginForm.Validate()<br>    if err != nil {<br>        println(err.Error())<br>        panic(err)<br>    }<br><br>    println(&quot;Login form is valid&quot;)<br>}</pre><p>In this example, the LoginForm struct implements a Validate method that utilizes the Validate generic function we defined earlier.</p><p>The Validate method calls the generic Validate function and provides it with two custom validators specific to the LoginForm type. The validators, represented as closure functions, check if the Username and Password fields are not empty using the StringNotEmpty validator function.</p><p>To validate the LoginForm instance, we simply call the Validate method on the instance itself.</p><pre>package main<br><br>func main() {<br>  loginForm := LoginForm{<br>    Username: &quot;John&quot;,<br>    Password: &quot;123&quot;,<br>  }<br>  <br>  err := loginForm.Validate()<br>  if err != nil {<br>    println(err.Error())<br>    panic(err)<br>  }<br>  <br>  println(&quot;Login form is valid&quot;)<br>}</pre><p>If any of the validators return an error, the validation process is halted, and the respective error is returned. In such cases, we handle the error accordingly.</p><h3>Conclusion</h3><p>the examples showcased the power and versatility of generics in Go 1.21. Generics enable us to write reusable and type-safe code that can handle different data types and structures without sacrificing code clarity and maintainability.</p><p>Generics bring significant benefits to the Go programming language, enhancing code reuse, reducing redundancy, and improving code organization. With generics, developers have the ability to write more expressive, concise, and flexible code that adapts to different data types and structures, paving the way for more extensible and maintainable software development.</p><p>To access the source code used in the examples discussed above, please visit the following GitHub Gist: <a href="https://gist.github.com/unijad/d8cede6305e8cea1316402c2ee8321a0">Source Code</a> Or <a href="https://go.dev/play/p/S7L_Kw6-pIk?v=gotip">Go Playground</a></p><p>Additionally, if you are interested in learning more about the upcoming Go release version 1.21 and further insights on the discussed examples, please take a look at my comprehensive notes on the release: <a href="https://younisjad.medium.com/whats-new-in-go-1-21-a-comprehensive-notes-96017750b390">Go Upcoming Release 1.21</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6528b37feb5c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/lyonas/go-1-21-generic-functions-comprehensive-guide-6528b37feb5c">Go 1.21: Generic Functions Comprehensive guide</a> was originally published in <a href="https://medium.com/lyonas">akaSRC</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why Every Startup Should Have a Comprehensive SRS for Software Development]]></title>
            <link>https://younisjad.medium.com/why-every-startup-should-have-a-comprehensive-srs-for-software-development-cb7042d9365a?source=rss-57da83c15db4------2</link>
            <guid isPermaLink="false">https://medium.com/p/cb7042d9365a</guid>
            <category><![CDATA[startup]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[srs]]></category>
            <category><![CDATA[software-documentation]]></category>
            <category><![CDATA[startup-lessons]]></category>
            <dc:creator><![CDATA[Younis Jad]]></dc:creator>
            <pubDate>Wed, 26 Jul 2023 14:29:06 GMT</pubDate>
            <atom:updated>2023-07-26T14:29:06.611Z</atom:updated>
            <content:encoded><![CDATA[<h4>Aligning Stakeholders and Development Team with an SRS</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i-tykrY-FWy0wPE2e7ZT6Q.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@homajob?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Scott Graham</a> on <a href="https://unsplash.com/photos/5fNmWej4tAA?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>let’s explore why it is imperative for every startup to invest time and effort in crafting a comprehensive SRS before diving into software development. We will delve into the benefits, insights, and strategic advantages that arise from this crucial pre-development process. So let’s explore why writing an SRS is the cornerstone of a startup’s software development journey.</p><h4>6 Keypoints on Why Startups Should Start Writing SRS</h4><p>Developing software for a startup is an exciting yet challenging endeavor. As a startup, having a clear vision and well-defined goals is crucial for success. One of the essential steps in this process is creating a Software Requirements Specification (SRS) before embarking on the development journey.</p><p><strong>1. Clear Understanding of Requirements:</strong></p><p>Writing an SRS for your startup software provides a structured approach to capture and document all the necessary requirements. This process helps build a clear understanding of what needs to be developed, ensuring that all stakeholders are on the same page. It helps prevent miscommunication, reduces the risk of missed requirements, and sets a solid foundation for the development process.</p><p><strong>2. Effective Communication and Collaboration:</strong></p><p>Startups typically involve multiple stakeholders, such as founders, investors, developers, and potential clients. An SRS serves as a central document that facilitates effective communication and collaboration between these parties. It acts as a reference point for discussions, clarifications, and decision-making, enabling everyone to have a shared understanding of the software’s objectives and functionality.</p><p><strong>3. Minimize Costly Changes and Rework:</strong></p><p>Starting development without a clear understanding of requirements can lead to costly changes, rework, and delays. By investing time upfront to write an SRS, startups can identify and address potential issues early on. This proactive approach allows for smoother development, minimizes the need for major changes later in the process, and ultimately saves time and resources.</p><p><strong>4. Efficient Resource Allocation:</strong></p><p>With limited resources, startups need to allocate their time, budget, and talent effectively. Writing an SRS helps startups prioritize development efforts and allocate resources efficiently. By defining and prioritizing requirements, startups can focus on building the most critical features, ensuring that resources are not wasted on unnecessary functionalities.</p><p><strong>5. Stakeholder Alignment and Investor Confidence</strong></p><p>Having a well-defined SRS helps align stakeholders’ expectations and gain investor confidence. Startups can present the SRS to prospective investors, demonstrating a clear roadmap and a structured approach to software development. This level of transparency and professionalism can instill trust and credibility, increasing the chances of securing funding and support for the startup.</p><p><strong>6. Risk Management and Scalability:</strong></p><p>An SRS aids in identifying and managing potential risks associated with software development. It helps startups anticipate and address issues related to scalability, security, performance, and compatibility early on. By incorporating risk mitigation strategies into the SRS, startups can ensure that their software is designed, developed, and scalable to meet future demands.</p><h4>Crucial Sections that should be in SRS document:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4_CuHGX2HNgP3qVcnvoQog.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@kaleidico?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Kaleidico</a> on <a href="https://unsplash.com/photos/3V8xo5Gbusk?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>When developing software for your startup, creating a thorough and well-structured Software Requirements Specification (SRS) is essential. An SRS serves as a roadmap for your development team, stakeholders, and investors, outlining the goals, functionalities, and constraints of your software project.</p><p>To ensure the success of your startup, it is crucial to focus on certain key aspects when crafting your SRS.</p><p><strong>Product Perspective</strong></p><ul><li>Integration with Existing Fintech Infrastructure</li><li>Relationship with Third-Party Services (e.g., Payment Gateways, APIs)</li></ul><p><strong>Product Functions and Features</strong></p><ul><li>Account Management.</li><li>Payment Processing</li><li>Transaction Monitoring and Fraud Detection</li><li>Reporting and Analyticse.</li><li>Compliance and Regulatory Requirements (e.g., KYC, AML)</li></ul><p><strong>User Characteristics. User Roles</strong></p><ul><li>(e.g., Admin, Customer, Financial Analyst)</li><li>User Interface Preferences (e.g., Desktop, Mobile)</li></ul><p><strong>Functional Requirements</strong></p><ul><li>User Registration and Authentication</li><li>Account Creation and Management</li><li>Funds Deposit and Withdrawal</li><li>Transaction Authorization and Confirmation</li><li>Reporting and Analytics Generation</li></ul><p><strong>Performance and Scalability Requirements</strong></p><ul><li>Response Time and Throughput Targets</li><li>Scalability for Concurrent Users and Transaction Volumes</li></ul><p><strong>Security and Privacy Requirements</strong></p><ul><li>Encryption and Data Protection Measures</li><li>Access Control and Authentication Mechanisms</li></ul><p><strong>Reliability and Availability Requirements</strong></p><ul><li>Disaster Recovery and Backup Procedures</li><li>High Availability and Redundancy Configurations</li></ul><p><strong>Legal and Compliance Requirements</strong></p><ul><li>Compliance with Financial Regulations (e.g., GDPR, PCI-DSS)</li><li>Audit Trails and Data Retention Policies</li></ul><p><strong>System Design Constraints</strong></p><ul><li>Server Infrastructure Specifications</li><li>Client Device Compatibility</li></ul><p><strong>Architectural and Design Limitations</strong></p><ul><li>Technology Stack and Frameworks</li><li>Development Methodology and Approaches</li></ul><p><strong>External Interfaces and Integration Points</strong></p><ul><li>Third-Party APIs and Services</li><li>Error Codes and Data Validation</li><li>Integration with Banking Systems and Financial Institutions</li></ul><p><strong>Test Strategy and Approach</strong></p><ul><li>Functional Testing</li><li>Performance and Load Testing</li><li>Security and Vulnerability Testing</li></ul><p><strong>Acceptance Criteria</strong></p><ul><li>Criteria for Different System Functions and Modules</li><li>User Acceptance Testing (UAT) Plan</li></ul><p><strong>Validation Plans</strong></p><ul><li>Plan for Verifying Compliance with Regulatory Standards</li></ul><h4>Conclusion</h4><p>startups should start writing an SRS for their software development projects to ensure a clear understanding of requirements, facilitate effective communication, minimize costly changes and rework, allocate resources efficiently, gain stakeholder alignment and investor confidence, and manage risks while planning for scalability. By investing time in the SRS process, startups can lay the foundation for a successful and well-executed software development journey.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cb7042d9365a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What’s New in Go 1.21 a Comprehensive Notes]]></title>
            <link>https://medium.com/lyonas/whats-new-in-go-1-21-a-comprehensive-notes-96017750b390?source=rss-57da83c15db4------2</link>
            <guid isPermaLink="false">https://medium.com/p/96017750b390</guid>
            <category><![CDATA[release-notes]]></category>
            <category><![CDATA[golang-development]]></category>
            <category><![CDATA[golang-tools]]></category>
            <category><![CDATA[go]]></category>
            <category><![CDATA[golang]]></category>
            <dc:creator><![CDATA[Younis Jad]]></dc:creator>
            <pubDate>Tue, 25 Jul 2023 16:20:42 GMT</pubDate>
            <atom:updated>2023-07-28T04:25:35.311Z</atom:updated>
            <content:encoded><![CDATA[<h4>Go 1.21 Exciting Updates and Enhancements: A Comprehensive Overview</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OWUGPbMTINTQEZmSi3n-hQ.png" /><figcaption>Go 1.21 Exciting Updates and Enhancements: A Comprehensive Overview</figcaption></figure><p>The Go programming language has released its first Release Candidate (RC) for version 1.21, which is packed with new features, improvements, and performance enhancements. This article provides an overview of the notable changes and features in Go 1.21, along with some exciting additions to the standard library.</p><h3>Tool Improvements:</h3><h4>The Profile Guided Optimization (PGO) feature</h4><p>In Go 1.21, the process of enabling PGO optimization has been streamlined. By default, the standard approach is to store a pprof CPU profile with the filename “default.pgo” in the main package directory of the profiled binary. This profile is automatically detected by the go build command, enabling PGO optimizations during the build.</p><pre># Store default.pgo profile in the main package directory<br>$ go build<br># Assuming default.pgo exists, PGO optimizations will be applied during the build process</pre><p><strong>Committing Profiles in Source Repository</strong></p><p>To ensure reproducible and performant builds, it is recommended to commit the profiles directly into the source repository. This approach simplifies the build experience as there are no additional steps required to fetch the profiles other than fetching the source code.</p><pre># Committing default.pgo profile in the source repository<br>├── main.go<br>└── default.pgo<br># Developers can directly build the code with the committed profile<br>$ go build</pre><p><strong>Advanced PGO Profile Selection</strong></p><p>In more complex scenarios, the go build command provides the -pgo flag to control the PGO profile selection. By default, this flag is set to -pgo=auto, which follows the behavior described above using the default.pgo profile.</p><pre># Using -pgo flag to manually specify the profile for optimization<br>$ go build -pgo=/tmp/foo.pprof</pre><p><strong>Disabling PGO Optimization</strong></p><p>In cases where PGO optimizations are not desired, the -pgo flag can be set to -pgo=off to disable them entirely.</p><pre># Disabling PGO optimizations using the -pgo flag<br>$ go build -pgo=off</pre><p>These examples demonstrate the usage of the go build command for simplicity. The same principles apply to other build commands such as go install and go run.</p><blockquote>Note: Starting from Go 1.21, PGO optimizations are enabled by default. Prior to Go 1.21, PGO had to be explicitly enabled using the -pgo flag.</blockquote><h4>Backward and Forward Language Compatibility</h4><p>Go 1.21 introduces backward and forward language compatibility support in the go tool, making it easier for developers to ensure their code remains compatible with different language versions.</p><p>Example: Testing package with //go:debug directive in *_test.go file</p><pre>package mypackage_test</pre><pre>//go:debug mysetting=1<br>import (<br>    &quot;testing&quot;<br>    &quot;mypackage&quot;<br>)</pre><pre>func TestMyFunction(t *testing.T) {<br>    // Test code<br>    result := mypackage.MyFunction()<br>    // Assertion code<br>}</pre><p>In this example, the //go:debug mysetting=1 directive is included in the *_test.go file of the package being tested. This directive serves as a directive for the test’s main package and can override the default behavior for specific debug settings during testing. This allows different test scenarios to be executed by enabling specific debug settings.</p><p><strong>Reporting default GODEBUG settings for a main package</strong></p><pre>go list -f &#39;{{.DefaultGODEBUG}}&#39; my/main/package</pre><p>When executing this command, where my/main/package is the path to the main package, the Go toolchain will report the default GODEBUG settings that will be compiled into the main package. This command is useful to see the differences from the base Go toolchain defaults.</p><h3>Language Changes:</h3><h4>New Built-in Functions: min, max, and clear</h4><p>Go 1.21 introduces three new built-in functions, namely min, max, and clear, which provide convenient options for performing basic operations on numeric data.</p><p><strong>Min, Max Functions</strong></p><p>The min and max functions are built-in functions in Go that calculate the smallest or largest value, respectively, among a fixed number of arguments of ordered types. These functions require at least one argument to be passed.</p><p>The same type rules that apply to operators also apply to these functions. For ordered arguments x and y, calling min(x, y) is valid if the addition x + y is valid. The type of the result returned by min(x, y) is the same as the type of x + y, and the same applies to the max function. If all the arguments passed to these functions are constant, the result returned by these functions is also constant.</p><pre>var x, y int<br>m := min(x)                 // m == x<br>m := min(x, y)              // m is the smaller of x and y<br>m := max(x, y, 10)          // m is the larger of x and y but at least 10<br>c := max(1, 2.0, 10)        // c == 10.0 (floating-point kind)<br>f := max(0, float32(x))     // type of f is float32<br>var s []string<br>_ = min(s...)               // invalid: slice arguments are not permitted<br>t := max(&quot;&quot;, &quot;foo&quot;, &quot;bar&quot;)  // t == &quot;foo&quot; (string kind)</pre><p><strong>Clear Function</strong></p><p>The clear function is a built-in function that takes an argument of type map, slice, or type parameter type. It is used to delete or zero out all the elements within the provided data structure.</p><pre>var a = [...]int{0, 1, 2, 3, 4, 5, 6, 7}</pre><pre>package main</pre><pre>import (<br> &quot;fmt&quot;<br> &quot;math&quot;<br>)</pre><pre>func main() {<br> a := map[float64]bool{100: true, 1000: true, math.NaN(): true, math.NaN(): true}<br> delete(a, math.NaN())<br> fmt.Printf(&quot;before clear, a len: %d\n&quot;, len(a))<br> clear(a)<br> fmt.Printf(&quot;after clear, a len: %d\n&quot;, len(a))<br>}</pre><h4>Improved Type Inference for Generic Functions</h4><p>The type inference system for generic functions has received several improvements in Go 1.21. The Go specification now includes an expanded and clarified description of type inference, making it easier for developers to understand and utilize this powerful feature.</p><pre>// Improved type inference for generic functions</pre><pre>func genericFunc[T any](x T) {<br>    // Function implementation<br>}</pre><pre>value := 42<br>genericFunc(value) // Type inference automatically detects the type of value</pre><h4>Preview of Loop Variable Capture Improvement</h4><p>Go 1.21 introduces a preview feature aimed at addressing the common challenge of loop variable capture in Go programming. Developers can enable this feature in their code using an environment variable.</p><pre>var out []*int<br>for i := 0; i &lt; 3; i++ {<br>out = append(out, &amp;i)<br>}<br>fmt.Println(&quot;Values:&quot;, *out[0], *out[1], *out[2])<br>fmt.Println(&quot;Addresses:&quot;, out[0], out[1], out[2])</pre><p>goroutine Example that prints 1…10</p><pre>for i := 1; i &lt;= 10; i++ {<br> go func() {<br>  fmt.Println(i)<br> }()<br>}</pre><h3>New Introduced Packages:</h3><ul><li>New <a href="https://pkg.go.dev/log/slog@master">log/slog Package</a> for Structured Logging</li><li>New <a href="https://pkg.go.dev/slices@master">slices Package</a> for Common Operations on Slices</li><li>New <a href="https://pkg.go.dev/maps@master">maps Package</a> for Common Operations on Maps</li><li>New <a href="https://pkg.go.dev/cmp@master">cmp Package</a> for Comparing Ordered Values</li></ul><h3>Improved Performance:</h3><p>Improved Performance with PGO:In addition to the performance improvements from enabling PGO, Go 1.21 brings additional enhancements to overall performance.</p><h4>New Experimental Port for WebAssembly System Interface (WASI):</h4><p>Go 1.21 introduces an experimental port for the WebAssembly System Interface (WASI) — Preview 1, allowing developers to compile their Go code for the WebAssembly platform.</p><h4>Conclusion</h4><p>Go 1.21 offers enhancements in tooling, language features, standard library additions, and performance optimizations make Go an even more robust and efficient programming language for various use cases. With the availability of the Release Candidate, developers are encouraged to experiment, test, and provide feedback to help shape the final release slated for August 2023.</p><p>source: <a href="https://go.dev/blog/go1.21rc#:~:text=Go%201.21%20adds%20an%20experimental,WASM%20host%3A%20go%3Awasmimport%20.">https://go.dev/blog/go1.21rc#:~:text=Go%201.21%20adds%20an%20experimental,WASM%20host%3A%20go%3Awasmimport%20.</a></p><p>Reference:</p><ul><li><a href="https://go.dev/blog/go1.21rc#:~:text=Go%201.21%20adds%20an%20experimental,WASM%20host%3A%20go%3Awasmimport%20.">https://go.dev/blog/go1.21rc#:~:text=Go%201.21%20adds%20an%20experimental,WASM%20host%3A%20go%3Awasmimport%20.</a></li><li><a href="https://go.dev/doc/pgo#:~:text=Profile%2Dguided%20optimization%20(PGO)%2C%20also%20known%20as%20feedback,information%20to%20make%20more%20informed">https://go.dev/doc/pgo#:~:text=Profile%2Dguided%20optimization%20(PGO)%2C%20also%20known%20as%20feedback,information%20to%20make%20more%20informed</a></li><li><a href="https://tip.golang.org/doc/godebug">https://tip.golang.org/doc/godebug</a></li><li><a href="https://tip.golang.org/ref/spec#Min_and_max">https://tip.golang.org/ref/spec#Min_and_max</a></li><li><a href="https://github.com/golang/go/wiki/CommonMistakes">https://github.com/golang/go/wiki/CommonMistakes</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=96017750b390" width="1" height="1" alt=""><hr><p><a href="https://medium.com/lyonas/whats-new-in-go-1-21-a-comprehensive-notes-96017750b390">What’s New in Go 1.21 a Comprehensive Notes</a> was originally published in <a href="https://medium.com/lyonas">akaSRC</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[(Series) Efficient Workflows in Go with Temporal: Signals & Selectors]]></title>
            <link>https://medium.com/lyonas/series-efficient-workflows-in-go-with-temporal-signals-selectors-ddd4bbc285d4?source=rss-57da83c15db4------2</link>
            <guid isPermaLink="false">https://medium.com/p/ddd4bbc285d4</guid>
            <category><![CDATA[golang-tutorial]]></category>
            <category><![CDATA[go]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[temporal]]></category>
            <dc:creator><![CDATA[Younis Jad]]></dc:creator>
            <pubDate>Sun, 23 Jul 2023 15:35:02 GMT</pubDate>
            <atom:updated>2023-07-23T15:35:41.303Z</atom:updated>
            <content:encoded><![CDATA[<p>Orchestrating Success: the Potential of Temporal Signals &amp; Selectors</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1UP3C_NUCPMw9549A06jSg.png" /></figure><p>This Tutorial is part of my recently published series: <a href="https://younisjad.medium.com/series-efficient-workflow-in-go-with-temporal-io-ab3248b1c5f9"><strong>(Series) Efficient Workflow in Go with Temporal.io</strong></a></p><h4>What is Workflow Signals in Temporal</h4><p>Temporal Signals, similar to webhooks, offer a mechanism for external entities to impact the behavior and advancement of a workflow. However, there is a notable difference in how they operate. While webhooks typically involve a direct modification or interruption of execution.</p><h4>What is Workflow Selectors in Temporal</h4><p>Workflow Selectors in Temporal are a feature that allows workflows to dynamically wait for different events or conditions to occur before proceeding further. They enable the workflow to make decisions based on available signals or events, providing flexibility and adaptability to the workflow execution.</p><h4>The Power of Workflow Selectors With Signals</h4><p>Workflow Selectors allow workflows to wait for specific Signals to occur, enabling them to synchronize different paths of execution based on the first event that happens. This flexibility grants workflows the ability to make informed decisions and take appropriate actions based on the available Signals.</p><p>With the use of Signals, workflows can receive updates, notifications, or requests from external systems or actors. These Signals can trigger wait conditions within the workflow, allowing it to patiently pause until a defined Signal is received. Once the appropriate Signal is received, the workflow can resume execution, processing the information or executing actions as desired.</p><h3>Example Workflow Overview</h3><p>In this section, we will discuss an example workflow that demonstrates the seamless integration between Temporal, a REST API, and a Data Layer. This scenario showcases how these technologies can work together to streamline processes and optimize communication between various components.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OAeHEUHogrAbwXsJbS-Hzg.png" /><figcaption>E -Commerce Order Temporal + Rest Client Workflow Example</figcaption></figure><p>The workflow begins with a client making a request to the server. The server, acting as a mediator, processes the request and responds back to the client. However, in the background, the server also initiates a workflow using Temporal.</p><p>The workflow involves multiple tasks, distributed among different services. These tasks include creating an order, generating a transaction, and creating shipping details. The server communicates with Temporal, which acts as a central hub for managing and coordinating these tasks.</p><p>At various stages of the workflow, the server sends signals to Temporal, indicating key events such as invoice confirmation and shipping confirmation. These signals trigger corresponding actions in Temporal, enabling the associated services to perform necessary actions and update their respective states.</p><p>For instance, when the invoice is confirmed, the service responsible for invoice management receives a signal from Temporal. This prompts the service to confirm the invoice and proceed to the next step. Similarly, when shipping is confirmed, the corresponding service performs the necessary actions and updates the workflow status in Temporal.</p><h3>Implementation Details</h3><p>Now, let’s dive into the implementation details of the example workflow. We’ll discuss the different code blocks for the Workflow, Activities, and the REST Client.</p><h4>Preparing Workflow</h4><p>Before diving into the implementation details of the workflow, it’s essential to make sure that everything is set up correctly. In this section, we will guide you through the necessary steps to prepare the workflow, ensuring a smooth and efficient execution of tasks in your Temporal-based application.</p><p><strong>Generic Activity Options</strong></p><pre>// @param ctx: workflow context<br>// @param productsString string a slice of product ids &quot;1,2,3,..etc&quot;<br>// @return temporal error<br>func CreateOrderWorkflow(ctx workflow.Context, productsString string) error {<br><br>  return nil<br>}</pre><p><strong>Workflow Configurations</strong></p><p>We configure the retry options to ensure that our workflow continuously retries each step of the transaction, shipping, and order process until the desired status change is achieved. By incorporating signals and selectors, we can interpret these status changes and determine when to advance to the next step. The retry mechanism allows for a resilient workflow that persists until the necessary conditions are met.</p><pre>func CreateOrderWorkflow(ctx workflow.Context, productsString string) error {<br> options := workflow.ActivityOptions{<br>  StartToCloseTimeout: time.Minute * 20,<br>  RetryPolicy: &amp;temporal.RetryPolicy{<br>   InitialInterval:    time.Minute,<br>   BackoffCoefficient: 2,<br>   MaximumAttempts:    7,<br>   MaximumInterval:    time.Hour,<br>   NonRetryableErrorTypes: []string{<br>    &quot;activity_error&quot;,<br>   },<br>  },<br> }<br><br> // start workflow with activity options<br> ctx = workflow.WithActivityOptions(ctx, options)<br><br> // configure logger<br> logger := workflow.GetLogger(ctx)<br> logger.Info(&quot;Starting CreateOrderWorkflow&quot;)<br><br> // start the activites<br><br> return nil<br>}</pre><p>Now Let’s enhance our workflow by incorporating activities that represent our business logic. Take a look at the sequence diagram to get a visual understanding of how these activities fit within the overall workflow. By aligning our business logic with the sequence of activities, we can effectively orchestrate and streamline the flow of our workflow.</p><pre>func CreateOrderWorkflow(ctx workflow.Context, productsString string) error {<br>  // ... workflow difnition<br><br>  // get running workflowId<br>  workflowId := workflow.GetInfo(ctx).WorkflowExecution.ID<br>  <br>  // Create Order<br>  orderId := &quot;&quot;<br>  workflow.ExecuteActivity(ctx, activity.CreateOrder, productsString, workflowId).Get(ctx, orderId)<br>  <br>  // Create Transaction<br>  workflow.ExecuteActivity(ctx, activity.CreateTransaction, orderId).Get(ctx, nil)<br>  <br>  // Create Shipping<br>  workflow.ExecuteActivity(ctx, activity.CreateShipping, orderId).Get(ctx, nil)<br>  <br>  // Confirm Transaction invoice<br>  workflow.ExecuteActivity(ctx, activity.ConfirmInvoice, orderId, confirmInvoiceResult).Get(ctx, nil)<br>  <br>  // Confirm Shipping fulfillment<br>  workflow.ExecuteActivity(ctx, activity.ConfirmShipping, orderId, confirmShippingResult).Get(ctx, nil)<br>  <br>  // Confirm Order<br>  workflow.ExecuteActivity(ctx, activity.ConfirmOrder, orderId).Get(ctx, nil)<br>  <br>  // ... workflow difnition<br>}</pre><p>If you observe closely, you will notice that we pass the workflowId as a parameter in our activities. We do this because we will leverage this workflowId in our Data layer to signal our workflow from the client at a later stage. This connectivity between the activities and the data layer allows us to effectively communicate and synchronize the workflow’s progress, ensuring seamless coordination and interaction between different components of our system.</p><h4>Synchronizing Activities with Signals using Selectors</h4><p>Currently our workflow will run and retry on failure, and most likely will get stuck at <strong>confirmInvoice </strong>that’s why we need to setup <strong>workflow selectors</strong> to receive data from our signals, to asynchronously run activities.</p><h4><strong>Signals &amp; Selectors</strong></h4><p>Let’s define the ConfirmInvoice selector and create a channel to receive signals. This will allow us to efficiently handle and process signals related to confirming invoices within our workflow.</p><p><strong>Confirm Invoice and Shipping Selector and Signal Channel Implementation:</strong></p><pre> // result can be string, struct, other data types.<br> var confirmInvoiceResult string<br> var confirmShippingResult string<br><br> // workflow selector<br> invoiceSelector := workflow.NewSelector(ctx)<br> shippingSelector := workflow.NewSelector(ctx)<br><br> // workflow named signal channel<br> invoiceSignalChan := workflow.GetSignalChannel(ctx, &quot;confirmInvoice&quot;)<br> shippingSignalChan := workflow.GetSignalChannel(ctx, &quot;confirmShipping&quot;)<br><br> // implement selector reciever via signal channel<br> invoiceSelector.AddReceive(invoiceSignalChan, func(c workflow.ReceiveChannel, more bool) {<br>  c.Receive(ctx, &amp;confirmInvoiceResult)<br> })<br><br> shippingSelector.AddReceive(shippingSignalChan, func(c workflow.ReceiveChannel, more bool) {<br>  c.Receive(ctx, &amp;confirmInvoiceResult)<br> })</pre><p>Finally, let’s enhance our workflow by incorporating signals and selectors. This update will allow us to effectively utilize signals for communication and synchronizing different steps within the workflow.</p><pre>// workflow/order.go<br>func CreateOrderWorkflow(ctx workflow.Context, productsString string) error {<br> options := workflow.ActivityOptions{<br>  StartToCloseTimeout: time.Minute * 20,<br>  RetryPolicy: &amp;temporal.RetryPolicy{<br>   InitialInterval:    time.Minute,<br>   BackoffCoefficient: 2,<br>   MaximumAttempts:    7,<br>   MaximumInterval:    time.Hour,<br>   NonRetryableErrorTypes: []string{<br>    &quot;activity_error&quot;,<br>   },<br>  },<br> }<br><br> // start workflow with activity options<br> ctx = workflow.WithActivityOptions(ctx, options)<br><br> // configure logger<br> logger := workflow.GetLogger(ctx)<br> logger.Info(&quot;Starting CreateOrderWorkflow&quot;)<br><br> // get running workflowId<br> workflowId := workflow.GetInfo(ctx).WorkflowExecution.ID<br><br> // result can be string, struct, other data types.<br> var confirmInvoiceResult string<br> var confirmShippingResult string<br><br> // workflow selector<br> invoiceSelector := workflow.NewSelector(ctx)<br> shippingSelector := workflow.NewSelector(ctx)<br><br> // workflow named signal channel<br> invoiceSignalChan := workflow.GetSignalChannel(ctx, &quot;confirmInvoice&quot;)<br> shippingSignalChan := workflow.GetSignalChannel(ctx, &quot;confirmShipping&quot;)<br><br> // implement selector reciever via signal channel<br> invoiceSelector.AddReceive(invoiceSignalChan, func(c workflow.ReceiveChannel, more bool) {<br>  c.Receive(ctx, &amp;confirmInvoiceResult)<br> })<br><br> shippingSelector.AddReceive(shippingSignalChan, func(c workflow.ReceiveChannel, more bool) {<br>  c.Receive(ctx, &amp;confirmInvoiceResult)<br> })<br><br> // start the activites<br><br> // Create Order<br> orderId := &quot;&quot;<br> workflow.ExecuteActivity(ctx, activity.CreateOrder, productsString, workflowId).Get(ctx, orderId)<br><br> // Create Transaction<br> workflow.ExecuteActivity(ctx, activity.CreateTransaction, orderId).Get(ctx, nil)<br><br> // Create Shipping<br> workflow.ExecuteActivity(ctx, activity.CreateShipping, orderId).Get(ctx, nil)<br><br> invoiceSelector.Select(ctx)<br><br> // Confirm Transaction invoice<br> workflow.ExecuteActivity(ctx, activity.ConfirmInvoice, orderId, confirmInvoiceResult).Get(ctx, nil)<br><br> shippingSelector.Select(ctx)<br><br> // Confirm Shipping fulfillment<br> workflow.ExecuteActivity(ctx, activity.ConfirmShipping, orderId, confirmShippingResult).Get(ctx, nil)<br><br> // Confirm Order<br> workflow.ExecuteActivity(ctx, activity.ConfirmOrder, orderId).Get(ctx, nil)<br><br> return nil<br>}</pre><p>In our final code implementation, we have incorporated the <strong>selector.Select(ctx)</strong> statement to initiate the workflow’s wait for a selector fulfillment signal. This particular statement pauses the workflow, awaiting the arrival of a signal. Once a signal is received, the code proceeds to execute the subsequent activities. This implementation guarantees that our workflow maintains responsiveness and dynamically progresses forward as soon as the required signal is detected.</p><h4>Preparing Rest Client</h4><p>Preparing REST ClientTo interact with external systems or services, enabling seamless communication between your Temporal-based application and the desired REST APIs. Get ready to harness the power of REST APIs in your Temporal workflows.</p><ul><li>Setup Temporal Worker</li><li>Register Workflows and Activities</li><li>Create http server and setup routes</li><li>Start Temporal Worker as a goroutine</li></ul><pre>// service/main.go<br><br>func Server() {<br> // set up the worker<br> c, err := client.Dial(client.Options{})<br> if err != nil {<br>  log.Fatalln(&quot;unable to create Temporal client&quot;, err)<br> }<br> defer c.Close()<br><br> w := worker.New(c, &quot;cart&quot;, worker.Options{})<br> w.RegisterWorkflow(workflow.CreateOrderWorkflow)<br> w.RegisterActivity(activity.CreateOrder)<br> w.RegisterActivity(activity.CreateTransaction)<br> w.RegisterActivity(activity.CreateShipping)<br> w.RegisterActivity(activity.ConfirmShipping)<br> w.RegisterActivity(activity.ConfirmInvoice)<br> w.RegisterActivity(activity.CreateInvoice)<br><br> mux := http.NewServeMux()<br> mux.HandleFunc(&quot;/cart&quot;, CartGetHandler)             // curl -X GET http://localhost:5000/cart<br> mux.HandleFunc(&quot;/cart/set&quot;, CartSetHandler)         // curl -X POST http://localhost:5000/cart/set\?products\=1,2,3<br> mux.HandleFunc(&quot;/order/create&quot;, OrderHandler)       // curl -X POST http://localhost:5000/order/create?cartId=1<br> mux.HandleFunc(&quot;/order/signal&quot;, SignalOrderHandler) // curl -X POST http://localhost:5000/order/signal?orderId=1&amp;signalName=confirmInvoice&amp;status=confirmed<br><br> server := &amp;http.Server{Addr: &quot;:5000&quot;, Handler: mux}<br><br> // start the worker and the web server<br> go func() {<br>  err = w.Run(worker.InterruptCh())<br>  if err != nil {<br>   log.Fatalln(&quot;unable to start Worker&quot;, err)<br>  }<br> }()<br><br> log.Fatal(server.ListenAndServe())<br>}</pre><h4><strong>REST API As a Client</strong></h4><p><strong>Create Order Handler</strong></p><p>By initiating the creation of an order, we kickstart the Temporal workflow. In other words, starting the order creation process will trigger the Temporal workflow to commence and orchestrate the subsequent steps and activities involved in fulfilling the order.</p><pre>func OrderHandler(w http.ResponseWriter, r *http.Request) {<br> productsString := r.URL.Query().Get(&quot;products&quot;)<br> // create a new temporal client<br> c, err := client.Dial(client.Options{})<br> if err != nil {<br>  log.Fatalln(&quot;unable to create Temporal client&quot;, err)<br> }<br> defer c.Close()<br><br> _, err = c.ExecuteWorkflow(r.Context(), client.StartWorkflowOptions{<br>  ID:        &quot;CreateOrderWorkflow_&quot; + uuid.New().String(),<br>  TaskQueue: &quot;order&quot;,<br> }, workflow.CreateOrderWorkflow, productsString)<br> if err != nil {<br>  http.Error(w, &quot;unable to start workflow&quot;, http.StatusInternalServerError)<br>  return<br> }<br><br> jsonResponse, err := json.Marshal(&quot;{status: &#39;ok&#39;}&quot;)<br> if err != nil {<br>  http.Error(w, &quot;unable to marshal response&quot;, http.StatusInternalServerError)<br>  return<br> }<br><br> w.Write(jsonResponse)<br>}</pre><p><strong>Signal Handler</strong></p><p>a webhook to signal our workflows using workflow and passed params “orderId, signalName, Status as signal data”</p><p>the using orderId we get the order details, and extract workflowId which then we will use to signal our workflow with result using the signal name</p><pre>func SignalOrderHandler(w http.ResponseWriter, r *http.Request) {<br> orderId := r.URL.Query().Get(&quot;orderId&quot;)<br> signalName := r.URL.Query().Get(&quot;signal&quot;)<br> orderStatus := r.URL.Query().Get(&quot;status&quot;)<br> // create a new temporal client<br> c, err := client.Dial(client.Options{})<br> if err != nil {<br>  log.Fatalln(&quot;unable to create Temporal client&quot;, err)<br> }<br> defer c.Close()<br><br> // get order from data layer<br> repo := &amp;repository.Order{}<br> order, err := repo.GetOrder(r.Context(), orderId)<br> if err != nil {<br>  http.Error(w, &quot;unable to get order&quot;, http.StatusInternalServerError)<br>  return<br> }<br><br> workflowId := order.WorkflowId<br> runId := &quot;&quot; // we did not store runId we can safely leave it empty<br> err = c.SignalWorkflow(r.Context(), workflowId, runId, signalName, orderStatus)<br> if err != nil {<br>  http.Error(w, &quot;unable to signal workflow&quot;, http.StatusInternalServerError)<br>  return<br> }<br><br> jsonResponse, err := json.Marshal(&quot;{status: &#39;ok&#39;}&quot;)<br> if err != nil {<br>  http.Error(w, &quot;unable to marshal response&quot;, http.StatusInternalServerError)<br>  return<br> }<br><br> w.Write(jsonResponse)<br>}</pre><h3>Conclusion</h3><p>In conclusion, the utilization of Temporal workflow signals with selectors offers a powerful mechanism to achieve synchronized and dynamic workflow execution. By leveraging these features, developers can design workflows that respond to real-time events, dynamically wait for specific signals, and make informed decisions based on the available information.</p><p>Furthermore, the integration of signals allows workflows to receive updates, notifications, or requests from external systems or actors. This empowers workflows to collaboratively interact with other components, incorporating external input to determine the flow and behavior of the execution.</p><h4>Thank you for reading our article</h4><p>on Temporal workflow signals with selectors! You can find the full code on our GitHub repository: <a href="https://github.com/unijad/temporal-select-signal-tutorial-code">https://github.com/unijad/temporal-select-signal-tutorial-code</a>.</p><p>If you enjoyed the article, consider following and subscribing to My mailing list for future updates. also appreciate your comments and feedback.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ddd4bbc285d4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/lyonas/series-efficient-workflows-in-go-with-temporal-signals-selectors-ddd4bbc285d4">(Series) Efficient Workflows in Go with Temporal: Signals &amp; Selectors</a> was originally published in <a href="https://medium.com/lyonas">akaSRC</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[(Series) Efficient Workflow in Go with Temporal.io]]></title>
            <link>https://medium.com/lyonas/series-efficient-workflow-in-go-with-temporal-io-ab3248b1c5f9?source=rss-57da83c15db4------2</link>
            <guid isPermaLink="false">https://medium.com/p/ab3248b1c5f9</guid>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[go]]></category>
            <category><![CDATA[golang-tutorial]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[temporal]]></category>
            <dc:creator><![CDATA[Younis Jad]]></dc:creator>
            <pubDate>Sat, 15 Jul 2023 11:59:20 GMT</pubDate>
            <atom:updated>2023-07-23T15:37:10.360Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YhVWMZfM0tMXyAH701Ts5w.png" /></figure><blockquote>To understand is to perceive patterns.</blockquote><blockquote><strong>Isaiah Berlin</strong></blockquote><p>In today’s fast-paced world, building scalable, efficient, and maintainable software is essential for businesses of any size. One challenge of creating modern software systems is managing the workflows and activities that make up the system. Workflow management can become complicated, especially when working on complicated distributed systems.</p><p>To address this challenge, Temporal.io provides a robust and easy-to-use platform for managing workflows and activities in distributed systems. This open-source platform offers a Workflow Engine and other developer tools to help you build workflows and manage activities more efficiently.</p><p>The series will cover topics such as setting up a Golang project with Temporal.io, structuring the code using different architectural patterns like Layered Architecture and Repository Pattern, creating workflows, and using activities to execute specific tasks. We will also explore the use of retry options and error handling, logging, and monitoring in Temporal.io, and best practices to optimize workflow management in distributed systems.</p><p>By the end of this tutorial series, you will have the skills and knowledge required to build, maintain and monitor fast, reliable, and efficient workflows and activities in Golang applications with Temporal.io.</p><h4>Efficient Workflow in Go with Temporal.io <strong>Series:</strong></h4><ul><li><a href="https://younisjad.medium.com/aws-step-functions-vs-temporal-cf51c892fe0f">AWS Step Functions vs Temporal: Comparison for Workflow Orchestration</a></li><li><strong>System Design:</strong> <a href="https://younisjad.medium.com/efficient-workflow-in-go-with-temporal-io-layered-architecture-66b1b70ff5a5">Layered Architecture</a></li><li><strong>System Design: </strong><a href="https://younisjad.medium.com/efficient-workflow-in-go-with-temporal-io-repository-pattern-d66e6ac78e39">Repository Pattern</a></li><li><strong>Tutorial: </strong><a href="https://medium.com/@younisjad/using-temporal-to-build-scalable-and-fault-tolerant-applications-in-golang-99ed2f47bf68">Using Temporal to Build Scalable and Fault-Tolerant Applications in Golang</a></li><li><strong>Tutorial: </strong><a href="https://younisjad.medium.com/series-efficient-workflows-in-go-with-temporal-signals-selectors-ddd4bbc285d4">Temporal Signals &amp; Selectors</a></li><li><strong><em>Tutorial: </em></strong><em>Temporal Queries (coming soon…)</em></li><li><strong><em>Tutorial:</em></strong><em> Temporal Schedules (coming soon…)</em></li><li><strong><em>Tutorial: </em></strong><em>Temporal Heartbeat (coming soon…)</em></li><li><strong><em>Tutorial: </em></strong><em>Temporal Versioning (coming soon…)</em></li><li><strong><em>Tutorial: </em></strong><em>Advanced Temporal Workflows with Namespaces (coming soon…)</em></li></ul><p><strong>Updated: July 23rd 2023</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ab3248b1c5f9" width="1" height="1" alt=""><hr><p><a href="https://medium.com/lyonas/series-efficient-workflow-in-go-with-temporal-io-ab3248b1c5f9">(Series) Efficient Workflow in Go with Temporal.io</a> was originally published in <a href="https://medium.com/lyonas">akaSRC</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS Step Functions vs Temporal]]></title>
            <link>https://medium.com/lyonas/aws-step-functions-vs-temporal-cf51c892fe0f?source=rss-57da83c15db4------2</link>
            <guid isPermaLink="false">https://medium.com/p/cf51c892fe0f</guid>
            <category><![CDATA[aws-step-functions]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[system-design-concepts]]></category>
            <category><![CDATA[temporal]]></category>
            <category><![CDATA[go]]></category>
            <dc:creator><![CDATA[Younis Jad]]></dc:creator>
            <pubDate>Thu, 13 Jul 2023 09:21:45 GMT</pubDate>
            <atom:updated>2023-07-13T09:21:45.954Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>AWS</strong> Step Functions vs Temporal: Comparison for Workflow Orchestration</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*RtDr9URuFJQX27wMOCyOZQ.png" /></figure><blockquote><strong>TLDR:</strong> AWS Step Functions and Temporal are two workflow orchestration solutions for building event-driven architectures. AWS Step Functions provides an easy-to-use platform for building state machines and integrations with AWS services, while Temporal provides more flexibility with support for multiple programming languages, granular resilience policies, and more scalable messaging. Temporal’s features, including flexibility and fine control over workflow executions, make it ideal for developers building event-driven systems using open-source solutions. AWS Step Functions is useful when building with AWS services and needing tight integration among these services.</blockquote><h3>What is AWS step functions?</h3><p>AWS Step Functions is a fully managed service that enables developers to build and manage workflows that run AWS services, custom applications, and third-party services. It provides a platform for building event-driven systems and workflow orchestration, with several key features that make it a popular solution for developers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_ugSS74OnGtFdE67AumDKw.png" /><figcaption>AWS step functions workflow example by <a href="https://aws.amazon.com/step-functions/">Amazon</a></figcaption></figure><h3>What is Temporal?</h3><p>Temporal is an open-source workflow orchestration and coordination platform, designed for mission-critical applications. It provides developers with a feature-rich platform for building workflows that span multiple services, systems, and teams. Temporal is robust, scalable, and fault-tolerant, making it the perfect solution for building event-driven systems.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*3OF9TG-I49idcNPX-LRNtw.png" /><figcaption>Example Temporal Workflow By <a href="http://younisjad.medium.com/">Younis Jad</a></figcaption></figure><h3>AWS Step Functions vs Temporal</h3><p>As a software engineer, it’s essential to consider the best possible workflow orchestration solutions for event-driven architectures. AWS Step Functions and Temporal are two such solutions, each with its own set of features and benefits.</p><p>With <strong>AWS Step Functions</strong>, you can easily build and manage workflows that run AWS services, as well as custom applications and third-party services. Its visual workflow design feature enables you to design state machines visually using the Step Functions studio. This allows you to intuitively create parallel workflows and conditional decision-making based on event data. AWS Step Functions’ built-in support for retrying failed states and catching failed executions provides better recovery options, making it a hassle-free solution.</p><p>However, <strong>Temporal</strong> provides a more flexible platform while being open-source, which allows you to create workflows using any language that supports gRPC or HTTP/JSON-based client and server APIs. Its granular resilience policies provide fine control over individual workflow executions, enhancing the overall resiliency of the system. You can easily communicate with a running workflow using <strong>signals via Temporal</strong>, which informs it of an update or action. Furthermore, You have full control over the execution of individual workflow activities, with the ability to specify timeouts, retries, versioning, and cancellation options.</p><p>Comparing the two, Temporal’s flexibility stands out, as it supports multiple clients and messaging protocols while AWS step functions is using Apache Kafka for distributed messaging and event handling. This provides high reliability, scalability, and ensures events are processed in order better than AWS Step Functions’ AWS Simple Notification Service (SNS) and Simple Queue Service (SQS).</p><h3>Conclusion</h3><p>As a software engineer, it is important to note that there are no sides when it comes to choosing between Temporal and AWS Step Functions. Both technologies have their own unique strengths and weaknesses, and the best choice depends on the specific use case.</p><p>For instance, if flexibility and feature richness are your priorities, Temporal is likely the way to go. Its support for multiple programming languages, granular resilience policies, workflow signals, and activity controls make it a highly customizable and adaptable option.</p><p>On the other hand, if you are building with AWS-specific services or integrating with AWS ecosystem, AWS Step Functions is still a solid choice. Its seamless integration with other AWS services and familiarity with the AWS environment could be powerful advantages in these scenarios.</p><p>Ultimately, the decision of which technology to use should always be considered on a case-by-case basis, taking into account the specific needs and priorities of the project at hand.</p><h4>Thank you!</h4><p>If you enjoyed this article and would like to receive more quality content, please consider <strong>following </strong>for future updates and insights on the latest technology and software development trends.</p><p>If you liked this content, check out this tutorial to get started using temporal with Go.</p><ul><li><a href="https://younisjad.medium.com/using-temporal-to-build-scalable-and-fault-tolerant-applications-in-golang-99ed2f47bf68">Using Temporal to Build Scalable and Fault-Tolerant Applications in Golang</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cf51c892fe0f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/lyonas/aws-step-functions-vs-temporal-cf51c892fe0f">AWS Step Functions vs Temporal</a> was originally published in <a href="https://medium.com/lyonas">akaSRC</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Vite vs SWC vs Webpack: A Performance Comparison for React Applications]]></title>
            <link>https://medium.com/lyonas/vite-vs-swc-vs-webpack-a-performance-comparison-for-react-applications-1384553c659d?source=rss-57da83c15db4------2</link>
            <guid isPermaLink="false">https://medium.com/p/1384553c659d</guid>
            <category><![CDATA[create-react-app]]></category>
            <category><![CDATA[benchmark]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[frontend]]></category>
            <category><![CDATA[vitejs]]></category>
            <dc:creator><![CDATA[Younis Jad]]></dc:creator>
            <pubDate>Tue, 11 Jul 2023 13:52:48 GMT</pubDate>
            <atom:updated>2023-07-11T14:00:06.255Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*VpcgcF4KS4hzHipEbDYrVw.png" /></figure><p>Are you looking to improve the performance of your React applications? In today’s fast-paced development world, it’s important to choose the right tools to help you build faster and more efficient applications. In this article, we’ll compare the performance of a Vite vs SWC vs Webpack.</p><h3>importance of performance in web applications</h3><p>I recognize the importance of performance in all stages of developing, building, and serving. Ensuring performance at each stage is critical to achieving a well-performing application.</p><p>During development, performance plays a crucial role in productivity. For instance, if the development environment is slow, it can demotivate developers, leading to lower productivity. A well-optimized development environment can encourage developers to write quality code, leading to better performance in the final product.</p><p>Similarly, building and serving a web application requires optimized performance. The build process should be as fast and efficient as possible to reduce downtime between development cycles and ensure that the latest changes are quickly integrated into the application. When serving the application, optimized performance ensures that users can interact with the app seamlessly and without delay, leading to a more positive user experience.</p><p>In summary, prioritizing performance during all stages of development, building, and serving of web applications is critical for achieving an excellent user experience and high productivity.</p><h3>tools and specs</h3><p>our example app should have significant implementation, so we will be using varies of components, ant design, react router.</p><p>all test are conducted using github <strong>codespaces</strong> instance, and used <a href="https://github.com/sharkdp/hyperfine"><strong>hyperfine</strong></a><strong> </strong>for CLI benchmarking.</p><h3>Performance Check</h3><h4>Vite</h4><ul><li>Build tool: babel.js</li><li>Run Time (<strong>mean</strong> ± σ): <strong>292.5 ms</strong> ± 13.7 ms</li><li>Build Time (<strong>mean</strong> ± σ): <strong>286.6 ms</strong> ± <strong>22.9</strong> ms</li><li>Time Range (min … max): <strong>267.4</strong> ms … <strong>496.2</strong> ms</li><li>Runs: <strong>100 runs</strong></li><li>Bundle Size: <strong>851.84</strong> kb ± 50 kb</li></ul><h4>Vite + SWC</h4><ul><li>Build tool: <strong>rust SWC</strong></li><li>Run Time (<strong>mean</strong> ± σ): <strong>269.4 ms</strong> ± 13.1 msÏ</li><li>Build Time (<strong>mean</strong> ± σ): <strong>287.1 ms</strong> ± <strong>15.1</strong> ms</li><li>Time Range (min … max): <strong>276.1</strong> ms … <strong>386.6</strong> ms</li><li>Runs: <strong>100 runs</strong></li><li>Bundle Size: <strong>851.84</strong> kb ± 50 kb</li></ul><h4>Create React App</h4><ul><li>Build tool: Webpack</li><li>Run Time (<strong>mean</strong> ± σ): <strong>289.8 ms</strong> ± 7.8 ms</li><li>Build Time (<strong>mean</strong> ± σ): <strong>283.5 ms</strong> ± <strong>12.1</strong> ms</li><li>Time Range (min … max): <strong>270.9</strong> ms … <strong>385.5</strong> ms</li><li>Runs: <strong>100 runs</strong></li><li>Bundle Size: <strong>266.19</strong> kB ± 10 kb</li></ul><h4>Conculsion</h4><p>Based on the performance check, it is evident that all three build tools Vite + SWC, Vite with Babel.js, and Create React App — are viable options for developing and building a React application. While Vite + SWC has the fastest run time, Vite with Babel.js has the fastest build time and Create React App resulted in the <strong>smallest bundle size</strong>. Although there is minimal difference in run time between the tools, the choice of the build tool may differ depending on the developer’s preference and specific project requirements. Therefore, developers should consider these factors while choosing the right build tool for their React app.</p><p>you can find <a href="https://github.com/unijad/react-benchmark">Source Code on Github</a> and instruction on Running benchmarks locally.</p><h3>Thank You for Reading!</h3><p><strong>Share your thoughts in the comments</strong> and stay tuned for more great content like this by giving us a follow. We can’t wait to hear what you have to say!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1384553c659d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/lyonas/vite-vs-swc-vs-webpack-a-performance-comparison-for-react-applications-1384553c659d">Vite vs SWC vs Webpack: A Performance Comparison for React Applications</a> was originally published in <a href="https://medium.com/lyonas">akaSRC</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Safe Go Type Conversions: Comprehensive Guide]]></title>
            <link>https://medium.com/lyonas/go-type-casting-starter-guide-a9c1811670c5?source=rss-57da83c15db4------2</link>
            <guid isPermaLink="false">https://medium.com/p/a9c1811670c5</guid>
            <category><![CDATA[golang-tutorial]]></category>
            <category><![CDATA[datastrucutre]]></category>
            <category><![CDATA[go]]></category>
            <category><![CDATA[programming-languages]]></category>
            <category><![CDATA[golang]]></category>
            <dc:creator><![CDATA[Younis Jad]]></dc:creator>
            <pubDate>Fri, 07 Jul 2023 10:30:01 GMT</pubDate>
            <atom:updated>2023-07-31T09:25:46.046Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W-s7zPkymjX9Y4b5zlhwAA.png" /><figcaption>Unsafe Conversion Example</figcaption></figure><p>This starter guide provides an overview of Go’s type system, with a focus on type conversion. It explores the basics of type assertion, conversion, and unsafe type conversion and provides best practices for using them effectively. Type Conversion</p><p>Type conversion in Go involves changing the type of a value to a different type. There are two ways of converting types in Go: Implicit conversion and Explicit conversion.</p><h4>Implicit Conversion</h4><p>Implicit conversionImplicit conversion occurs when Go converts the type of a value automatically. For instance, when we assign an integer value to a float variable, Go will automatically convert it to a float type. Here is an example of implicit conversion:</p><pre>package main<br><br>import &quot;fmt&quot;<br><br>func main() {<br> var a float32 = 5.6<br> var b float64 = float64(a)<br><br> fmt.Printf(&quot;a = %v, b = %v\n&quot;, a, b)<br>}</pre><p>this code will result an unexpected panic therefore it’s unwise to use implicit conversions, continue reading to learn more on how to do typecasting and assertions to safely write convertible types code.</p><h4>Explicit conversion</h4><p>Explicit conversion occurs when we use the conversion syntax to convert a value to a different type. The conversion syntax in Go is similar to other programming languages, as it requires enclosing the value in parentheses and specifying the type in front of them. Here is an example of explicit conversion:</p><pre>package main<br><br>import &quot;fmt&quot;<br><br>func main() {<br>  var a float64 = 5.6<br>  var b int = int(a)<br><br>  fmt.Printf(&quot;a = %v, b = %v\n&quot;, a, b)<br>}</pre><p>In the code above, the value of variable <strong>a</strong> is explicitly cast to an integer, and it is assigned to variable b. The int function is used to perform the type conversion, and the resulting value is truncated to an integer.</p><h4>Fundamental<strong> type </strong>conversion<strong> in Go</strong></h4><p>Type conversion is a fundamental concept that plays a significant role in Go programming. It provides a powerful tool for conversion values to different types, thus allowing us to operate on the same data in different ways.</p><p><strong>Converting an integer to a float:</strong></p><pre>var i int = 10<br>var f float64 = float64(i)</pre><p><strong>Converting a float to an integer:</strong></p><pre>var f float64 = 10.5<br>var i int = int(f)</pre><p><strong>Converting a string to a byte slice:</strong></p><pre>var s string = &quot;hello world&quot;<br>var b []byte = []byte(s)</pre><p><strong>Converting a byte slice to a string:</strong></p><pre>var b []byte = []byte{104, 101, 108, 108, 111}<br>var s string = string(b)</pre><p><strong>Converting an interface to a specific type:</strong></p><pre>var i interface{} = &quot;hello world&quot;<br>var s string = i.(string)</pre><p><strong>Converting a specific type to an interface:</strong></p><pre>var s string = &quot;hello world&quot;<br>var i interface{} = s</pre><h4>Safe Type Conversions using Type Assertions</h4><p>Type assertion is a technique used in Go to extract the underlying value of an interface value and test whether it matches a specific type. There are two types of type assertion in Go: assertion with a single value and assertion with multiple values.</p><pre>package main<br><br>import &quot;fmt&quot;<br><br>func f(i interface{}) {<br>    switch i.(type) {<br>    case int:<br>        fmt.Println(&quot;This is an integer&quot;)<br>    case string:<br>        fmt.Println(&quot;This is a string&quot;)<br>    default:<br>        fmt.Println(&quot;I don&#39;t know what this is&quot;)<br>    }<br>}<br><br>func main() {<br>    f(&quot;hello&quot;)<br>    f(42)<br>    f(false)<br>}</pre><p>In the above code, the f function takes an interface{} value and uses a switch statement to perform type assertion with multiple values. It tests the assertion of the value to either an int or a string type, and if the assertion is true, it prints a message. If the assertion fails, it moves to the default clause and prints a message indicating that it does not know what the value is.</p><p>here’s an example of using type assertion with implicit type conversion to capture panic and recover if any and provide a default value:</p><pre>package main<br><br>import (<br> &quot;fmt&quot;<br>)<br><br>func main() {<br> var i int16 = 10<br> var i64 int64<br> defer func() {<br>  if r := recover(); r != nil {<br>   fmt.Println(&quot;Recovered from panic:&quot;, r)<br>   i64 = 0<br>  }<br> }()<br> i64 = int64(i) // Implicit type conversion with type assertion<br> fmt.Println(&quot;i64:&quot;, i64)<br>}</pre><p>In the above code, we have an int16 variable i, and we want to convert it to an int64 variable i64. We use the type assertion syntax for an implicit type conversion since we know the conversion will be successful.</p><p>However, to demonstrate how to handle panics from incorrect type assertions, we add a defer statement that recovers from any panic that may occur during the execution of the program. Then, we use the int64 type with the variable i by using it within the type assertion, which auto-converts I <strong>safely</strong> into an int64 value.</p><p>If a panic occurs during the type assertion, the defer function is executed, where we print a message indicating that we recovered from the panic. We also set the value of i64 to a default value of 0 to avoid the program from crashing further.</p><p>Finally, we print the value of i64 whether it was set correctly or as a default value.</p><p><strong>Output:</strong> i64: 10</p><p>So given that the type assertion is successful, the output will print the converted value of i to i64.</p><h4>Unsafe Type Conversions</h4><p>In some instances, it may be necessary to perform type conversion that is not safe. Go provides a package called unsafe that contains functions that perform unsafe type conversion.</p><blockquote>The unsafe package provides a way for Go programmers to bypass the compile-time type checking and memory safety checks enforced by the language.</blockquote><p><strong>However, it is essential to use the unsafe package with caution as its use may lead to unexpected runtime behavior and memory corruption.</strong></p><p>example of unsafe type conversion:</p><pre>package main<br><br>import (<br> &quot;fmt&quot;<br> &quot;unsafe&quot;<br>)<br><br>func main() {<br> var i uint32 = 10<br> var ptr *uint32<br> ptr = (*uint32)(unsafe.Pointer(&amp;i))<br> *ptr = 20<br> fmt.Printf(&quot;i = %d\n&quot;, i)<br>}</pre><p>The use of unsafe type conversion is discouraged, and it should only be used when it is necessary, and when there are no other options available. It is important to understand the implications of using unsafe type conversion and to test it carefully to ensure the safety of the code.</p><p>Here’s an example of using type assertion with unsafe type conversion and defer from panic:</p><pre>package main<br><br>import (<br> &quot;fmt&quot;<br> &quot;unsafe&quot;<br>)<br><br>type MyStruct struct {<br> x int<br> y string<br>}<br><br>func main() {<br> myStruct := MyStruct{x: 1, y: &quot;hello&quot;}<br><br> var ptr = unsafe.Pointer(&amp;myStruct)<br> var ptrToInt = (*int)(ptr)<br> var i = *ptrToInt<br><br> fmt.Println(&quot;Value of i:&quot;, i)<br><br> defer func() {<br>  if r := recover(); r != nil {<br>   fmt.Println(&quot;Recovered from panic:&quot;, r)<br>  }<br> }()<br><br> var myString = myStruct.y<br> var ptrToString = (*string)(unsafe.Pointer(&amp;myString))<br> var myIntString = *ptrToString<br> fmt.Println(&quot;My string:&quot;, myIntString)<br>}</pre><p>In this example, we first create a basic struct MyStruct with an integer value x and a string value y. We then create a pointer called ptr and point it to our MyStruct.</p><p>After that, we create another pointer ptrToInt of int type and set it equal to ptr. We then dereference ptrToInt and save it to a variable i.</p><p>We then print the value of i, which should be the value of MyStruct.x.</p><p><strong>Note: we use a defer function to handle any panics that occur during runtime.</strong></p><p>We then declare a string variable myString and set it to MyStruct.y. We create another pointer called ptrToString, which is of string type and set it to the address of myString.</p><p>We then dereference ptrToString and save it to myIntString, which we then print to the console.</p><p><strong>Note that in this example, we used unsafe pointers and type </strong>conversion<strong>. We should use them with caution, as they can lead to unexpected and incorrect behavior if not used correctly.</strong></p><h4>Type conversion and Conversion Best Practices</h4><p>Here are a few best practices that can be followed when working with type conversion and assertion in Go:</p><p>Always check and handle errors when performing type assertion with multiple values. Here’s an example:</p><pre>package main<br><br>import (<br>    &quot;fmt&quot;<br>)<br><br>func main() {<br>    var x interface{} = 42<br>    if n, ok := x.(int); ok {<br>        fmt.Printf(&quot;x holds an int value of %d\n&quot;, n)<br>    } else if s, ok := x.(string); ok {<br>        fmt.Printf(&quot;x holds a string value of %s\n&quot;, s)<br>    } else {<br>        panic(&quot;x does not hold an int or string value&quot;)<br>    }<br>}</pre><p>Avoid using unsafe type conversion and assertion as much as possible. Instead, use safe alternatives wherever available. Here’s an example:</p><pre>package main<br><br>import (<br> &quot;fmt&quot;<br> &quot;strconv&quot;<br>)<br><br>func main() {<br> i := 10<br> s := strconv.Itoa(i)<br> fmt.Printf(&quot;The type of s is %T\n&quot;, s)<br>}</pre><p>Use custom types to provide safety and clarity. Custom types can provide more safety and clarity in the code, and they can also reduce the number of type assertions required. Here’s an example:</p><pre>package main<br><br>import (<br> &quot;fmt&quot;<br>)<br><br>type MyInt int<br><br>func (mi MyInt) IsPositive() bool {<br> return mi &gt; 0<br>}<br><br>// usage<br>func main() {<br> var x MyInt = 42<br> if x.IsPositive() {<br>  fmt.Println(&quot;The value of x is positive.&quot;)<br> }<br>}</pre><p>Keep type conversion and assertion logic separate from the main logic of the program. This makes it easier to test and modify the code when necessary. Here’s an example:</p><pre>package main<br><br>import (<br> &quot;fmt&quot;<br> &quot;log&quot;<br> &quot;net/http&quot;<br> &quot;strconv&quot;<br>)<br><br>func getIntValue(x interface{}) (int, error) {<br> if n, ok := x.(int); ok {<br>  return n, nil<br> } else if s, ok := x.(string); ok {<br>  i, err := strconv.Atoi(s)<br>  if err != nil {<br>   return 0, err<br>  }<br>  return i, nil<br> } else {<br>  return 0, fmt.Errorf(&quot;invalid type %T&quot;, x)<br> }<br>}<br><br>func main() {<br> resp, err := http.Get(&quot;http://example.com&quot;)<br> if err != nil {<br>  log.Fatal(err)<br> }<br><br> contentLength, err := getIntValue(resp.Header.Get(&quot;Content-Length&quot;))<br> if err != nil {<br>  log.Fatal(err)<br> }<br><br> fmt.Printf(&quot;Content-Length: %d\n&quot;, contentLength)<br>}</pre><p>By keeping the type assertion logic separate from the main logic, we can easily test and modify this function when necessary.</p><p>These best practices aim to ensure that the code is safe, readable, and maintainable. Always remember to consider these practices in order to write high-quality and robust Go code.</p><p>In the Next Article we will Discuss <strong>Type conversion with Struct and Interface Types for JSON</strong></p><h3>Thank You for Reading!</h3><p>Leave a Comment and Follow for More Content Like This.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a9c1811670c5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/lyonas/go-type-casting-starter-guide-a9c1811670c5">Safe Go Type Conversions: Comprehensive Guide</a> was originally published in <a href="https://medium.com/lyonas">akaSRC</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>