views:

295

answers:

5

I'm writing a lightweight IDE. I chose Ruby+Gtk2 for the task. I already have a minimal prototype for it, but right now, most of the code is inside my window class. I'll soon start working on the "real deal", but I would like to know what design patterns should I make use of. I'm planning for plugin support too, so that the app will be extensible. Any ideas are welcome, but please discuss your option a bit.

Please keep in mind this is a scripting language. I'm not sure if all of Java's design patterns apply here.

+1  A: 

I'm not sure if this will be much help, but the book "Design Patterns in Ruby" talks about, well, design patterns in ruby and how they might differ from Java's design patterns.

inglesp
+5  A: 

Design patterns are solutions for common problems. What problems are you having? In consulting work, we see that often when someone sets out saying "Okay, here's my idea. What design patterns can I put to work?," the architecture gets overly complicated very quickly.

Instead of looking for design patterns that you could possibly use, read up on design patterns (I hate to link to Wikipedia, but their article does have a good list to get you started on other searches with at least) and then apply them when you come up with a problem that fits their criteria.

As far as having a lot of code in your window class, that may be appropriate for your application, or you may want to look at something like a loose MVC pattern. Generally for GUI programming, a rigid MVC is going to be too strict, and require too much work for "true" separation of concerns.

There are many common problems that can be solved without design patterns, and that does not mean the solution is right or wrong. Plugin support, for instance, is very often given just by supplying a plugin interface or a set of events a plugin can respond to. Alternatively, you could look at the Adapter pattern.

JoshJordan
+1 for essentially defining design patterns.
strager
I'm thinking in perspective a bit. The fact that I have a lot of code in my window class seems pretty bad practice to me, because if I keep it like that, I think it will be harder to maintain.
Geo
In that case, the issue may not be a lack-of-design-patterns issue per se, but rather just poorly-suited design overall. Can you post some example code (either here in or in a new thread)?
JoshJordan
Here is most of the code I used so far : http://codepad.org/FHydIJdt
Geo
I'm not at all familiar with Ruby, but this isn't a long module at all. If you really wanted to pull the code out to separate classes, I would subclass the Gtk objects that you're creating, and move the "add_xxx" logic to the xxx constructor, where xxx inherits from Gtk::xxx.Thats a start.
JoshJordan
+1  A: 

Also, don't forget to check out existing IDEs. What did they use?

Since editing will be a component of your IDE, you should check up on actual open source editors.

Daren Thomas
I don't quite get what you mean by "editing will be a component of your IDE"
Geo
Well, among other things, IDEs let you edit code. So, an IDE will generally include an editor.
Daren Thomas
I think this goes without saying, right?
Geo
+1  A: 

Just to clarify a possible misunderstanding: Are you perhaps referring to UI patterns (as opposed to software architecture design patterns)? Your question seems to me to make more sense that way.

Adrian Grigore
They're still design patterns,aren't they?
Geo
Also, those UI patterns seem related to web development.
Geo
It depends on what you mean by design. From a Software Engineering perspective, "design" means OO class structure or overall system architecture (although one could argue that design and architecture are separate). From a web development point of view, its up in the air.
JoshJordan
+1  A: 

I'm not sure if this is appropriate, but there's a nice book about disecting & building an IDE in C#. The book does discuss about the design patterns being used to develop the Sharp Develop IDE. SharpDevelop is a nice IDE & it's open source you might want to have a peek at this book & home page for Sharp Develop.

AB Kolan