Pages: [1]   Go Down
Author Topic: Benefits (advantages) of creating Libraries  (Read 574 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 1
Posts: 32
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello everybody.

As my project progresses and I keep adding hardware and libraries I was wondering If I should create my own. I must admit that I'm not as C++ fluent as I would like to be, hence I come here for your comments.

What are the benefits of creating Libraries vs in-sketch formulas?
Logged

UK
Offline Offline
Shannon Member
****
Karma: 223
Posts: 12631
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Use of libraries enables code reuse without duplication.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

East Anglia (UK)
Offline Offline
Faraday Member
**
Karma: 114
Posts: 4240
May all of your blinks be without delay()
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I built a simple library to control a motor connected to a H bridge for several reasons

1. To see whether I understood enough to do it.
2. To enable the methods I included in the class to have meaningful names
3. To be able to control more than one motor and to give them names
4. So that I could use the library in several programs without copy/paste of functions between them
5. To get experience so that I could understand the workings of other libraries.
Logged

Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 610
Posts: 49077
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
What are the benefits of creating Libraries vs in-sketch formulas?
Less hair to wash, comb, etc.
Logged

East Anglia (UK)
Offline Offline
Faraday Member
**
Karma: 114
Posts: 4240
May all of your blinks be without delay()
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Same amount of hair but you just get someone else to wash, comb etc
Logged

Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

UK
Offline Offline
Shannon Member
****
Karma: 223
Posts: 12631
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

2. To enable the methods I included in the class to have meaningful names
3. To be able to control more than one motor and to give them names

These points relate to using classes, not libraries.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Left Coast, CA (USA)
Online Online
Brattain Member
*****
Karma: 361
Posts: 17293
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I think the biggest benefit of developing libraries is the ease in which you can share your solutions with others so that they may benefit from your work. The vast number of 3rd party library contributions is one of the main things that makes Arduino the best and most popular platform for both beginners and many experienced alike.

 The Arduino platform was build on the shoulders of several open source projects and library contributions is one of the best ways people can give back.

Lefty
« Last Edit: February 05, 2013, 09:30:59 pm by retrolefty » Logged

East Anglia (UK)
Offline Offline
Faraday Member
**
Karma: 114
Posts: 4240
May all of your blinks be without delay()
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

2. To enable the methods I included in the class to have meaningful names
3. To be able to control more than one motor and to give them names

These points relate to using classes, not libraries.
True.  My fault for conflating the 2 ideas in my post, although putting a class into a library seems the natural thing to do.
The advantages of having the same class easily available to several programs was actually the reason I created the library.
Logged

Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Offline Offline
Newbie
*
Karma: 1
Posts: 32
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks! I now have a better understanding of Libraries!... Regards!
Logged

Pages: [1]   Go Up
Jump to: