Shared time with a programmer

One day, one of my friends found himself in a situation where he couldn’t achieve the kind of user interface he wanted. I invited him to our office and within two days, we were able to reach somewhere.
I realized the cause of his suffering arose from how he was writing code and not knowing the procedure of how something should be approached. For example, he couldn’t really explain to me what he wanted to happen when a certain element is being hovered.
Basically, it was hard to read and understand his code because of the way he indented his code and named his variables.
When I helped him, I shared some of the code on github.com which I will share in this post, hopefully, one can pick an idea or two or even contribute towards improving it. This code is written in HTML, JavaScript, and PHP. A snippet which is meant to handle submission of multiple form fields which should pick an array of data. By saying the array of data, I mean picking numerous variants of the same object.
In his scenario, he wants to pick the available work periods of a contractor and send to a PHP script for processing and storage. During the data entry of a contractor, they have to specify the time duration of a particular day that the contract will be available to offer a service throughout the entire contract period i.e. Monday 08:00 to 17:00, Tuesday 09:00 to 17:00 etc. Therefore it’s necessary for the web application to enable an administrator and registering contract to select a collection of work periods at once without navigating away from the entry form.
Click here to take a look at the code.
Besides the code we wrote together, how did I help him improve his coding lifestyle?

  • He got an idea of how to name variables so that even without writing comments the code can be understood by other programmers without any struggle.
  • I admit my code doesn’t come near to the cleanest written code that I hope it will be in a couple months but he was inspired by how I indent and it looks so clean, perhaps he is now practicing the same or even better.
  • I taught him about writing optimized code, especially when using loops.
  • I also introduced him to the idea of a ternary operator as control statement, this was really amazing to him because it would help cut almost a quota of his code.
  • JavaScript is one of his weakest points according to my observation and encouraged him to take a good study of the language including the new concepts of ES6.
  • I encouraged him to watch and follow NetNinjas and Traversy Media channels and others on YouTube to help him develop as fast as possible.

 
 
 

David

View Comments

  • This is the very first time I read a word "optimized code"
    Am here still wondering how that looks like.
    And besides, I love the humility in you. Other Devs would charge a per hour rate for this.
    Kudos David.

    • First of all thanks for reading.
      Yes the term optimized code means the code that will execute first. Uses little memory(RAM), Processor and takes little storage space. Writing this kind of code comes with experience and being around people who have done it already.
      hahahaha if I start charging will I loose humility? :D

Recent Posts

You deserve to be there at the top.

I'm glad to present about "deserving to be there at the top" at the first…

1 year ago

When not to use a forEach loop in JavaScript

A forEach loop is one of the most optimized JavaScript Higher-Order functions that make it…

5 years ago

You are not about to die poor.

In recent years, the biggest number of people I have met are characterized by the…

5 years ago

Thoughts on 13-06-2019

I promised to share my thoughts in any possible way. In fact, am happy to…

5 years ago

A beautiful thought for 29-05-2019

Hey beloved, Once in a while, I develop thoughts in my head, and instead of…

5 years ago

How to Design your career for ultimate happiness and fulfillment – Part 1.

I remember in primary school, I had different interests compared to the ones I have…

5 years ago