Do we need a programming template?

18 posts / 0 new
Last post
walkero
walkero's picture
Offline
Last seen: 4 months 3 weeks ago
Joined: 2009-05-03 16:54
Do we need a programming template?

I would like to discuss if there is a need for a programming template. I know that there is the AVD Template from Jamie Krueger, that might be helpful. I liked to use the file structure the Emperor was producing, but I am afraid that this might be too old for now. Codebench and CubicIDE doesn't create basic files when you start a new project.

So, what I am asking is, if we should create a new template for all the new programmers, like me. This would be useful for the first steps on programming. This shouldn't cover many things, but could have a few features ready, like the "Project" menu. This should also have self commented code, which will inform users on almost each line.

If there is a template like the one I describe, please provide it here.

Rigo
Rigo's picture
Offline
Last seen: 2 years 6 months ago
Joined: 2011-01-24 21:55
It is certainly something

It is certainly something that could be added to CodeBench. Perhaps a discussion here outlining just what would be expected in these "templates" would be an idea.

Simon

cha05e90
cha05e90's picture
Offline
Last seen: 6 years 2 months ago
Joined: 2011-02-07 20:22
Oh, that's a hard one... ;-)

Oh, that's a hard one... ;-) If I think about my own first steps, I would have found something like

Screen, Window, Menu, Locale, ARexx port, Argument parsing (Shell/WB)

extremly useful. But on the other hand this might be to much for a "basic" template.

A hyper-convenient system could offer this components and the user can choose from them. Incl. some basic pre-defined (Shell program, WB program without Menu and so on...) ones.

X1000|II/G4|440ep|2000/060|2000/040|1000

jap
jap's picture
Offline
Last seen: 10 months 2 weeks ago
Joined: 2011-06-04 05:53
Templates for different kind

Templates for different kind of components and programs would be very useful. This is my template wish list:
* ANSI C program
* Shell tool (CLI program)
* WB program (GUI program)
* commodity
* docky
* library
* device
* handler
* class
* gadget
* datatype
* kickstart module (kmod)
* language driver
* country file
* USB device driver
* printer driver
* sound card driver (AHI)
* graphics card driver (Picasso96)
* network card driver
* screen blanker module

kas1e
kas1e's picture
Offline
Last seen: 4 months 1 week ago
Joined: 2010-11-30 15:30
Jap's list is quite enough

