Template in Programming & Comp Sci forum

  • Suggestion
  • Thread starter jhae2.718
  • Start date
In summary, the idea of having a template for the programming and comp. sci. forum not unlike Homework Help is a good one. Code tags would help make code more readable, and encouraging their use would help. However, there are problems with formatting posts without proper indentation, and with posts that lack any sense of logic.
  • #1
jhae2.718
Gold Member
1,184
20
I was thinking that it might not be a bad idea to have a template for the programming and comp. sci. forum not unlike Homework Help.

Basically, something like:
Code:
If you have example code, please place it inside code tags...

That way there might actually be readable code posted, as no one seems to know about code tags.
 
Physics news on Phys.org
  • #2
I do like this idea. Particularly after one of the last ones with a huge block of unindented code. What a lovely read that was.

(Big thanks to Mark44 who re-wrote it with tags and indents.)
 
  • #3
Tangential to this: is there any way to allow for tab characters? White space, and proper indenting make code readable. I have to open up Notepad, type a tab character, and then copy and paste it in code here.
 
  • #4
JaredJames said:
I do like this idea. Particularly after one of the last ones with a huge block of unindented code. What a lovely read that was.

(Big thanks to Mark44 who re-wrote it with tags and indents.)
I have a hard time trying to discern the logic (or lack thereof) when code is poorly or not indented. Sometimes I'll go in and indent it to help me understand what the OP is trying to do, and to help other readers.
 
  • #5
Mark44 said:
I have a hard time trying to discern the logic (or lack thereof) when code is poorly or not indented. Sometimes I'll go in and indent it to help me understand what the OP is trying to do, and to help other readers.

The majority of stuff I do now is with Python, so when not indented it's impossible to see what goes where (as I'm sure you're aware).

So when a thread pops up without proper formatting, I usually just give up on the code if I can't see it clearly with a quick skim through.
 
  • #6
JaredJames said:
The majority of stuff I do now is with Python, so when not indented it's impossible to see what goes where (as I'm sure you're aware).

So when a thread pops up without proper formatting, I usually just give up on the code if I can't see it clearly with a quick skim through.

For Python cases, if I'm in a good mood I'll quote the post with the code, and then throw it in code tags, which can usually recover the indentation.

There's certainly no lack of unclear posts, though. Sometimes I get the feeling that the posters don't even indent their source code. :eek:
 
  • #7
jhae2.718 said:
There's certainly no lack of unclear posts, though. Sometimes I get the feeling that the posters don't even indent their source code. :eek:

Some of the worst, IMO, is Awful Fortran Code, with no indenting, and lots of incomprehensible variable names such as rtlxgn and the like.
 
  • #8
Would anyone be interested in a tool that you could paste source code into and have it formatted for BBCode (e.g. syntax highlighting)? I was thinking that might be a fun summer project.
 
  • #9
jhae2.718 said:
Would anyone be interested in a tool that you could paste source code into and have it formatted for BBCode (e.g. syntax highlighting)? I was thinking that might be a fun summer project.

As long as the words "open source" are there somewhere, it sounds great!
 
  • #10
But of course! (Right now I'm thinking of Python/wx and using XML to define syntax files.)

Note that this will be a spare time thing, and right now I have very little spare time.
 
  • #11
jhae2.718 said:
But of course! (Right now I'm thinking of Python/wx and using XML to define syntax files.)

Note that this will be a spare time thing, and right now I have very little spare time.

Join the club.
 
  • #12
MATLABdude said:
Tangential to this: is there any way to allow for tab characters? White space, and proper indenting make code readable. I have to open up Notepad, type a tab character, and then copy and paste it in code here.
The problem is the browser(s). Rather than allowing you to type a tab, they use tab to cycle through inputs sources on the page. (A "feature" I never use.) To get the above tab, I hit tab in a text editor, and copied and pasted it here.

As for encouraging code tag usage, try something like what C Programming.com does; see the first announcement?

Maybe a sticky with a title like "USE CODE TAGS, OR I'LL COME TO YO' HOUSE AND KICK YOU IN YO' TEETH!" would attract attention.
 

Related to Template in Programming & Comp Sci forum

1. What is a template in programming?

A template in programming is a reusable piece of code that serves as a framework for creating similar functions or classes. It allows for easier and more efficient coding by providing a pre-defined structure that can be customized for different purposes.

2. How do templates work in programming?

Templates in programming work by using placeholder values that can be replaced with specific data when the code is executed. This allows for flexibility and variability in the output of the code, making it more versatile and adaptable for different use cases.

3. What are the benefits of using templates in programming?

There are several benefits to using templates in programming, including increased efficiency, easier maintenance and updates, and improved code organization and readability. Templates also allow for code reusability, reducing the need for writing repetitive code.

4. Are templates used in all programming languages?

No, not all programming languages support templates. Some languages, such as C and Java, have their own alternatives to templates, such as macros and generics. However, many popular programming languages, such as C++, Python, and PHP, have built-in support for templates.

5. Can templates be used for both front-end and back-end development?

Yes, templates can be used for both front-end and back-end development. In front-end development, templates are often used for creating dynamic web pages, while in back-end development, templates are commonly used for generating reports or documents with variable data.

Similar threads

Replies
8
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
3
Views
534
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
1K
  • Programming and Computer Science
Replies
4
Views
797
  • Programming and Computer Science
Replies
4
Views
791
  • Computing and Technology
Replies
3
Views
2K
Replies
15
Views
5K
  • Feedback and Announcements
Replies
1
Views
2K
Replies
63
Views
3K
  • STEM Academic Advising
Replies
14
Views
1K
Back
Top