comp.lang.ada
 help / color / mirror / Atom feed
* Object oriented (question)
@ 2017-10-19 22:48 Victor Porton
  0 siblings, 0 replies; only message in thread
From: Victor Porton @ 2017-10-19 22:48 UTC (permalink / raw)


I am writing thick (object oriented) Ada2012 bindings of a C library.

Right now I am finishing to implement bindings for:
http://librdf.org/docs/api/redland-parser.html

My bindings are in
https://github.com/vporton/redland-bindings/blob/ada2012/ada/src/rdf-redland-parser.ads
https://github.com/vporton/redland-bindings/blob/ada2012/ada/src/rdf-redland-parser.adb

Particularly I defined Parser_Type tagged type to describe RDF parsers.

We should be able to attach an URL filter (allowing/disallowing certain
URLs to be downloaded).

Should the URL filter be implemented simply as a primitive function
(intended to be called with dynamic dispatch like virtual function in
C++) which returns Boolean?

Or should I create a special tagged type URI_Filter_Type and procedure
like

procedure Attach (Parser: Parser_Type; Filter: URI_Filter_Type'Class);

?

The first is easier to implement. But it looks not elegant, maybe
violating single responsibility principle (Parser_Type is responsible
both for parsing and URI filtering).

The second is harder to implement and harder to invoke (at least in
simple situations), as it would require an additional variable

Filter: URI_Filter_Type;

every time when it is used with a Parser_Type object.

But the second one is more flexible in principle.

However, do I really need this flexibility? The implementation of
Parser_Type would require just one overridable subprogram. So the
argument that to properly overriding multiple subprograms multiple
inheritance (which is missing in Ada) would be needed, looks like
a void argument.

So, please help me to choose.

Note that the only reason to decide should be convenience of using
of my library, not complexity to implement, as I can implement it
in any case.

-- 
Victor Porton - http://portonvictor.org


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-10-19 22:48 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-19 22:48 Object oriented (question) Victor Porton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox