On Tue, Oct 13, 2015 at 10:56:15AM +0200, Josef Reidinger wrote:
On Tue, 13 Oct 2015 10:43:09 +0200 Arvin Schnell <aschnell@suse.com> wrote:
On Tue, Oct 13, 2015 at 08:55:48AM +0200, Ancor Gonzalez Sosa wrote:
Yes. And it should be fairly easy to implement. But I still wonder about how flexible and future-proof is to keep adding find_by_xx on demand to the API.
More flexible solutions would also be more complex to use for sure. I just wonder if they are worth exploring. One obvious solution (that would need refinement, of course) if having a search object that accepts any number of key-pair filters. The most primitive form just to expose the idea would be something like (in pseudocode):
s = Storage.search(device_graph, "filesystem") s.add_filter("mountpoint", "/") s.first()
1. This API converts compile-time checks to runtime errors, e.g. if you search for a flag that does not exist.
agreed. It should be what kind you search for. So it is better to have something like search_filesystem
So Filesystem::find_by_mountpoint(): Type-safe and in the class Filesystem where it belongs.
The set of classes is not fixed. On research already people requested to have plugins to support new storage types so any design that has a central search function like above looks inappropriate.
Basically for plugins the best design is to have good concept base class like filesystem, container that have methods that allows them to connect to rest of graph
In general I think we should follow already know principles of good OO design like open/closed principle https://en.wikipedia.org/wiki/Open/closed_principle , SOLID or KISS
Good, so I expect that all "improvement ideas" show that they follow those principles. So far that was unfortunately not the case. ciao Arvin -- Arvin Schnell, <aschnell@suse.com> Senior Software Engineer, Research & Development SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg) Maxfeldstraße 5 90409 Nürnberg Germany -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org To contact the owner, e-mail: yast-devel+owner@opensuse.org