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
3
votes
0 answers

Sparse matrix design in modern C++

I want to implement a sparse matrix class using modern c++ ie 14 or 17. I know there must be some trade offs between storage and runtime efficiency. Right now I'd prefer to optimize more in terms of storage efficiency. If possible, I'd prefer more…
Rocking chief
  • 1,039
  • 3
  • 17
  • 31
3
votes
0 answers

What are the pros and cons for opaque pointers vs id numbers using the C programming language?

I'm currently using opaque pointers as my standard technique for encapsulation, but looking at the OpenGL API makes me think that using id numbers could be a better choice. I would like some advice from seasoned C programmers (I've only been using…
arkod
  • 1,973
  • 1
  • 20
  • 20
3
votes
1 answer

.NET IoC: Preconfiguring library components for easier use

I had a similar question a while back, but with much less of a grasp of the whole IoC/DI topic and as well as what I was aiming to achieve, so here goes again.... I am building a library for common use within our company. The most commonly used…
3
votes
2 answers

Why doesn't std types provide conversion constructor / assignment from sources differing in allocator

For example, why doesn't template< typename Elem, typename Traits, typename Alloc > basic_string { ... } provide: template< typename OtherAlloc > basic_string( const basic_string< Elem, Traits, OtherAlloc >& a_Other ) { ... } It would seem fairly…
Ylisar
  • 4,293
  • 21
  • 27
2
votes
2 answers

instantiating a free template function within a template class

I need to instantiate a free template function (FTF) within a template class (TC). The FTF takes as a template parameter one of the template parameters of the TC. The TC also holds generic pointers to these FTF's, and these functions are called…
Hassan Syed
  • 20,075
  • 11
  • 87
  • 171
2
votes
3 answers

Reusable Class Library - INotifyPropertyChanged

I am developing a WPF application in which it will reference a class library that contains mostly business objects and some methods to manipulate those objects. Since this library is being used in conjunction with WPF, I have the need to use the…
Inisheer
  • 20,376
  • 9
  • 50
  • 82
2
votes
3 answers

Why do standard classes sometimes have seemingly unrelated methods?

While studying the standard Java library and its classes, i couldn't help noticing that some of those classes have methods that, in my opinion, have next to no relevance to those classes' cause. The methods i'm talking about are, for example,…
Semisonic
  • 1,152
  • 8
  • 21
2
votes
2 answers

How to design the interface for a static library in C

Although I am not an experienced programmer in C, I have to use this language at work to build a static library which compiles both on SunOS and Win32. This library has just a few source files and their correspondent headers (let's say: a.c, b.c,…
Gerardo Lima
  • 6,467
  • 3
  • 31
  • 47
2
votes
3 answers

Architecture of some reusable code

I am writing a number of small, simple applications which share a common structure and need to do some of the same things in the same ways (e.g. logging, database connection setup, environment setup) and I'm looking for some advice in structuring…
nicolaskruchten
  • 26,384
  • 8
  • 83
  • 101
1
vote
3 answers

Why not a Phantom class which extends Functor Contravariant?

I am playing around with the Data.Functor.Contravariant. The phantom method caught my eye: phantom :: (Functor f, Contravariant f) => f a -> f b phantom x = () <$ x $< () Or, more specifically, the annotation to it: If f is both Functor and…
1
vote
1 answer

Is catch(Exception) viable for convenience methods if there is an overload that allows proper handling?

I am developing a library for working with files and want to make it as easy to use (i.e. not having to worry about exceptions), but also as complete as possible (i.e. allow for proper exception handling). To achieve this, I expose two methods. One…
cegredev
  • 1,485
  • 2
  • 11
  • 25
1
vote
1 answer

Library design and DI with 3rd party dependencies

I'm writing a library for internal use. The purpose of this library is to abstract away calls to some internal REST API's. Under the hood, I'm using Flurl to make the requests. The library also provides extensions methods that sets up DI (Core Web)…
martinoss
  • 5,268
  • 2
  • 45
  • 53
1
vote
1 answer

Should String and CharArray be the same thing?

When designing a programming language API what are the advantages and disadvantages of: The type String and Array(or linkedList) of chars are indistinguishable. Like in: Haskell, Erlang, C String is it's own type and Array(or linkedList) of chars…
Mustafa
  • 931
  • 1
  • 13
  • 26
1
vote
1 answer

Designing public error codes in C for a library

A design issue I'm trying to solve is what is the flexible way to make client to be able to handle errors that may occur when calling to a library functions. I see 2 approaches: I. To put all errors that my be raised by any library functions in a…
St.Antario
  • 26,175
  • 41
  • 130
  • 318
1
vote
2 answers

Inheritance in Java: naming collision case

This question is not only about Java, it is also about another object oriented languages. I designing simple UI library and it has got a special interface called Drawer which contains abstract methods for drawing controls and primitives on some…