Note that there are some explanatory texts on larger screens.

plurals
  1. POIn Rails should objects be limited to those that will have a view and controller?
    primarykey
    data
    text
    <p>I've been struggling with a design problem, and I admit that I am new to both OOP and RoR so I'm sure this is going to be very basic. I have an application where I am reading from text files in various formats in order to parse information related to hands of poker. So what I have are three entities:</p> <ul> <li><p>A file object. This stores the name and path of the file and some other attributes, and has functions related to reading from the files. This is MVC because I can add a file and have it be auto-updated, or I can just parse the info from a file on the fly.</p></li> <li><p>The poker hand object. This essentially just stores information about who played the hand of poker and what the actions and results were.</p></li> <li><p>A parser. This reads external JSON files with different regex patterns depending on the type of file that is being read. It also has some basic state machine info in the JSON file so that alot of the logic is removed from the parser. </p></li> </ul> <p>So my initial feeling about the parser was that it should be its own object. But then I realized that it didn't have a V or a C and so possibly didn't fit with the Rails way of doing things. And it also doesn't have any functionality that is needed by any object other than the file object, and so seemed to fit within the file. But at the same time it's so distinctly different than a file object, that it didn't seem to fit. I thought of a module, but the point of modules seems to be if multiple objects share the need for some functions, and in this case only the file does.</p> <p>So should it be its own object, be within the file object, or is there some other alternative I'm not seeing?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload