Hi Joe,

I'm not sure in what context you mean.  Why wouldn't you run this in the
#initialize method?

JoeAccountingParser class>>configure
        InPath := '/Users/jja/Desktop/accountingfiles/'.
        OutPath := '/Users/jja/Desktop/accountingfiles processed/'.

JoeAccountingParser >>initialize
        self class configure.
        fileParser := FileParser new.
        fileParser inPath: self class InPath.
        fileParser outPath: self class OutPath.

JoeAccountingParser class >> process: aFile
        ^(self new) process: aFile; yourself.
                

JoeAccountingParser process: aFile
        fileParser readThis: aFile.
        fileParser process.
        fileParser write.

This is a bit refactored and it uses the configure method I recommend to you
earlier.  This configure method could be anything including a method to read
an external file for details.

Solutions like a factory method pattern come to mind if you don't want to
use #initialize.

JoeAccountingParser class >> process: aFile from: inPath to: outPath

There is also Behavior #startUp and #shutDown on the class side.

See Smalltalk #addToStartUpList: #addToShutDownList:

These fire when an image is started or shutdown.  

I think a bit more explanation of what problem you are having is needed.

All the best,

Ron Teitelbaum 



> From: Joseph Alotta
> Sent: Friday, June 10, 2016 12:23 PM
> 
> Greetings,
> 
> My object needs to have some variables set before it can run the
initialize
> method and also it needs to have run an exit method.
> 
> f := FileParser new.
> f inPath: '/Users/jja/Desktop/accountingfiles/'.
> f readThis: 'rei mastercard.csv'.
> f process
> f outPath: '/Users/jja/Desktop/accountingfiles processed/'.
> f write.
> 
> 
> Is there a better way to do this?
> 
> Sincerely,
> 
> Joe.
> 
> 
> _______________________________________________
> Beginners mailing list
> Beginners@lists.squeakfoundation.org
> http://lists.squeakfoundation.org/mailman/listinfo/beginners

_______________________________________________
Beginners mailing list
Beginners@lists.squeakfoundation.org
http://lists.squeakfoundation.org/mailman/listinfo/beginners

Reply via email to