Craft intuitive
In developing a web, a code base or a plan of programer sometimes is not accepted because it requires much brain processing power or simply not intuitive. To help programmers more understanding about Craft intuitive. Today, JT1 will share with you some methods to process handle code better and clearer.
As a developer, you can spend more time reading the code than actually writing it. In addition to your regular outputs and refactor, think about the amount of time you spend reading instructions, documentation, reviewing pull requests, checking for the latest repos on Github, only maintain a project. However, it is difficult to convert from the knowledge you read can be easily used in writing. If you are a seasoned programmer, you need to know about Craft intuitive as a useful method.
How to use methods:
Using map and filter in order to extract and convert the result to a new set, keeping the original unchanged or in more technical terms helps prevent from mutating the original project.
Creating a set of specialized units - the reading function, which makes us easy to read and understand at first glance but will also have the side effect of generating reusable code.
Steps to Craft intuitive
- Filter step:
Firstly, we will create a helper function for example propEquals, which will only worry about whether an attribute on an x object is equal to the value y. It also generic enough to look up any key pair or value pair against any object. Besides, using out functions of prequels, we also can fix the argument values to default in a specific country which is named as a country. We can also say that USCountry comes from propEquals and sets the parent's default values to the country is the key, and choose the lowercase or uppercase value of the string.
- Convert step:
First, extract the phone formatting function to separate it from the fact that it is always attached to an object. We can format a number whether it is part of an object or not. To this perform, we use the USPhoneFormat function. Continually, we add our final help transform. Basically, it will takes a key and a transformation function and applies a value transformation on a certain object, after we can recompile a more specific function that handles only number format.
Although it has more steps to perform this, however, it also has some benefit including:
Self-documenting
Composable: provide for your ideas
Readable
Eloquent
Abstraction layer: add it anywhere it makes sense
Maintainable: small units which easy to check.
Scalable: Separate and generic functions that are easy to reuse.
Finally, JT1 want to introduce some methods to improve readability and reducing complexity:
Format: Too much energy is wasted on formatting. So, apply a standard format, apply it to the code base, and automate it. Then you can refocus that energy into actually coding.
Nested code: Unravel nested code using guard statements, early returns, or functional programming aspects.
In fact, if you want to become an excellent programmer, understanding this basic knowledge will help you quickly advance in your career.
[Collective Sources]
---
JT1 - IT Recruitment Agency
Email: hi@jt1.vn
Phone: +8428 6675 6685
Website: http://www.jt1.asia
Blog: http://www.jt1.asia/blog
Facebook: https://www.facebook.com/jt1asia