How to Write Good Code & Become a Professional Programmer

The "why" is clear, we're supporting a need the programmer will have for creating service instances. The "what" is clear, the function returns an instance of the specified generic type T. The "how" is clear, there are four function calls that describe how this function works.

Beginner to code - Are you a programmer? Web Developer? do you know How to Write Good Code and make you a professional programmer? This article is simply about how do to write good code. Bad habits from a programmer especially in Indonesia very often to forget this. In fact, just by adding a bit of writing in your code, you will look like a Professional Programmer.

Here i will show you how to do that. First in your application you must you need to explain some point, WHY, WHAT, HOW. For example, Please see source code below (i will write using C#) :

How to Write Good Code

// usually you will describing why the function exists
public void AnyFunctions()
{
  // do anything!.
}

Now, why you don't write a beauty code look like this one :

/// <summary>
/// The user can get an instance of a service implementing 
/// the specified interface, but only if the service is 
/// registered as supporting instance creation.
/// </summary>
public virtual T GetInstance()
  where T : IService
{
  VerifyRegistered();
  VerifyInstanceOption();
  IService instance = CreateInstance();
  instance.Initialize(this);

  return (T)instance;
}

it's better than the first code.
The "why" is clear -- we're supporting a need the programmer will have for creating service instances.
The "what" is clear -- the function returns an instance of the specified generic type T.
The "how" is clear -- there are four function calls that describe how this function works.
If your function has "how" fragments that would benefit from "how", "what" or "why" comments, then this is great indicator that you should move those fragment into separate functions where the the function name describes "what" and embodies "how."

In other words, when you could write a comment in the body of the code that answers one of those questions, you need to move that code into a function that answers the "what". Recurse that process until the function's name answers "what" and the body of the function clearly describes "how", then for each function you created, write an intelligent "why" comment. Now go forth and code better!

References : http://www.codeproject.com/Tips/1058613/How-to-Write-Good-Code

COMMENTS

Next Recomended


Feel free to code it up and send us a pull request.

Hi everyone, let's me know how much this lesson can help your work. Please Subscribe and Follow Our Social Media 'kodeajaib[dot]com' to get Latest tutorials and will be send to your email everyday for free!, Just hit a comment if you have confused. Nice to meet you and Happy coding :) all ^^



Follow by E-Mail


Name

ADO.NET,3,Ajax,6,Android,9,AngularJS,4,ASP.NET,4,Blogger Tutorials,7,Bootstrap,7,C++,1,Codeigniter,2,Cplusplus,6,Crystal Report,6,CSharp,25,Ebook Java,2,FlyExam,1,FSharp,3,Game Development,2,Java,35,JDBC,2,Laravel,84,Lumen,2,MariaDB,2,Ms Access,3,MySQL,31,ODBC,6,OleDB,1,PHP,14,PHP Framework,5,PHP MYSQLI,9,PHP OOP,5,Python,8,Python 3,4,SQL Server,4,SQLite,4,Uncategorized,5,Vb 6,2,Vb.Net,89,Video,48,Vue Js,4,WPF,2,Yii,3,
ltr
item
KODE AJAIB: How to Write Good Code & Become a Professional Programmer
How to Write Good Code & Become a Professional Programmer
The "why" is clear, we're supporting a need the programmer will have for creating service instances. The "what" is clear, the function returns an instance of the specified generic type T. The "how" is clear, there are four function calls that describe how this function works.
https://4.bp.blogspot.com/-8hmjV7RY51Y/V5EsOs-7SDI/AAAAAAAACHQ/L8NVPF7Pdt4zkIpLD_rcd8Tqklqi7S90QCLcB/s320/write-good-code-good-programmers.jpg
https://4.bp.blogspot.com/-8hmjV7RY51Y/V5EsOs-7SDI/AAAAAAAACHQ/L8NVPF7Pdt4zkIpLD_rcd8Tqklqi7S90QCLcB/s72-c/write-good-code-good-programmers.jpg
KODE AJAIB
https://www.kodeajaib.com/2016/07/how-to-write-good-code.html
https://www.kodeajaib.com/
https://www.kodeajaib.com/
https://www.kodeajaib.com/2016/07/how-to-write-good-code.html
true
3214704946184383982
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS CONTENT IS PREMIUM Please share to unlock Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy