Register
It is currently Sat Nov 22, 2014 9:32 am

Rewrite with functions or not to Rewrite with functions


All times are UTC - 6 hours


Post new topic Reply to topic  [ 3 posts ] 
Author Message
 PostPosted: Mon Jan 06, 2014 3:59 pm   

Joined: Mon Jan 06, 2014 3:44 pm
Posts: 1
I learned scripting the hard way and originally without functions (didn't need them for what I was doing) I have written a few scripts that do a bunch of different steps to configure a monitoring program. The script works fine as is. But I was wondering should i rewrite it with functions or just leave as is?


Top
 Profile  
 PostPosted: Tue Jan 07, 2014 1:31 pm   
User avatar

Joined: Fri Jul 22, 2011 5:39 pm
Posts: 47
If it's not broke, don't fix it. :)

If it breaks, then rewrite with functions.

Just my advice.


Top
 Profile WWW  
 PostPosted: Tue Jan 14, 2014 11:10 pm   
Site Admin
User avatar

Joined: Sun May 15, 2005 9:36 pm
Posts: 673
Location: Des Moines, Iowa
Depends, I rewrite alot of my old scripts that I'm not real proud of how they were written. This is known as code refactoring.
Quote:
Code refactoring is a "disciplined technique for restructuring an existing body of code, altering its internal structure without changing its external behavior",[1] undertaken in order to improve some of the nonfunctional attributes of the software. Advantages include improved code readability and reduced complexity to improve the maintainability of the source code, as well as a more expressive internal architecture or object model to improve extensibility.

Quote:
By continuously improving the design of code, we make it easier and easier to work with. This is in sharp contrast to what typically happens: little refactoring and a great deal of attention paid to expediently adding new features. If you get into the hygienic habit of refactoring continuously, you'll find that it is easier to extend and maintain code.
—Joshua Kerievsky, Refactoring to Patterns


So, personally, I think if you have time, it's a good thing and a worthwhile thing to do. ;)


Top
 Profile WWW  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], Yahoo [Bot] and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP