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.
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
thanks Ron, I hadn’t thought about class variables.
sincerely,
Joe.
On Jun 10, 2016, at 12:17 PM, Ron Teitelbaum [via Smalltalk] ml-node+s1294792n4900450h99@n4.nabble.com wrote:
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 [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners
Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners
If you reply to this email, your message will be added to the discussion below: http://forum.world.st/set-variables-before-initialize-and-write-out-files-be... To start a new topic under Squeak - Beginners, email ml-node+s1294792n107673h12@n4.nabble.com To unsubscribe from Squeak - Beginners, click here. NAML
-- View this message in context: http://forum.world.st/set-variables-before-initialize-and-write-out-files-be... Sent from the Squeak - Beginners mailing list archive at Nabble.com.
beginners@lists.squeakfoundation.org