Inconvenient way C/C++ libraries are designed written

Deouss
Posts: 425
Joined: Tue Mar 20, 2018 11:36 am

Inconvenient way C/C++ libraries are designed written

Postby Deouss » Sat Jul 07, 2018 12:25 pm

I looked through a dozen of different libraries f.ex. TFT or sensor libraries and just noticed they are written in quite chaotic way. First of all if we use multiple devices like LCD with common functions - they should have 'virtual' access modifier for devices to override that method in a class. Instead this is like an ocean of IFs and #DEFINEs....

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: Inconvenient way C/C++ libraries are designed written

Postby kolban » Sat Jul 07, 2018 2:40 pm

Howdy. When you talk about different libraries that are written in different styles ... are you referring to different libraries written by different individuals and shared as open source samples? If not, I'm afraid I'm not following the notion. I like to share my samples on Github and if they can be improved upon to make them more consumable I'm all ears so your thinking and desire is very relevant for what I like to do. Would you be willing to elaborate further?
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

Deouss
Posts: 425
Joined: Tue Mar 20, 2018 11:36 am

Re: Inconvenient way C/C++ libraries are designed written

Postby Deouss » Sat Jul 07, 2018 3:55 pm

Hey there )
Yes it is sometimes quite annoying and just exhausting to deal with opensource C++ code out there.
I do not intend to offend anyone - just saying. For example if you look at TFT library - functions like setrotation use specific to device spi commands and it is extremely hard to add support for more devices. Instead - what I'd do is to create skeleton/abstract class with basic functions that are virtual and must be overwritten - in that way we create class per each device and call that function in similar way as it is in C# via 'Interfaces'. C++ has multiple inheritance so it would be very beautiful to code like that.
I dealt with many app architects and they were very particular about it as the projects grow in the future and you can really get stuck on coding because of inconsistency. It is just my input on that subject) Maybe it interests someone or future devs

Who is online

Users browsing this forum: Baidu [Spider] and 202 guests