Apr 11, 2006 at 9:02am
Just a quickie coding style question :
I realize my Open() function (no matter the context) do too much things
Apr 11, 2006 at 10:12am
Apr 11, 2006 at 10:30am
On 11-Apr-2006, at 11:02, f.e wrote:
The way I learned to do this at uni and the way these things happen
In the real world, there is a tendency to be happy when something
What training&experience give you is a sense of when to subdivide a
Two rules of thumb, salt to taste but do not give yourself a nervous
- If a function is too long to print on a single A4 sheet, it would
- If you find yourself about to Copy & Paste a chunk of code, it may
There are exceptions and trade-offs to be made.
I recommended the Bentley _Programming Pearls_ books on another
Hope this helps,
————– http://www.bek.no/~pcastine/Litter/ ————-
iCE: Sequencing, Recording & |home | chez nous|
Apr 11, 2006 at 11:13am
Apr 11, 2006 at 2:16pm
there’s always a trade-off between breaking things up too much and
i try to break things up within reason – those reasons being, 1) if
especially reason #2… a very good coder once told me, while i was
they call it “re-factoring,” that continual process of taking huge
Apr 11, 2006 at 2:36pm
so i didn’t really give a good answer there.
one method is to think of your code in terms of language structure
so in general, i’d say yes, if your “open” function does a lot more
Apr 11, 2006 at 5:18pm
Apr 12, 2006 at 3:55pm
As others have said, it’s as much about taste and expediancy as anything else; if it works and you can be confident of understanding the code six months from now then you may not want to lose sleep over it.
The most Javaesque way of slimming down is often to go for more classes rather than more methods, so in your case you could have a MidiFile class that is responsible for sanity checking a MidiFile and extracting its properties, and a sequence class that wraps it:
new Sequence(new MidiFile(new FileInputStream(…
a la the dao of java.io.
Oh, I lay no claim to guru-hood either :)
You must be logged in to reply to this topic.