<?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 Mohammed CHALOULI,  PhD on Medium]]></title>
        <description><![CDATA[Stories by Mohammed CHALOULI,  PhD on Medium]]></description>
        <link>https://medium.com/@medchalouli?source=rss-2926ead3d950------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*KyQg63V0_hWtGi56xLEryA.jpeg</url>
            <title>Stories by Mohammed CHALOULI,  PhD on Medium</title>
            <link>https://medium.com/@medchalouli?source=rss-2926ead3d950------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 19:43:40 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@medchalouli/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[Think Different — Code the same]]></title>
            <link>https://medium.com/@medchalouli/think-different-code-the-same-d6608b2b2523?source=rss-2926ead3d950------2</link>
            <guid isPermaLink="false">https://medium.com/p/d6608b2b2523</guid>
            <category><![CDATA[clean-code]]></category>
            <category><![CDATA[better-programming]]></category>
            <category><![CDATA[team-collaboration]]></category>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[coding-style]]></category>
            <dc:creator><![CDATA[Mohammed CHALOULI,  PhD]]></dc:creator>
            <pubDate>Sat, 18 Apr 2020 22:01:56 GMT</pubDate>
            <atom:updated>2020-04-19T20:00:20.777Z</atom:updated>
            <content:encoded><![CDATA[<h3>Think Different — Code the same</h3><h4>Clean code recommendation for teams</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9be1lWXHbLcbu6kb" /><figcaption>Photo by <a href="https://unsplash.com/@grohsfabian?utm_source=medium&amp;utm_medium=referral">Fabian Grohs</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><strong>Why Clean code is that important!</strong></p><p>During my experience in development, I worked with many teams and I found out that almost every developer (mostly juniors) has his own way to code. This reminds me while I was working alone, I liked the freedom of writing without any conditions as well as structuring my code according to my own preferences. That time, as long as I was able to read and to maintain my code, design patterns or software concepts didn’t mean much to me because I was the only one who writes the full solution from the D of design to the D of database. Later in my career, I couldn’t still be that lonely wolf because the evolution of the web development in this late decade where in one hand, I wasn’t able to catch all the new techs while delivery a good quality project in a relatively short time. And from the other hand, as the proverb once said: “If you want to go fast, go alone. If you want to go far, go together.”. So, I started learning about the design patterns [<a href="https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller">MVC</a>, <a href="https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93presenter">MVP</a>, <a href="https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93viewmodel">MVVM</a>… etc.], about the software architecture [<a href="https://en.wikipedia.org/wiki/Front_end_and_back_end">Front-end, Back-end</a>], Paradigms [<a href="https://en.wikipedia.org/wiki/Agile_software_development">Agile</a>, <a href="https://en.wikipedia.org/wiki/Waterfall_model">Waterfall</a>, <a href="https://en.wikipedia.org/wiki/Software_prototyping">Prototyping</a>… etc.] and software practices [<a href="https://en.wikipedia.org/wiki/Test-driven_development">TDD</a>, <a href="http://specification_by_example/">SBE</a>, <a href="https://en.wikipedia.org/wiki/Continuous_delivery">CD</a>… etc.]. As you see, there are plenty of different choices based on the project and the environment, but the only thing in common is the coding 😊. Whatever your choices, you’ve to code and you have also to deliver a code that is coherent for your team and for the code reviewers as well <em>(if you don’t want to stick with every project for lifetime 😉)</em>.</p><h4><strong>How to avoid a messy code!</strong></h4><p>This section will provide recommendations independently of the language chosen for coding.</p><p><strong>Variable names</strong></p><p>Variable names like the following are hard to be understood for other teammates and for you after a while 😉.</p><pre>var var1, _insideFUNCTIONResults;</pre><pre>var Integer_parameters_function_1;</pre><pre>var a2, obj3, b1;</pre><p>To avoid meaningless names, three points to be considered:</p><p><strong>1. Functional names:<br></strong>The name of the variable should reflect the reason this variable is created using few words like : (using camelCase style in examples):</p><pre>var clientAddress;</pre><pre>var totalPurchasedItems;</pre><p>Important to avoid also the magic numbers,</p><pre>var healthState = 1;<br>//Healthy = 1 ||  2: Sick ||  3: Dead</pre><p>And use Enum instead,</p><pre>const healthCondition = {&quot;healthy&quot;:1, &quot;sick&quot;:2, &quot;dead&quot;:3};</pre><pre>var healthState = healthCondition.healthy;</pre><p><strong>2. Unique case Style:<br></strong>Adopt one case style for your variable. Where, the most commonly used styles are (Example: Total Purchased Items)</p><pre><strong>//</strong><a href="https://en.wikipedia.org/wiki/Snake_case"><strong>snake_case</strong></a><strong>:</strong><br>var total_purchased_items;</pre><pre><strong>//</strong><a href="https://en.wikipedia.org/wiki/Camel_case"><strong>camelCase</strong></a><strong>:<br></strong>var totalPurchasedItems;</pre><pre>//<strong>PascalCase:<br></strong>var TotalPurchasedItems;</pre><p><strong>3. Public/Private scoop:<br></strong>Variables to be used only inside functions or classes (private) should have a different style of the public ones like adding underscore “_” at the beginning of each private variable.</p><pre>var _dateBirth, _userModel;</pre><p><strong>Functions</strong></p><p>Variable names like the following are hard to be understood for another team</p><p>1. <strong>Descriptive name and role:</strong></p><p>The name of the function should be meaningful and reflects the one role the function was created for.</p><p>Please avoid complex names as well as multiple roles by one function, for readability and maintenance purposes.</p><p>A different case style than the one used in variable names is also recommended (e.g. Using PascalCase for functions while camelCase is used for variables).</p><p>2. <strong>Parameters:</strong></p><p>If your parameter list is above 3 (polyadic), it will be better to use class/structure unless it’s really necessary.</p><p>Taking an example of a function returning four user information.</p><p>a. Create the user information class</p><pre>class userInfo {</pre><pre>constructor(_id,_name,_birthdate,_address) {</pre><pre>this.userId = _id;</pre><pre>this.userName = _name;</pre><pre>this.userBirthdate = _birthdate;</pre><pre>this.userAddress = _address;</pre><pre>this.userJob = &quot;Developer&quot;;</pre><pre>}}</pre><p>b. Fill the information and create the display function</p><pre>var userInformation = new userInfo(&quot;47&quot;,&quot;Mohammed&quot;,&quot;1988&quot;,&quot;Algeria&quot;);</pre><pre>// Displaying the user information in the console.<br>function DisplayUserInfo (_userDetail) {</pre><pre>console.log(&quot;The user &quot;+_userDetail.userName+&quot; with id: &quot;+_userDetail.userId+&quot; born in &quot;+_userDetail.userBirthdate+&quot; is living in &quot;+ _userDetail.userAddress);</pre><pre>}</pre><p>c. Call the display function</p><pre>DisplayUserInfo(userInformation);</pre><p>Applying this recommendation will avoid changing all the calls in case of modification in the client information.<br><em>N.B: if the function is related only to the information about the class, it will be better to be included in the class.</em></p><p>3. <strong>Tidy code:</strong></p><p>Important to add “TODO” for unfinished functions in order to let your team know that you’re still working on or just to let them know what’s left to be done. Example of adding this comment line to the previous function</p><pre>// TODO: Display these information in the User profile page.</pre><pre>function DisplayUserInfo (_userDetail) {<br>console.log(&quot;The user &quot;+_userDetail.userName+&quot; with id: &quot;+_userDetail.userId+&quot; born in &quot;+_userDetail.userBirthdate+&quot; is living in &quot;+ _userDetail.userAddress);</pre><pre>}</pre><h4>Best practices to clean your code!</h4><p>Along with applying the recommendation mentioned in the previous section, and in order to get a Clean Code, more recommendation has to be applied. Not in the code this time, but on the way of coding:</p><p><strong>Reliable comments</strong></p><p>It is preferred to have a block comment on each function or class defining the purpose or any related configuration. Remember, if you’re commenting variables, that means you didn’t write them well.</p><p><strong>Avoid Duplication</strong></p><p>Repetitive functions (e.g. Input sanitizing) should all be writing once in order to facilitate improvement or maintenance. Moreover, during a project, the modification/Adding of one field can bring multiple changes in various places. The use of <a href="https://en.wikipedia.org/wiki/Don%27t_repeat_yourself">DRY </a>(Don’t repeat yourself) principle will avoid you wasting your time by focusing only on the important changes.</p><p><strong>Tests are important</strong></p><p>Testing is extremely useful to keep a quality product and preserve reputation. Manual testers may omit/forget some use cases, while automated testing provides better control and more validation.</p><p><strong>Productivity tools</strong></p><p>Even a senior developer will get lost in code with multiple brackets and not well-organized indentation. Therefore, there are a plenty of tools and extensions to make your life easier and your code more coherent.</p><p>In the short term, you’re not a machine, Use tools!😉</p><h4>Finally!</h4><p>Remember that the code quality reflects the developer. So always remember, have a clean code not only for you but for your readers.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d6608b2b2523" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>