Jap's list is quite enough imho. Will cover all the necessary and aos4 specific part. Can add only to the list:
* OS3 kind template (so just adding of #define __USE_INLINE__) at top and simple example
* library different kind of templates: usuall aos4 native, + template for library.l.main, + vectors/crossstubs, etc.

But for first commodities/native-library/docky/device/handler will be already good to have

jap
jap's picture
Offline
Last seen: 10 months 2 weeks ago
Joined: 2011-06-04 05:53
Cha05e90's suggestion of

Cha05e90's suggestion of adjustable templates sounds good. To continue his list I'd like to add these optional components:

Rigo
Rigo's picture
Offline
Last seen: 2 years 6 months ago
Joined: 2011-01-24 21:55
Well, this is already

Well, this is already possible, in a roundabout sort of way. If you create a project and add the files required, that project could be saved as a "template". It's a simple matter of just loading that project, and all the files will be loaded as part of that project. Of course this does mean that someone is going to have to sit down and write the required source files...

Simon

walkero
walkero's picture
Offline
Last seen: 4 months 3 weeks ago
Joined: 2009-05-03 16:54
Re: Do we need a programming template?

What I had in mind is a basic file structure, with the basic features in it. But what you all proposed here is more than enough. Maybe a package with different example codes based on the same file structure would be great.

But first, it would be nice to start having in mind a basic structure, for example:
- main code file
- libraries files with functions to open and close the necessary libraries
- events file, with functions that are executed on mouse or key events etc.
- include file, where all the includes happen

The basic template in my opinion should have the following features:
- Open a common window, with the basic gadgets enabled, like "move Back", "Iconify" etc.
- Have a Project Menu, with "About", "Prefs" and "Close" included
- About window appear
- Inside the main window should be a few basic gadgets, like a button, a file requester and maybe a list.

The above are just an example, maybe awfully constructed. Please feel free to propose and change things here and there.

If Rigo likes the idea could use that template on "New Project" creation of Codebench.

Rigo
Rigo's picture
Offline
Last seen: 2 years 6 months ago
Joined: 2011-01-24 21:55
If Rigo likes the idea could

If Rigo likes the idea could use that template on "New Project" creation of Codebench.

Well, as I said, a "template" would simply be a project with all the files required, but missing any functionality.

You could load the "Library" template, and open the init.c file and add some libraries to open in libInit() etc...

As the templates go, they would have all the parts but just not do anything. This means that someone has got to sit down and write all these "blank" projects, so I'm not expecting much to come of it. Of course, the actual implementation would be easy, just adding an "Open Project Template" menu would be enough to allow the user to pick from any that may be stored in PROGDIR:Templates.

In actual fact, I'll add it now and see if anything comes of it :)

Simon

jap
jap's picture
Offline
Last seen: 10 months 2 weeks ago
Joined: 2011-06-04 05:53
I just wrote an ANSI C

I just wrote an ANSI C template. It parses and displays command line parameters and can print help message with option -h.

I can send it to you Rigo, if you are interested.

Rigo
Rigo's picture
Offline
Last seen: 2 years 6 months ago
Joined: 2011-01-24 21:55
Yeah, that would be great,

Yeah, that would be great, thanks

Simon

OldFart
OldFart's picture
Offline
Last seen: 4 months 2 weeks ago
Joined: 2010-11-30 14:09
This whole idea of templates

This whole idea of templates has crossed my mind a few years back. I was annoyed to say the least, that for every perceived project I had to copy-'n'-paste parts of sources from earlier projects, with all debugging to be applied before I could even start the actual intended project. To address the situation I created a directory and in it I stored a number of files (how surprising...). These files are either copied to a new project or soft-linked to. An average project has about 5 copied files and about 6 or 7 linked files.
Whenever I start a new project I call a DOS-script asking me all kinds of questions, like what the name of the project is to be, if it is a CLI-program and/or a WB-program, whether it is to open a window and whether that window is to take the entire WB-height (think of ListBrowsers) or just as much height as needed or does it require a screen of its own and hence, a window taking up the entire screen's surface. If it is a CLI-program, does it use DosArguments. If a WB-program does it use ToolTypes. And so on, and so forth. All in all quite complex at first sight, but in use it is hard to beat and I would not go without.
Some files will need to be modified to reflect the functionallity of the perceived program. These files are copied, whilst some other file are of a more generic nature and need not be modified. Those files are linked to (C:MakeLink). What is more: they are even disabled from modification so as not to modify them for a specific project as that might kill other projects that use the same file. Having a link established to these files makes maintainance really simple and all projects using that updated generic file will automatically be using the latest version when recompiled.
The benefits are more then at first sight. For instance assurance of opening a required gadgetclass is met by simply including that class's headerfile containing the prototypes. I don't know the exact name or path due to two reasons: haven't been programming for half a year or more and if I do, it is simply a matter of uncommenting or commenting out some #include lines in a project's "main.h". The same goes for libraries.
And when DosArguments are required, everything gets into place to assure a proper handling of the arguments. The argument's template is measured and the number of comma's plus one reflect the size of the array of int32's as required for storing the arguments (or addresses).

This way I have templates for a number of programs, beit CLI, WB, CLI and WB, Commodities, Libraries, Devices or any other. The moment a project is finalised and established it is compiled in order to asure a properly functioning starting point.
All project look alike with file naming schemes that are identical over all the projects. Makes maintainance easier again as it is clear in which file to look for which component.
In the process I built a number of files containing macros. I like macros as they make your source often that much better readable. The biggest macro file is the one that contains my private set of ReAction macros, which allow me to build a GUI quite fast and sure from near-standard building blocks, augmented with some specific tags when required.
One other file contains a (huge) number of functions, which are quite common for me to use. This file forms a compile-time library. Some functions it contains are funtions to Open an/or Close either Libraries and/or GadgetClasses.

I was in the process of writing an article about this when in the second half of 2012 my Micro refused to function anylonger. That situation has not yet changed, so that article is not being published any time soon.

My way of doing things may not be everybody's choice, but, hey, it works for me, but then again: I do things *MY* way...

OldFart

(typing this on a lousy laptop as doing this from a cellphone is even more of a PitA...)

Rigo
Rigo's picture
Offline
Last seen: 2 years 6 months ago
Joined: 2011-01-24 21:55
Seeing as JAP stepped up to

Seeing as JAP stepped up to the plate, I have now added the functionality in the latest version to accomodate templates, and added his ANSI C one as the first.

Once this version goes out, you will be able to add templates by simply adding them to the "Templates" drawer.

Simon

jap
jap's picture
Offline
Last seen: 10 months 2 weeks ago
Joined: 2011-06-04 05:53
Off-topic: CodeBench

Off-topic: CodeBench supporting snippets would be great. Any chance of getting that feature to CodeBench Rigo?

Rigo
Rigo's picture
Offline
Last seen: 2 years 6 months ago
Joined: 2011-01-24 21:55
It already does to a certain

It already does to a certain extent, although I'm not sure if that is available in the "free" version.

You can insert code constructs from the editor popup menu.
http://codebench.co.uk/docs/editor.html#editorpopup

Simon

jap
jap's picture
Offline
Last seen: 10 months 2 weeks ago
Joined: 2011-06-04 05:53
It's missing from the free

It's missing from the free version :-(
Is it possible to add your own code snippets in the latest CodeBench version?

Rigo
Rigo's picture
Offline
Last seen: 2 years 6 months ago
Joined: 2011-01-24 21:55
No, but it is something I

No, but it is something I plan to add. Probably not before the next public version goes out though, it's been delayed for far too long already by adding new features :/

Simon

TSK
TSK's picture
Offline
Last seen: 1 year 2 months ago
Joined: 2011-06-28 02:06
CompilerGUI on os4depot.net

CompilerGUI on os4depot.net can do small apps with a click of a button. I don't have time but it could be interesting to learn how to use CodeBench and if it supports plugins or something.

Log in or register to post comments