Showing posts with label code complete. Show all posts
Showing posts with label code complete. Show all posts

Tuesday, August 13, 2013

Code Complete Chapter 31 Layout and Style Notes

Notes from reading:
Code Complete: A Practical Handbook of Software Construction, Second Edition by Steve McConnell Link: Amazon 
I have been reading this try to improve my skills I figured I could jot down some notes which might help it sink in my brain and who know you might find interesting.  
 
Interesting
for ( int i = 0; i < MAX_LINES; i++ )
{
          ReadLine( i );
          ProcessLine( i );
}

for ( int i = 0; i < MAX_LINES; i++ )
   { 
          ReadLine( i );
          ProcessLine( i );
   }
McConnell makes the point that the above coding styles don't really illustrate the logic of the code.  His point is basically that the statements really don't need to be indented.  He believe that the following is really more appropriate. As the below better shows the concept better of what level the statement are at. 

for ( int i = 0; i < MAX_LINES; i++ )
   { 
    ReadLine( i );
    ProcessLine( i );
   }

I admit I have been using the first example quite often in C++ and C# as it seems to be the Visual Studio default.  He also mentions that the more standard Java (pure block) method is probably a slightly better layout.  I think he makes a decent case that this is a little better style as it would require less indenting to show the levels.
for ( int i = 0; i < MAX_LINES; i++ ) { 
    ReadLine( i );
    ProcessLine( i );
}


Nice to see in writing that the 80 character limit is not something that anyone should be worried about on modern technology.

grossRate[census[groupId].gender,census[groupId].ageGroup] should be
grossRate[ census[ groupId ].gender, census[ groupId ].ageGroup] which I will admit is probably more readable but I think it only works on a new project.  Trying to do that on an existing code base would probably just mean I wouldn't be able to search for anything properly. 

"A class should support one and only one purpose" I have read this a lot and it seems to make sense but sadly it seems like no one likes to do it. 
submit to reddit

Tuesday, August 6, 2013

Code Complete Chapter 30 Notes Programming Tools


Code Complete: A Practical Handbook of Software Construction, Second Edition by Steve McConnell Link: Amazon 

Templates I think I need to try to start developing and using templates in my work. This isn't the first time I have thought this maybe writing it down will help me remember. 

Data Dictionary is apparently a database that can list the names of all data including classes and data base tables with a description to aid in understanding the data.  This seems like a pretty good idea.

Ant is a technology that I would like to play with at some point.  I have read a lot about it on blogs and Stack overflow but sadly have never used it myself.

I think I need to consider scripting more things.  McConnell suggest that anytime you type the same 5 characters more then once it might call for a script!  This seems a little problematic with Internet password requirements being longer then this nowadays.  

Code Complete Chapter 29 Notes


Code Complete: A Practical Handbook of Software Construction, Second Edition

Daily builds :
  • Should build up executable every day and test it a little to just make sure it still works. 
    • Smoke testing as the Author calls it is key to getting the benefits out of the build.    
  • Increases morale 
    • This is new one I hadn't thought about before but seeing the product improve increases developer morale.  I believe this is true I'm always excited to see the product improving.