On Aug 2, 2008, at 10:50 AM, Benjamin Schroeder wrote:
On Aug 2, 2008, at 10:43 AM, Sean Allen wrote:
if I have class foo that is meant to only be descended from, never instantiated directly. and it has method bar that needs to made concrete by its descendents, what is the standard idiom for that?
is there a specific error that should be thrown or just:
foo self error: 'any old error here'
is there a particular error that is common practice to use?
You can do
foo
self subclassResponsibility
thanks ben. ok i have another. lets take something that in a sql driven environment would be a lookup table. countries and states. what the the smalltalk way with this?
ive come up with two basic ideas...
each country and each state/province is a single instance of their respective classes ( the class layout i can see a few different options but that isnt the thrust of the question. ). if its a single instance, then you have to deal with creation of each instance... how do you handle the instance creation? what is the normal method for setting up data to create them? monticello in the instances? have class side data that is used to build? this idea seems nice from being able to equality based on object equality but it seems like its generally overblown... however you could attach customized functionality easily if needed to different instances so that nice. ( in the past with C++, i would just load in data from a file on startup and create the objects the data file called for.... )
the other way i can see is to store all the information needed in class variables and create instances as needed when the are asked for. this seems much easier to manage but it feel less smalltalk. then again i dont really know what a smalltalk way really is, but a lookup data structure in class variables dont feel like it.
is one of these more smalltalk? is there something else more suited as a smalltalk solutuion? in the app i'm using to learn smalltak etc, i have this same basic pattern come up several times so I'd prefer to use the best method from the start so 3-6 months from now I dont have a 'o I should have done it this way because with smalltalk that allows... ' kind of moment.
Thanks to everyone for the help so far and any advice on tackling this.