Questions tagged [library-design]

Use this tag for topic related to library development

Relates to designing and developing libraries, which can be used for private or public software development.

66 questions
1
vote
0 answers

Should I create an extra type when using ad-hoc polymorphism in scala?

I'm currently writing some code using ad-hoc polymorphism in Scala. For example, one of my classes extends a Stream[Boolean] with a method: implicit class BooleanStreamOps(s: Stream[Boolean]) { def toByteStream: Stream[Byte] = ??? //…
Timo
  • 920
  • 8
  • 23
1
vote
0 answers

Given an abstract interface. Only clue for the need to provide an own implementation lies in NOT finding a factory function?

Admittedly a quite theoretical question. And I would like to ask it more from the perspective of a library designer, than a library user. Although the goal is to provide the easiest possible design for the user. Is there any gideline / best practice…
yau
  • 537
  • 6
  • 14
1
vote
2 answers

Why do some string routines give a result and some change the original in Delphi?

Something that has been boggling my mind is that I don't understand why some (most) string routines are functions that give a result and some string routines are procedures which change the original string. S2 := Copy(S1,3,2); Copies into S2 from…
Pieter B
  • 1,874
  • 10
  • 22
1
vote
1 answer

Passing function pointers as an API interface to a compiled library

Dearest stack exchange, I'm programming an MRI scanner. I won't go into too much background, but I'm fairly constrained in how much code I've got access to, and the way things have been set up is...suboptimal. I have a situation as follows: There…
Landak
  • 904
  • 14
  • 26
1
vote
1 answer

Object Oriented Code vs. MVC pattern - which to follow when initializing page?

R:1 They are not mutually exclusive as stated in this SO Post This is a specific question related to this more general SO Post However a controller is suppose to route all calls from the User. I do this by initializing my elements ( setting the…
CS_2013
  • 1,158
  • 3
  • 13
  • 24
0
votes
1 answer

std::span as a base class for std::vector

I'm currently developing a custom C++ container library that is similar to std::vector, but I also want to have features of std::span baked in. In particular, I want to be able to write functions that take in a std::span-like parameter, and also…
Dongryul Kim
  • 103
  • 2
0
votes
0 answers

Why not make { "hello"s + "world"sv; } valid in C++20?

#include #include using namespace std::literals; int main() { "hello"s + "world"; // ok "hello"s + "world"sv; // error } See online demo Why not make "hello"s + "world"sv valid in C++20?
xmllmx
  • 39,765
  • 26
  • 162
  • 323
0
votes
0 answers

boost::asio and boost::bind errors

This questions is a bit annoying, I can't get the following code to compile. You will have to compile the code below. I am having some trouble with boost asio, I am trying to abstract the logic of accepting connections into a uniform abstraction so…
Hassan Syed
  • 20,075
  • 11
  • 87
  • 171
0
votes
1 answer

How to Do Nested Imports

I am trying to clean up my user api, so that users can neatly just import from a single package object, and get all the stuff inside. I realize I can just move my packages to sit in the top package, but I was wondering if there is a way to do the…
finite_diffidence
  • 893
  • 2
  • 11
  • 20
0
votes
2 answers

Java standard library: Which methods are with biggest number of arguments in the library?

Which methods are with biggest number of arguments in the Java standard library? Note: variable Arguments (Varargs) should be counted as 1 argument of type array instead of infinite number of arguments. Reason: I'm trying to design better Libraries…
Mustafa
  • 931
  • 1
  • 13
  • 26
0
votes
3 answers

Is there a de facto standard to identify HTML elements for a JavaScript library to attach to?

I'm creating a JavaScript library. This library will attach itself to one or more div's in an HTML doc. I'd like to attach automatically to make it easy for users to integrate the library. Is there a de facto standard or best practice for how HTML…
DaveBurns
  • 2,036
  • 2
  • 27
  • 37
0
votes
1 answer

Referring to abstract type outside of trait for class construction

Premise: I want to separate the information necessary to instantiate a class from the information necessary to "run" the class. However, the information neccesary to "run" the class may differ from class to class. Thus, I imagine the class "has"…
0
votes
0 answers

Python api design, add copy method to object or defer to copy library

I have a library (pymunk) Im maintaining. Should I add my own copy() method on all the relevant classes or let the users of the library use the standard library copy.deepcopy method when they want a copy? Recently a user asked about a method to copy…
viblo
  • 4,159
  • 4
  • 20
  • 28
0
votes
0 answers

Scala library design: it it ok to use static factory methods for object creation?

I created a library in Scala. It's a parser that comes with different implementations. The trait that abstracts from everything looks something like this (simplified): trait Parser { def parse(in: Array[Byte]): Array[Byte] } The concrete parser…
ceran
  • 1,392
  • 1
  • 17
  • 43
0
votes
0 answers

Creating library in JavaScript - setting "this" keyword relative to instance for all functions

I have developed a draft of a library, and coming from a OOP Java background, have a problem setting/accessing the correct "this"-keyword. Each instance is linked to a canvas, which it draws to using various settings, instantiated like so (commands…
Robin Nabel
  • 2,170
  • 1
  • 21
  • 26