Properly design a code editor application

Posted by Hemaulo on Stack Overflow See other posts from Stack Overflow or by Hemaulo
Published on 2010-01-21T15:48:21Z Indexed on 2010/04/03 21:03 UTC
Read the original article Hit count: 282

Filed under:
|
|

I'm working on personal project which is basically a code editor. Imagine standard File menu with menu items New, Open, Save, Save As, Save All, Close, Close All.

I'm stuck with proper design. Currently I have:

  • A Document class which represents a document - code editing control, respective tab in tab bar and various properties such as Caption, Filename, IsModified etc.
  • A Documents class which represents all open documents. Contains methods like New, Open(FileName), ...

The problem is that I can't figure out which class / menu command is responsible for which tasks.

For example, with File->New menu command is simple - call Documents.New and that's it.

But what for File->Open? The Documents.Open method expects filename as a parameter. So before calling this method I need to open an file selection dialog, let user select files and for each file call Documents.Open(FileName). Where is best place for this supporting code, in menu command, rewrite Documents.Open and put it there?

The same with Save actions. Which is responsible for saving? Is it Documents class which uses Document.Editor.SaveToFile(FileName) or better create Save method in Document class? Somewhere in the middle also need to ask user if he wants to save current document...

I'm stuck. Any ideas?

Edited: The programming language is Delphi.

© Stack Overflow or respective owner

Related posts about class-design

Related posts about oop