John Salerno wrote: > So my question in general is, is it a good idea to default to an OOP > design like my second example when you aren't even sure you will need > it? I know it won't hurt, and is probably smart to do sometimes, but > maybe it also just adds unnecessary code to the program.
In general, no. I'm a strong believer in You Aren't Going to Need It (YAGNI): http://c2.com/xp/YouArentGonnaNeedIt.html because it *does* hurt - you have to write the code in the first place - every time you see a reference to MyNotebook you have to remind yourself that it's just a wx.Notebook - anyone else looking at the code has to figure out that MyNotebook is just wx.Notebook, and then wonder if they are missing something subtle because you must have had a reason to create a new class... and so on...Putting in extra complexity because you think you will need it later leads to code bloat. It's usually a bad idea. Possible exceptions are - If you are really, really, really sure you are going to need it really, really soon and it would be much, much easier to add it now then after the next three features go in, then you might consider adding it now. But are you really that good at predicting the future? - When you are working in a domain that you are very familiar with and the last six times you did this job, you needed this code, and you have no reason to think this time is any different. You struck a nerve here, I have seen so clearly at work the difference between projects that practice YAGNI and those that are designed to meet any possible contingency. It's the difference between running with running shoes on or wet, muddy boots. Kent -- http://mail.python.org/mailman/listinfo/python-list