From: Neubyr Neubyr Date: 2012-06-25T05:35:42+09:00 Subject: Code organization in multiple/single classes - things to consider I am writing a script where a user submits certain parameters from CLI and based on these parameters an XML document is created and then submitted to another system for further processing. I am new to object oriented realm and not sure how to organize code in this context. I have written following Person class where methods for XML representation and XML submission are defined in the same class. I am not sure whether this is a good design/organization and would like to get some feedback on how can I improve it. What are the factors or questions I should be considering here? Any comments will be really helpful. require 'rubygems' require 'nokogiri' # for xml require 'processor-client' # to be implemented # Person class class Person attr_accessor :name, :age, :city def initialize(name, age, city) @name = name @age = age @city = city end # Return/express person object in xml format def my_xml # Nokogiri already has to_xml method # create xml pxml = Nokogiri::XML::Builder.new do |xml| xml.person { xml.name @name xml.age @age xml.city @city } end end # Send Person object in xml format to the processor-system # I haven't implemented it yet def send_xml(xml_file) conn = ProcessorClient::Connection.new conn.submit(xml_file) ... ... end end ~ neubyr -- Posted via http://www.ruby-forum.com/.