<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ahmed Farfour</title>
    <description>The latest articles on DEV Community by Ahmed Farfour (@ahmed_farfour_973098ed855).</description>
    <link>https://dev.to/ahmed_farfour_973098ed855</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3682600%2Ffb91392e-b746-4693-b160-9618cf21398b.jpg</url>
      <title>DEV Community: Ahmed Farfour</title>
      <link>https://dev.to/ahmed_farfour_973098ed855</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ahmed_farfour_973098ed855"/>
    <language>en</language>
    <item>
      <title>From Logic to Code: Building a Text Formatting Tool in Go.</title>
      <dc:creator>Ahmed Farfour</dc:creator>
      <pubDate>Sun, 28 Dec 2025 12:22:53 +0000</pubDate>
      <link>https://dev.to/ahmed_farfour_973098ed855/from-logic-to-code-building-a-text-formatting-tool-in-go-i0a</link>
      <guid>https://dev.to/ahmed_farfour_973098ed855/from-logic-to-code-building-a-text-formatting-tool-in-go-i0a</guid>
      <description>&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt; I’ve officially completed my first significant project in Go! As I transition into software engineering, I’m realizing that coding is very similar to designing a building: you need a solid foundation (logic) and attention to detail (syntax).&lt;/p&gt;

&lt;p&gt;This project is a Text Completion tool. The goal was to build a program that reads a text file containing raw data and specific "formatting commands" (like (hex), (up), or (cap)), processes them, and outputs a clean, grammatically correct sentence.&lt;/p&gt;

&lt;p&gt;Here is what I built and what I learned along the way.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Challenge&lt;/strong&gt; The program needed to take an input file like this: "1E (hex) files were found in the folder (up)"&lt;/p&gt;

&lt;p&gt;And turn it into this: "30 FILES were found in the folder"&lt;/p&gt;

&lt;p&gt;It had to handle:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Conversions: Hexadecimal and Binary to Decimal.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Transformations: Uppercase, Lowercase, and Capitalization.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Grammar: Fixing punctuation spacing and correcting "a" to "an" before vowels.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;How I Structured the Logic The core of the program is the applyCommands function. It iterates through the words (slices of strings) and looks for specific tags.&lt;/p&gt;

&lt;p&gt;One of the most interesting challenges was handling the index manipulation. When a command like (hex) is found, it affects the previous word. I had to convert that word, and then remove the command itself from the slice so it doesn't appear in the final text.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjeqxr9r30wsjvvnh73pp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjeqxr9r30wsjvvnh73pp.png" alt=" " width="800" height="359"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Power of Regular Expressions (Regexp)&lt;/strong&gt; Once the words were processed, I had to fix the punctuation. I learned that doing this manually with if/else statements is messy. This was my introduction to the regexp package.&lt;/p&gt;

&lt;p&gt;I created a function called fixPuncAndVowels. It uses patterns to ensure punctuation sticks to the previous word but has a space after it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw4ra0uctl7gqzfxw04n8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw4ra0uctl7gqzfxw04n8.png" alt=" " width="800" height="280"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This single line of code replaced almost 20 lines of complex loop logic I had written initially!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What I Learned&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Slice Manipulation: I learned that when you remove an item from a slice in Go, you have to be very careful with your index (i--) so you don't skip the next word.&lt;/p&gt;

&lt;p&gt;Type Conversion: Moving between strings, integers, and back to strings using strconv.&lt;/p&gt;

&lt;p&gt;Modular Code: Breaking the code into small functions like hexToDec and capitalize made debugging much easier.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt; This project taught me that coding isn't just about syntax; it's about breaking a large problem into small, solvable logical steps. I’m excited to keep building and exploring more complex architectures in Go.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>go</category>
      <category>beginners</category>
      <category>career</category>
    </item>
  </channel>
</rss>
