F
Florian Weber
hi!
i have a design question. for example i have a class which reads a file
and prints out each line with line numbers. what if now i wanna be able
to plugin some functionality which sorts the file, depending on some
conditions (extension, etc) before its passed on to the line numbering
functionality. the class should be as less tied as possible to the
sorting
functionality as possible..
how would you normally design that in ruby?
would you just overwrite the method which calls the file read method
and passes it to the numbering method?
would you pack an object in between, which would check if the file
has to be sorted, because the conditions are true, read the file and
the return the sorted or unsorted content?
basically im wondering if its considered a good practice to overwrite
methods on the same class or if its kinda hackish.. =)
thanks a lot!
ciao!
florian
i have a design question. for example i have a class which reads a file
and prints out each line with line numbers. what if now i wanna be able
to plugin some functionality which sorts the file, depending on some
conditions (extension, etc) before its passed on to the line numbering
functionality. the class should be as less tied as possible to the
sorting
functionality as possible..
how would you normally design that in ruby?
would you just overwrite the method which calls the file read method
and passes it to the numbering method?
would you pack an object in between, which would check if the file
has to be sorted, because the conditions are true, read the file and
the return the sorted or unsorted content?
basically im wondering if its considered a good practice to overwrite
methods on the same class or if its kinda hackish.. =)
thanks a lot!
ciao!
florian