From: Adam Akhtar Date: 2008-11-08T14:57:44+09:00 Subject: implementing mvc - using observer pattern - beginner to OOP Hi I started making a simple command line todo list application as a way to get better at OOP. I decided to use a flat file db gem called kirbybase. Anyway the more I started programming it, the more it started to resemble spaghetti code with ui getting mixed in with logic so I started using google to find some patterns that might help. One that came up was MVC which ive heard about from my very very limited rails experience. I tried implementing it (more like fudging it) but I dont think im giong abotu it the right way. Ive looked on google for ruby specific stuff but keep getting rails results that only provide an overview of it. Can anyone provide any light on how to go about implementing it. Will Kirby Base essentially be my model? Or will the model interact with kirbybase? If i use the observer pattern I guess the model should be the observable with the views being registerd observers. Right? What about the controller? What is it obesvign and who is observing it? All menues etc will live in the views i think with user choices e..g "add task" being registered in the controller along with the program logic... is that right? Regards to their interaction, do all talk to each other or is there a chain of command. I.e. the models seem to speak to the views by updating them, the controllers seem to talk to about the views and models? is that right? Finally does the singleton pattern come into play here? If i wrap the database into a class should only one instance be made? Apologies for my inexperience ;-) I know this may sound like overkill for a simply todo command line app but i think it will make great practice and setme up for rails in the future. any help will be of great assistance -- Posted via http://www.ruby-forum.com/.