提升軟體開發品質! 寫程式的 6 招實用技巧 | 在地上滾的工程師 Nic

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
Hi Hello everyone I am today Nic this movie it wants to share with you what I now become a software engineer working in the industry about five years experience in combat almost the most practical 6 can write programs to improve the quality of tips First of all, we have to say write programs to enhance the quality of what can bring direct benefits primarily can effectively improve the efficiency of collaboration increases the likelihood of the program being tested and the establishment of certain professional degree for your own case but to maintain good code quality is a must have to pay little cost and price, but that is a lot of time especially when we chased unlimited demand to catch up with the oppressed and we have to press the part with a minimum of time to complete the highest quality that you think possible? Generally speaking, it is more difficult to get a bit of quality time code to be replaced with the fastest speed the development of on-line this is usually the most bosses want it at the beginning could reap the benefits of the program seems to feel the opposite is written soon also the on-line quickly seems to have no problem incorrect and technology began to accumulate debt will come back when there is demand for a more pronounced effect of drag care about the quality of teamwork it is usually put in the code as a certain self-imposed demand I think this is one of the standard of a good engineer should have a share in the next six practical tips basically the concept of it can be common to any programming language or have read the design pattern will be made real should find some mutual situation if there is interest in such content, then please remember to help me open a small bell subscribe to press easily give me praise like this you do not miss the next I want to share with you anything Hello the first point to avoid abbreviations use a meaningful name a lot of people, will set the parameters for the short program in which, say, you might want to write email address but that someone would put it into that other e engineer you want to know your code only you will not see a person usually code will leave a lot of people watching, after all, is a code will be repeatedly read than to write an email address like there is some engineers might think to write or write e ea for that other engineers first saw in terms of when it will feel to say, Hey! What is e? What is ea? Who is ea? ea What does it mean? and then he will have to guess the context may look through to see the text before and after echoed know Oh, the original email address you play more words, it will How is it? Will the keyboard break if you type a few more characters? Now many editors have an auto-complete as possible, please use the little short for your short and others imagine shorthand like password may not be the same as you might write pwd if we have a consensus sounds okay but if everyone named shorthand conventions are not the same password that he might want pd how to do that? Who can understand this program to play more that those words will not spend too much of your time, but because you spend less to play behind the words a lot of time reading the code so it will make possible the use of meaningful before naming I could open a library module above the library is to write Hello Kitty how I know that Hello Kitty is what is the use of Email Service to do to please you write Email Service Notification Service will ask you to write Notification Service otherwise no one knows Hello Kitty this Service will do something meaningful name is important to keep in mind that the number of parameters in your mind the second limit incoming general, we usually write a function later there will be some argument to pass in that some people may be because the function began to expand as demand increases the content of parameters passed into general, we'll write a function at the time of implementation logic that this function may be a lot of argument to be passed in through the external parameters to depend say the real function inside to what kind of content is not the same as there are changes made so that the result is not the same, this function may be the beginning of a parameter to be passed but the growth over time with the expansion of demand you will probably find a parameter is not enough had to pass the second parameter and the third pass, but if you do not properly maintain the definition of the function logic in the end do what is likely to become the function passed too many parameters in general I will Suggest a function recommend 3 3 parameter is the limit if you are more than three arguments then this function will become very difficult to test because it's changed because of the combination becomes very much complexity is directly promoted to burst table again you will find that if it is not directly see this function it is directly visible from other places call this function, say later create user create user pass a bunch of stuff OOXX what name, address, password ip address, referral source all passed in the beginning he would feel that Hey! Why Nic first to put a password on why the second order have bad? He had to dig to the root of the function I realized that this is the email mean oh oh it was a user name meaning So, if more than three arguments must be passed Maybe you can use the hash or object of way wrap it into a thing and then pass directly into this way, we see that part of the code will find the time, Oh! To call this function before the original must first make this object then this object inside the key will be what it usually say something like that to create user terms you can just think of the above into a bag for example: parameter then things such a transfer into other engineers to make the time to read this code will know, oh! So this is the first parameter over like this to prepare these first filter out these parameters and then put it into a object and then sends it into the third spot To simplify the predicate condition we can now assume that what Taiwan this motorcycle made a real predicate logic, a function so you can see Oh we can put a Taiwanese motorcycle ride this logic is encapsulated in a function which it might be like this can person ride motorbike? then we pass into the person that person must do his age his age must be greater than equal to eighteen and this person must have his driver's license is the person he might have an argument or has rider licence a function is executed so you can you can see when we qualified under that return true else return false situation we go back so it looks like no problem is also OK can break it into like this logic is encapsulated in here is already very perfect but then, in fact, to avoid excess needs to be read part of it, as long as we know what the conditions are like riding a motorcycle can be a fact, so we can put these if else are removed directly from the judge made a return type, spread out your back direct return person age> = 18 and person has rider license so it seems, this function is not to become a relatively simple you know I can not ride a motorcycle is to satisfy these two conditions in which the program just these two conditions it to return a boolean value greater than or equal thing because after all, you also return a boolean function and then return you to set design is boolean boolean and then the two together he would see that this condition is what return you will not have to write their own ture or false but it becomes a bit redundant to make it in time to see people reading it will be relatively lengthy comparison point so this trick it is quite recommend to everyone coming fourth definition of variables restrictions this section may be more used to write a little bit old javascript when only var var that it can be global can be read to say, you define a variable that you can go to the B function of the a function call also call to the C function can change it if you are not careful in naming a D function may be exactly the same Resulting in some very difficult to clean up the disaster it was because of this relationship will be in the global design variables when all the variables on the top that allow the program has been going down, however, when you start to grow up the code you'll find that a page could Oh you finish dragging, the variables defined at the top but at the bottom when your function is useful to think about it and then sometimes you have forgotten defined above is what has turned back the process of jumping back and forth back and forth in the fact let your reading becomes very difficult to engineer because it becomes difficult to debug like this caused you might first go to where the parameters are defined and then defines what? finally see a return function implement logic Nevertheless, the mainstream writing style is basically to adhere to the variables in a certain role which was out of scope like javascript let, const variables to avoid like the previous var everywhere as much as possible we want to mess with a variable scope restrictions in a function which only allows this function can be read only make this function can be changed so that this function would be lost after the end finished this will avoid some of the variables of global pollution problem is why the program begins later writing style has been slowly advocate say less use of global variables as much as possible not to cause contamination do not know where the variables are defined not know what period of time the program ran to modify it very difficult to debug the cause of this effect also makes time to write your tests become very difficult, however, because the programming language would not like this to put global variables this function to unplug after all, he has some very period when the environment is still very likely to be used only chance is relatively small so the current mainstream of development now let the variables used to a certain scope which do not run out to throw it to interfere with other people a fifth program only thing we implement a logic encapsulated into a function of time must be named and defined manner consistent behavior Do not secretly entrainment of the other features this will cause other engineers or above in reading comprehension or above are not careful you call this function caused him unimaginable effect Let's say we have a function that calculates the total price of the order you might name this function is called calculate total amount then orders such as this function you pass in order to calculate the total price you calculate the total price like why you want to secretly send email in function inside? your function name above does not say you have to send a letter only way you say you want to calculate as long as you calc ulate the total amount of this order would only like this where there is said to be the way to send email is not it? Isn't it? This way you will make other engineers call this function at the time if he does not look at the definition of the function he believes only in order to calculate a total Unexpectedly, why the quota system has recently been baffling letter is a letter recently so I say you run out to define a function that do not function inside when writing a program named above in addition to telling you any additional unnecessary thing to do something other than if you say, oh ah I would not want to give way the email I just had this scene you have to want to do so I usually recommend two solutions first want you to put this thing into a package similar service more neutral name clearly written this service needs to do something, a process so that we do in this service call when he has a mental preparation service is a service usually is expressed, said he would have to do a lot of things he would not know what to say maybe only calculate simple second point is not very good solution would be okay but a little bit and that is to change your name than your original scrawl way you can get rid of the name is similar to saying calculate total amount and send email, however named, and if there are also representatives said that this function you not only do the one thing that is actually not very good design but if you are the last resort, then I think this is the lowest bottom line at least you can not let your function trickery said good results but there are other price calculation of effect the sixth technique is the use of a technique I love is the early return I quite like to use this technique mainly because I'd been writing ruby javascript and golang I think he has very good for the most important scene is avoided excessive when the formula is determined if the if else occurs more than six five four three two or more layers of similar complexity something like boxing then there will be a fluctuation deep nested like this occurs will become very difficult to read, especially if you want to find out the corresponding else where then add enough logically stacked here when the pain is really super hell do you know? Hell is so in the design of this multi-function conditional I would use early rerturn skills to make the program as much as possible to avoid an early end to carry out the execution to where it should not be thought of as I regard it like playing a current emergency urgent stick like this! Eh! As long as a hit if it does not meet directly out of a good program, we look at the example oh For example today if we want to return something then we have to return a stuff two arguments so-called two argument only in these two parameters are validated under the conditions we will take these two parameters again made another parameter in the program which it then this new parameter made out of this last condition must be verified before we return stuff if it is not adopted under always throw error exception is so you can see if this program by way of a bunch of if else, then it becomes very difficult to understand in order to see that currently there are not a lot of logic I just have to write one line, two lines of it However, if we use the early return of the skills we put it back in again wrote what would become of it you will find a program as long as it discovered the error direct throw exception directly out of this function this way, I can make the code as much as possible keeping only one judgment that is if if reached Hey! To do, to continue down ... If you do not do it if exception thrown out like this will be above this function to read from top to bottom to understand this in the relevant design pattern also mentioned, for example, fail fast or guard clause, however, that in certain programming languages such as C it as long as more than one point of return would be considered bad design As such wording in the end it really good in fact, there is no standard answer to this thing, after all, write program code for as long as the team's style is subjective consensus everyone can be the fastest way to understand but then, I like writing style is quite like this again with other conventions, and learned something design pattern to follow can write easily maintain collaboration 6 little skill code provided today are immediately write it down yet can do in your current code improvements Oh These are all of the contents of this video if you like sharing your content today and please remember to help I push open the little bells subscribe and leave a message to tell me your ideas and thoughts today have not learned what you find useful tips it? Your support is my greatest motivation to continue to create I was rolling on the ground Nic engineers then we will see you next Hello
Info
Channel: 在地上滾的工程師 Nic
Views: 234,738
Rating: undefined out of 5
Keywords: 工程師nic, 在地上滾的工程師, 軟體工程師, 工程師, 寫程式, 程式設計, 程式, 學寫程式, python, 寫 程式 自學, 學 寫 程式, 寫 程式 課程, 基礎教學, 前端工程師, 科技, 資訊工程, 編程, ruby on rails, 資工, 程式語言, 學習, coding, learn to code, 軟體 工程師 課程, 學程式, 自學程式, 後端工程師, programming, computer science, engineering, 軟體, 教學, 程式語言 入門, 程式語言 新手, html css, 程式語言 學習, 程式語言 排行, software engineer, 程式語言 介紹, 程式語言 課程, 程式語言 比較, 程式語言 教學, 前端, 台大資工, 資工系, 電腦科學, javascript, 網頁開發, 程序员, 後端, 網頁, php, 薪水, 求職, 找工作, 學 寫 程式 課程, how to improve your code, how to write code, clean code tricks, programming tips
Id: cfeKek8p9us
Channel Id: undefined
Length: 13min 38sec (818 seconds)
Published: Mon Jul 05 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.