On Wed, Dec 18, 2002 at 10:17:23AM +0000, Donncha O Caoimh wrote:
> IMO using classes helps a lot, but it's not necessary, abstraction
> takes a lot of time and most of the time when deadlines are approaching..
I'd argue that abstration is one of the fundamental things you should do
when you're programming. Code reuse is a nice side effect of abstration.
Code reuse means fewer lines of code, which means fewer bugs. That
throwaway script *won't* be thrown away, so you may as well do it right.
If deadlines are approaching, do it the quick and dirty way, but
remember to go back and refactor your code later. Abstraction doesn't
take that much extra time, if at all, once you get used to always
abstracting out code :)
Remember that spending a little time on design at the start can save
time when implementing your system...
Some good advice I once received - if your subroutines are more than
about 10 lines, they're too long. Short amounts of code are much easier
to read. Also, try to remove as many variables as is possible. It makes
it easier to read too. If you can read the code, you're more likely to
understand it and remember what you were thinking when you wrote it :)
Don't be afraid to create lots of packages/modules/classes with not a
lot in them if it helps to keep things separate and logical to you.
BTW, that advice is relevant to perl code, I don't know how relevant it
will be for other languages.
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!