Code snippet sharing



  • Hello :D

    Great work here guys!

    I was thinking, would it be good if you include any code snippet sharing system here?

    Someone can write a plugin for Qt Creator that users can manage (download / upload) their code snippets from within the Qt Creator and be able to see and manage their code snippets from the web as well.

    Lots and lots of code is rewritten in the industry today and why let developers reinvent the wheel, instead of using code (a cool widget, an algorithm etc.) that someone has written once and shared in the code snippet sharing system?

    The typical scenario can be for example:

    I am writing a Luhn algorithm using Qt for the use of it within my Qt project(s), but I want to share such algorithm with the rest here, I just select the code that I want to share, hit a shortcut or select a menu that brings a dialog for more information such as name, Qt modules that were used etc. and share the snippet within my snippet "space" where someone else that is having similar task (writing the Luhn algorithm) can search, find my snippet, from Qt Creator select the snippet name and have the snippet inserted in his focused area...

    There is an independent project that is known among .NET developers called CodeKeep (http://www.codekeep.net/) it has a Visual Studio add-in as well.



  • Yes, I am in support of this. Some code snippets that demonstrate some advanced usage of Qt
    components. It doesn't have to be a complete working code, it can be algorithmic snippet or an illustration of a certain feature. And preferably it shouldn't be part of the Qt demos/examples.



  • May be one can post these source code snippets in to the wiki.



  • Why not use http://qt.pastebin.com/ ?



  • I think we should prefer one hosted by Qt only and avoid third party sharing sites. If providing a new interface is not on the roadmap, then posting the code snippets in the wiki like Forum Nokia will be a better option.



  • [quote author="Henrik Hartz" date="1273215603"]Why not use http://qt.pastebin.com/ ?[/quote]

    That's a good idea, but users cannot register and maintain their own code snippets and users are not able to see/use other users' code, it's not that convenient, it would be better to have something built-in right here in the developer network and as well have a Qt Creator plugin for sharing a snippet from Qt Creator itself, it can be also a wiki with a special category called "snippets" or something similar where users can post such code, and I am willing to have such support on Qt Creator.

    Maybe I will write a plugin once I have a web service API exposed :D



  • [quote author="Milot Shala" date="1273218610"][quote author="Henrik Hartz" date="1273215603"]Why not use http://qt.pastebin.com/ ?[/quote]

    That's a good idea, but users cannot register and maintain their own code snippets and users are not able to see/use other users' code, it's not that convenient, it would be better to have something built-in right here in the developer network and as well have a Qt Creator plugin for sharing a snippet from Qt Creator itself, it can be also a wiki with a special category called "snippets" or something similar where users can post such code, and I am willing to have such support on Qt Creator.

    Maybe I will write a plugin once I have a web service API exposed :D[/quote]

    An plugin to view code snippets will be really great.



  • [quote author="Milot Shala" date="1273218610"][quote author="Henrik Hartz" date="1273215603"]Why not use http://qt.pastebin.com/ ?[/quote]

    That's a good idea, but users cannot register and maintain their own code snippets and users are not able to see/use other users' code, it's not that convenient, it would be better to have something built-in right here in the developer network and as well have a Qt Creator plugin for sharing a snippet from Qt Creator itself, it can be also a wiki with a special category called "snippets" or something similar where users can post such code, and I am willing to have such support on Qt Creator.

    Maybe I will write a plugin once I have a web service API exposed :D[/quote]

    I really like the idea, particularly the integration into Qt Creator. I have made it a feature request for future versions since it will need both coding and legal work.

    Maybe we can use the pastebin for now and link to the snippets on a wiki page so they don't get lost?



  • [quote author="Alexandra Leisse" date="1273235820"][quote author="Milot Shala" date="1273218610"][quote author="Henrik Hartz" date="1273215603"]Why not use http://qt.pastebin.com/ ?[/quote]

    That's a good idea, but users cannot register and maintain their own code snippets and users are not able to see/use other users' code, it's not that convenient, it would be better to have something built-in right here in the developer network and as well have a Qt Creator plugin for sharing a snippet from Qt Creator itself, it can be also a wiki with a special category called "snippets" or something similar where users can post such code, and I am willing to have such support on Qt Creator.

    Maybe I will write a plugin once I have a web service API exposed :D[/quote]

    I really like the idea, particularly the integration into Qt Creator. I have made it a feature request for future versions since it will need both coding and legal work.

    Maybe we can use the pastebin for now and link to the snippets on a wiki page so they don't get lost?[/quote]

    Good to hear! Thanks Alexandra.

    As per pastebin we can do that, or it can be better if everyone can share such snippets directly on the wiki and then filter wiki contents by user, if this can be done on this system?

    IMO I think it is better to maintain such sharing on QtDN and not using third-party services such as pastebin because on pastebin every user should enter its information (some may leave the fields blank), here every user must be logged in to edit wiki, I think tracking of the changes and filtering can be easier here.



  • I know this is very old, but actually I started a project that accomplishes that:
    https://github.com/cybercatalyst/qt-pods



  • I know this is very old, but actually I started a project that accomplishes that:
    https://github.com/cybercatalyst/qt-pods



  • Great idea, but I think it is necessary some support from Qt Project to organize the code and get an easy access to these snippets.



  • Great idea, but I think it is necessary some support from Qt Project to organize the code and get an easy access to these snippets.



  • The idea is to have it organized in repositories. The graphical tool qt-pods (there will be a command line version in the future) loads a list from your defined sources, then offers packages for install. You just click on them and they install to your projects. The same way you remove them.

    What happens is that they get added as git submodules and are woven together via a single .pri that is the single thing you need to include to you project. Then you can start using them! It's very easy, but it needs more people to come together, reformat the code and spread the word.



  • The idea is to have it organized in repositories. The graphical tool qt-pods (there will be a command line version in the future) loads a list from your defined sources, then offers packages for install. You just click on them and they install to your projects. The same way you remove them.

    What happens is that they get added as git submodules and are woven together via a single .pri that is the single thing you need to include to you project. Then you can start using them! It's very easy, but it needs more people to come together, reformat the code and spread the word.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.