How would you guys do this?
I have created a very simple text editor with basic functionality. It's all in one class, and this is what bothers me. I wanted it in different classes, but just couldn't seem to get it done. So, what I ask from you is your input on the different classes you would use if you wrote this program. Mine has the following functionalities: Save, SaveAs, New, Find, Replace, and other crap like that. I know it's simple enough to have it in just one class, but I was hoping to get practice with using multiple classes.
Any help would be appreciated.
Re: How would you guys do this?
Are you already using the Swing editor model? Or do you do everything yourself? If you do it yourself, you could try separating the document and the view of it. That's all I can think of. Separating the functionality you listed doesn't make sense.
Re: How would you guys do this?
Im doing everything myself. I don't know of a swing model.
Re: How would you guys do this?
Well, then go ahead and create a Document class and a View class.
Re: How would you guys do this?
I hope you don't mind me asking, but what do you mean by a document class and a view class?
Re: How would you guys do this?
The document class stores the data. It offers operations to save, load, create new, modify etc. Ideally it emits notifications if it is changed.
The view class displays the data. It stores a reference to the document and has some UI elements that can be used to work on it. For example, it offers a text area where it displays the data, and when the text area is modified, it tracks the modifications in the document.
The advantage is that you can have more than one view of the same data. You could have another view that parses the data and displays a class browser, for example.
Re: How would you guys do this?
Quote:
Originally Posted by CornedBee
The document class stores the data. It offers operations to save, load, create new, modify etc. Ideally it emits notifications if it is changed.
The view class displays the data. It stores a reference to the document and has some UI elements that can be used to work on it. For example, it offers a text area where it displays the data, and when the text area is modified, it tracks the modifications in the document.
The advantage is that you can have more than one view of the same data. You could have another view that parses the data and displays a class browser, for example.
Thank you. This idea is definitly one worth trying. Again, thank you for helping.