As I look back at my older projects and code, the lack of organization and structure is missing. I’m thankful for my detailed comments, because that code would have taken much longer to read. In our course, we went over the principles and practices associated with writing and abiding by “clean code” strategies. To deeper my knowledge on this matter I ended up finding an article called “How to Write Clean Code – Tips and Best Practices(Full Handbook),” by German Cocca. I trust this resource, it comes from freeCodeCamp. I have used this website in the past and I think it is a very useful source of free information. I also trust the author because he is a full stack developer. This comes from his own blog.
This article states clean code is more than just code that can run and function. Clean code should be very easy to read, understand, maintain overtime, and breakdown. His pilers of clean code are effectiveness, efficiency and simplicity. While the focus of codding should always be the functionality of the code, this should also be done so wile optimizing resource usage and while maintaining clarity.
The most important information I took from learning about clean code in the class room, was the idea that If you have to comment code, you didn’t write it clear or efficient enough. This also goes with functions, functions should be kept as small as possible. This kind of thinking helped me step back and re-evaluate my codding approach. Because of this I feel i write more readable efficient code now.
This article also goes over a very important idea that had a similar effect on my codding as the last. This is the idea of SRP or single respnibility principle. This means every clas or module should onley have one job. If you need to validate orders, calculate a total, save data,these should all be done in their own separate methods classes or functions. This makes the code much more readable and it makes implementing these functions easier.
So far these concepts have also ben dissgussed or touched upon in my class, The concept of modularization was not. This involves breaking down complex code into much smaller pieces. This makes the code easier to test and understand. This allows you to test maintain and read the code all more efficiently. Folder structure was also not talked about in my class. Folder structure is crucial for keeping a clean scalable codebase. The structure should keep related files together based on their functionality. For example instead of organising by filetype, you would organise by feature types. If every feature has its own place, it will be easier to go back and modify it.
I enjoyed looking into this site because It layed everything out in a nice organised manor. It explained everything briefly enough to maintain my interest, but was indepth enough where I was getting the information and knowledge I needed. This website also provided nice code examples for everything it mentions.
Reference:
https://www.freecodecamp.org/news/how-to-write-clean-code/ – How to Write Clean Code – Tips and Best Practices(Full Handbook) by German Cocca
Tags: CS@Worcester, CS-343, Week-11
From the blog CS@Worcester – SPM blog by Aaron Nano and used with permission of the author. All other rights reserved by the author.