Re: Good use of Adapter pattern?
Leam Hall <[email protected]> Fri, 6 Sep 2019 07:14:36 -0400
| Newsgroups | gmane.comp.lang.ruby.general |
|---|---|
| Message-ID | <[email protected]> |
Here's what I have so far. Not sure it's the best looking library ever. :) https://github.com/makhidkarun/ftl_tools/blob/master/lib/ftl_tools/data_mine.rb Here are the tests. Also lots of room for improvement. https://github.com/makhidkarun/ftl_tools/blob/master/spec/data_mine_spec.rb Looking for critique on both. Thanks! Leam On 9/2/19 4:17 AM, Andy Jones wrote: > I would have said so, yes. Very much so. > > Presumably you will have a model class for each data source, and the adaptor class will instantiate the model class it needs? > > > > -----Original Message----- > From: ruby-talk [mailto:[email protected]] On Behalf Of Leam Hall > Sent: 01 September 2019 11:55 > To: Ruby users > Subject: Good use of Adapter pattern? > > I'm building my OO skills (about 30 years late) and am learning a little > bit about patterns. While they may not be the be all and end all, my > current use case might be a good fit for the Adapter. Looking for a > little wisdom before I jump in. > > I have a module, "data_mine", currently with two methods. > "get_random_line_from_file" returns a string from a file, and it uses > "array_from_file" to intake a line delimited file of possible data options. > > The goal is to change the "get" method so it can take an optional > positive integer and return that many items, and for the source of data > to be either a line based file, a CSV file, a MongoDB or SQLite > datastore, etc. > > Is the Adapter pattern a good fit for this refactoring? > > Thanks! > > Leam > > Unsubscribe: <mailto:[email protected]?subject=unsubscribe> > <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk> > > > Click here to view Company Information and Confidentiality Notice.<http://www.jameshall.co.uk/index.php/small-print/email-disclaimer> > > Please note that we have updated our privacy policy in line with new data protection regulations. Please refer to our website to view the ways in which we handle your data. > > Unsubscribe: <mailto:[email protected]?subject=unsubscribe> > <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk> > Unsubscribe: <mailto:[email protected]?subject=unsubscribe> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>