Dne 29.2.2016 v 08:07 Ancor Gonzalez Sosa napsal(a):
This is the (hopefully) last part of my list of thing I considered as the obvious way to go while refactoring/reviewing code at some point but turned out to be more controversial than I expected.
This week we'll probably agree in a more shared and less personal view about these topics.
1) RSpec as a design validator
Yes, tests are also good indicators of design quality. If it is difficult to write a test then it will be very likely difficult to use the code in a real application.
2) Another note about OOP design
[...]
fake_probing = Yast::Storage::FakeProbing.new devicegraph = fake_probing.devicegraph factory = Yast::Storage::FakeDeviceFactory.new(devicegraph) factory.load_yaml_file(input_file) yaml_writer = Yast::Storage::YamlWriter.new yaml_writer.write(devicegraph, output_file)
The fact that we had a "new" every couple of lines is a design smell to me. The adopted solution was creating class methods, so we can do things like this.
I agree, creating an object, calling a single method and then throwing it away is actually hidden procedural code... [...]
factory = Yast::Storage::DevicegraphFactory.new devicegraph = factory.create_from_file(input_file) File.open(output_file, 'w') {|f| f.write devicegraph.to_yaml }
NP: you can use File.write(output_file, devicegraph.to_yaml) [...]
That's all. Sorry again for the long text. I suck at summarizing.
No, actually it's good to discuss some designs ideas as well. We missed that in the past. I personally welcome this discussion, after the years with YCP it's difficult to change the way I think... -- Best Regards Ladislav Slezák Yast Developer ------------------------------------------------------------------------ SUSE LINUX, s.r.o. e-mail: lslezak@suse.cz Lihovarská 1060/12 tel: +420 284 028 960 190 00 Prague 9 fax: +420 284 028 951 Czech Republic http://www.suse.cz/ -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org To contact the owner, e-mail: yast-devel+owner@opensuse.org