Lecture 2 - Good Code, Bad Code
Lecture 2 - Good Code, Bad Code CS2103
Popular in Software Engineering
Popular in Quantitative Methods
verified elite notetaker
This 3 page Class Notes was uploaded by Jerry Tan on Saturday August 22, 2015. The Class Notes belongs to CS2103 at National University of Singapore taught by Damith C. Rajapakse in Summer 2015. Since its upload, it has received 130 views. For similar materials see Software Engineering in Quantitative Methods at National University of Singapore.
Reviews for Lecture 2 - Good Code, Bad Code
Report this Material
What is Karma?
Karma is the currency of StudySoup.
You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!
Date Created: 08/22/15
National University of Singapore NUS CS2103 Software Engineering AY2015 SEM 1 Lecture 2 Good Code Bad Code Friday 21St August 2015 By Jerry Tan Si Kai Good code Bad code What are the qualities of production level code 1 Performance 2 Readability 3 Functionality 4 Ease of maintenance 5 Documentation Code quality is measured by WTF min Practices for better quality code 1 Follow a standard a Indentation b Function naming c Syntax d All code in any codebase should look like a single person typed it no matter how many people contributedquot 2 Comment a Some comments are wrong b Some comments will eventually be wrong c Selfexplanatory code works better than having comments so what really is the value of comments d Good comments explain i What the function is supposed to do ii Why do we call certain methods purpose for doing something iii How it is implemented e Avoid magic numbers define a constant for frequently used numbers 3 Exploit abstraction SLAP 4 Optimize if you must Single Level of Abstraction Per Function SLAP What 1 In order to make sure our functions are doing one thingquot we need to make sure that the statements within the function are at the same level of abstraction 2 Eg public static void main String args String command getCommandscanner String result parseCommandO String msg executeCommandresult0 result1 printExecutionResultmsg 3 Do not mix high intermediate and low level abstractions within the same function Why SLAP 1 There is a limit to how much the brain can process it is easier to understand smaller functions than bigger functions 2 Breakdown big problems into smaller manageable bitesized chunks Why not SLAP 1 More functions slow down the code a Prematurely optimizing code is the root of evil in programmingquot b Obscures the code c The code where you optimize may not even be the one that gets executed d Negligible improvements in performance Messy things get messier fast So we have to clean up code Refactor cleaning up code by modifying it incrementally without modifying behaviour But refactoring may introduce regression So perform a regression test after refactoring Revision Control Software We are using Git for C82 103 Repository folder containing all the files and folder that the RC5 will track Local your computer Remote server does not exist on your computer
Are you sure you want to buy this material for
You're already Subscribed!
Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'