[Fabricio Rocha] - 13 Jun 2009 - Maybe you want to keep track of your expenses in a way that GnuCash can't help you. Maybe you have an apparently great idea for something that could be done on your PC but it seems that nobody thought the same before. You can imagine the interface, the dialogs. You can even imagine how nice your program would be, what other people would think of it, what about a website... In other words: you want to create a new software. You know a little bit of Tcl/Tk and you feel it is the best tool for moving your ideas from your mind to reality. But... how to do it? Where to start? Is there a library that could help? How to use it? How to organize your code? Can you draw your own icons or would you like to find some for free? How could the interface look better? Which procedures to write first? How can you take advantage of some Tcl peculiarities? How can you leave room for future versions, how to avoid a crash if your program reaches something that you don't want to implement immediately? There is a bunch of questions that fill your head when you feel the bite of the programming bug, but it is not so easy to find answers for them, and even professional programmers sometimes find themselves in doubts. There is a good number of coding standards guides, but much less information about software architecture and design, and the documents in this category are mostly driven to company-sized development, big databases, etc; not to the lone programmer which wants to create a little desktop or mobile application. I propose this page in the hope that more experienced Tclers can teach and discuss with newbies and intermediate users which practices they use when creating new apps, what must be avoided, how to create good interfaces, how to keep focus on the important things, and so on. I admit I have some big struggles with some of these topics, and I believe that lots of newbies in programming find themselves doing the same questions. It should not become a coding guide like how-to-name-your-variables, nor a bunch of copied-and-pasted procs; but a more generic guide on how to go from an idea to a running software -- something which might be applied to most programming languages, but here with some special Tcl/Tk sauce. Far from being the definite cake recipe; but a good way to start. ---- **Developing and polishing the idea** ''So, when the light shines on your head, what do you do first? How to improve the idea? Do you prefer to start coding right after, or look for a similar software before trying?'' [Fabricio Rocha] 14-Jun-2009 - When a new idea comes to my mind, I like to write it down like explaining to myself what the program should do, which should be the highlights and special features in a user's view, etc. Then the concept seems to get more organized naturally, and soon some more ideas and implementation details come. I don't know if this is really a good thing, because I feel I spend lots of time writing and planning before actually doing code; but there is a lot of people which says that planning is never lost time. I also like to search for a piece of software which does what I am trying to create; if there is, I don't see much sense in redoing the same thing. ---- **The interface** ''Is it useful to create interface mockups? On paper, on a prototyping software, in Tcl/Tk itself? What must be observed in the interface design?'' ***Interface mock-ups*** [Fabricio Rocha] 13 Jun 2009 - [Paper prototyping] is the first thing I use when thinking about an interface. This technique can be very complex, but in my simple version I just get a notepad, a pencil, draw an empty window and start drawing widgets and writing tiny letters on them. Sometimes I draw some different versions of the same window or dialog and actually "seeing" it, even with all the imperfections of the drawing, really helps a lot. I know there is a good number of people who uses Tcl/Tk itself for prototyping, and then it becomes a matter of adding backstage functionality later; but I'm still not at this stage. I really miss a visual interface designer for Tk ([Visual Tcl] is quite outdated); I have already used Glade a lot for creating interface mockups which later could be used in the program. I have also tried some free prototyping software (the Pencil project [http://www.evolus.vn/Pencil/] looked very interesting) but I still could not find a convinceable one. ***Interface standards*** Developers are almost always encouraged to adhere to interface standards for their specific platforms, unless they really believe that their ideas for an interface are a differential or better than those standards (and they really know what they are doing). While those standards are a kind of limit to creativity, they generally ensure that your software will be rapidly understood by new users, and so they will allow the user to concentrate in what the software does, not in how to make it do it. Tcl/Tk is notoriously cross-platform and, in spite of all the efforts to make it look native in all the supported platforms, it does not always look native, and this makes things harder for the developers, specially when they are not writing software which will run on one only platform. Also, ([Fabricio Rocha] - AFAIK) there is not something like a [Tk Interfaces Guide] in the shape of the [GNOME Human Interface Guidelines] and others. This also makes it hard to make suggestions on "do's and don't"s in interface design with Tk, specially because the subject always seem to create a lot of controversy; but I ([Fabricio Rocha]) would try these: ****Good:**** * '''Resizeable windows and frames''' - Some types of applications simply require a lot of screen space and you just can't make the main window simpler or smaller, but it is not good to imagine that nowadays everyone owns 1024x780 or larger monitors in which all your toplevels will fit -- specially because the so-called netbooks with smaller screens are becoming highly popular. It is always better when then whole main window (and also dialogs, which are often forgotten) can fit any screen with all its widgets visible; and if this is not possible all the widgets should be at least accessible (it is irritating when parts of the screen simply can't be seen). Tk offers the [scrollbar] and [panedwindow] widgets, which can be used for allowing the user to choose visible parts of the screen and to resize them as convenient. ****Bad:***** * '''MDI''', shorthand for [Multiple Documents Interface]. It became widely famous as the way that [Microsoft Word] used to display various documents in one window, by creating windows that looked like toplevels inside one single window. [MDI] has been greatly discouraged, but it still has fans. The most common alternative is to use a notebook widget (like [ttk::notebook]) for opening and showing the various documents. * '''Notebooks for preferences dialogs''' - Options in softwares are often grouped in one single dialog window, under different tabs of anotebook widget. This is ok if there are not many pages of options, but the interface can look clumsy when the number of tabs becomes higher. In such cases, a [treeview] or a [listbox] widget can list the groups of available options, alongside the main area of the dialog where the different pages are shown. ---- **What to consider before starting to code** ''Try to find if there is something like the software you want to create? Try to find libraries which might be used?'' ---- **Useful tools for Tclers** This is a very common question which got a page for itself in the Tclers Wiki: [are there tools which are required or would be useful when developing in Tcl]? [Fabricio Rocha] - 14-Jun-2009 - As many programming languages, Tcl/Tk does not really need anything more than a text editor, and the most seasoned Tclers seem to be very happy with Vi or emacs. I use [Komodo Edit] because of its autocompletion tips, which are really helpful when you don't have a pocket reference guide. An up-to-date GUI design tool, as I said previously, would be greatly appreciated (I am trying to create one, but it's still too far from being eligible for discussion). Debugging could be useful as well. I have tried to use [RamDebugger] but it didn't work. But so far the simple use of [puts] for checking variables in strategic code locations has been sufficient. ---- **Files and directories** ''Split the code in multiple files... or not?'' ---- **Development tips** ''Copy procedure names on paper? Run again whenever a new procedure is added?'' ---- **Coding standards** There are some pages in the Wiki which go into details about programming style in the sense of making the code more readable and easy to maintain: [Tcl Style Guide] [Tips for writing quality software] ---- **Using other people's code** ''Where to find useful code? How will the use of third-party libraries affect your coding? Do you have to tell the authors? How to distribute libraries with your software?'' ---- **Documentation and website** ''Which kind of documentation is needed and expected by users? How detailed must it be? Write these docs during development or just before the initial release? How to know if a website is needed, and when to create it? ---- !!!!!! %| Category Tutorial | Category Development | Category Concept |% !!!!!!