Help:Contents

From CompSciWiki
Jump to: navigation, search

Link to WikiMarkup Page

http://en.wikipedia.org/wiki/Help:Wiki_markup

Using Templates

All pages in the COMP 1010 wiki are based on one of these templates:

  • 1010Chapter - used for the chapter pages which summarize the chapter and list the chapter topic; should have an image of U of M campus in parameter Picture
    • Parameters: ChapterNum, Picture, Introduction, Body, PChapterNum, PChapterLink, NChapterNum, NChapterLink
  • 1010Topic - describe the topic, often includes code and output examples
    • Parameters: Chapter, Previous, Next, Body
  • 1010PrAd - Used for Program-A-Day pages, should have either an image or a "by students..." section in parameter SideSection
    • Parameters: ProblemName, Problem, SideSectionTitle, SideSection, Solution
  • 1010CaseStudy - Used for Case Study pages, should have an image of a student performing task related to case study in parameter SideSection
    • Parameters: ProblemName, Problem, SideSectionTitle, SideSection, Solution
  • 1010ExtraLabs - Used for ExtraLabs. Should have a drawing or image associated with lab.
    • Parameters: Introduction, Body

Also, each page my use two nested templates:

For example, here is an example using an abbreviated version of the topic String Methods:

{{1010Topic 
|Chapter_TOC=[[Calling Methods]]
|Previous=[[Calling Methods]]
|Next=[[Math Methods]]
|Body=

==Introduction==
You will learn how to use simple String Methods such as comparing Strings and finding the length of a String. String is just another toolbox and its methods are the tools to simplify work related to Strings.

==String Methods==

===<code>equals</code>===

In the beginning of the Java programming learning process, you have learned that the equal sign "==" determines equality of [[Common Primitive Variables|primitive types]] (eg. int, double, char). However, the equals() method is needed to find the equality of two Strings. This method compares two Strings and returns a boolean result <font color="red">(true or false)</font>. True, if they are the same string and false, if they differ in any way. Think of it as a method that is applied to a String to see if it equals another. This method is required for Strings because the ''''='''' symbol is used for assignment purposes. Example:

====Code====
{{CodeBlock
|Code=
public class testStrings
{
	public static void main(String args[])
	{
		String testString;
		testString = "I am test";

		System.out.println("String equals I am test");	
		
	}
}
}}

Output

{{OutputBlock
|Code=
String equals I am test
}}

==Summary==
In this section, you have learned how to make use of  <code>equals</code>. 
}}

To edit a template, type in the name of the template prefaced with Template. Eg: https://wiki1010.cs.umanitoba.ca/mediawiki/index.php/Template:1010ExtraLabs

Add a new video to the COMP 1010 Youtube Video Channel

New in Winter 2012! We now have a COMP 1010 Youtube Video Channel. All videos on the channel should have the same look and feel. Here are the COMP 1010 Video Standards.

Create a New Page

Categories

Articles on Wikis are typically divided into categories. These categories appear in a list at the bottom of the article, and serve as an easy way to group articles about similar topics together.

When creating or modifying a page the editor should ensure that the categories are properly listed. To do this use the following code:

[[Category:Category Name]]

For example, the following code should be used in all articles that apply to material covered in Comp 1010:

[[Category:COMP 1010]]

A single article can belong to multiple categories by listing each category. For example, the following categories should be used on a page with sample questions for COMP 1010 students about Java:

[[Category:COMP 1010]]
[[Category:Java]]
[[Category:Sample Questions]]
Categories should be listed at the end of the article, after references. The Wikipedia article on Fruit is a good example of the use of
categories.

For the purposes of a Computer Science Wiki the following categories have been defined:

  • COMP 1010: all articles that contain information relevant to the COMP 1010 course should be included in this category
  • Java: all articles about Java syntax, functions, etc..., as well as sample programmes should be included in this category
  • Sample Questions: articles containing sample questions for students to work on should be in this category
  • Solutions: articles with the solutions to the sample questions belong in this category

Format Text

Headings

Articles can be divided into a number of headings and sub-headings. Typically these headings should be used to divide information into easy-to-find sections; every heading is automatically placed in the contents section of the article.

Headings can be nested up to five layers deep. Unless absolutely necessary headings should not be nested more than three layers deep; adding depth makes the table of contents more complicated and harder to read.

Use the following code to generage headings of different levels:

==Links==
===Basic Links===
Basic linking in a Wiki is easy.
To create a link to a page on the wiki such as the [[community portal]]:

<pre>
[[community portal]]

Capitalization is unnecessary, the first letter of the link is internally capitalized automatically.

Notice that clicking on the link opens up an edit page and not a viewing page. Clicking on a link within a wiki page to a page that does not exist automatically opens up the editor for you to add content to the page.

Anchor Links

To link to another section on the current page like #Format Text:

[[#Format Text]]

To link to an anchor placed somewhere on the page such as this #example:

[[#example]]

To create such an anchor:

<div id="example">whatever you want your anchor text to be
</div>

Click on the example to see where the anchor is hidden!

Using [[Some label]] without linking

In order to disable the linking fuctionality(in addition to other functionalities), surround the text you want to nullify with <nowiki></nowiki> tags.

Anchor Link on a different page

In order to link to an achor or heading on a different page in the same wiki, use the [[NewPage#Anchor]] syntax. What this would do is link you to the "Anchor" anchor on the "NewPage" page. You can even use the pipe character to hide the link, such as [[NewPage#Anchor|RealTitle]]

Main Page#Getting Started

Page Redirection

To make one page automatically redirect to another page, use the #REDIRECT [[target command]]. For instance, if you wish to have the pages While and While Loop have the same content, simply have the While page redirect to the While Loop page.

#REDIRECT [[While Loops]]

Document Signing

To sign a document, forever immortalizing your user name in the eyes of first year students if you don't get edited out:

:~~~
:~~~~
:~~~~~

3 squiggles give your name.

Umdrysd6

4 squiggles give your name and the date and time.

Umdrysd6 22:15, 7 February 2007 (CST)

5 squiggles give just the date.

22:15, 7 February 2007 (CST)

Note that your name is the only link and links to your user page.

(Please respect the term "squiggle". It is far superior to the overly technical "tilda".)


Links

External Links

There are two accepted ways to link to external sources. To link a URL with a name for the page: CS Courses nTreePoint Server:

[http://courses.cs.umanitoba.ca CS Courses nTreePoint Server]

To create a numbered link for a footnote in an article body:

[http://courses.cs.umanitoba.ca/]


Internal Links

Linking to another page in the same Wiki is very easy. To create a link to a page on the wiki such as the Computer Science Courses page:

[[Computer Science Courses]]

Capitalization is unnecessary, the first letter of the link is internally capitalized automatically.

Notice that clicking on the link opens up an edit page and not a viewing page. Clicking on a link within a wiki page to a page that does not exist automatically opens up the editor for you to add content to the page.

Anchor Links

To link to another section on the current page like #Format Text:

[[#Format Text]]

To link to an anchor placed somewhere on the page such as this #example:

[[#example]]

To create such an anchor:

<div id="example">whatever you want your anchor text to be
</div>

Click on the example to see where the anchor is hidden!

Using [[Some label]] without linking

In order to disable the linking fuctionality(in addition to other functionalities), surround the text you want to nullify with <nowiki></nowiki> tags.

Anchor Link on a different page

In order to link to an achor or heading on a different page in the same wiki, use the [[NewPage#Anchor]] syntax. What this would do is link you to the "Anchor" anchor on the "NewPage" page. You can even use the pipe character to hide the link, such as [[NewPage#Anchor|RealTitle]]

Main Page#Getting Started

Page Redirection

To make one page automatically redirect to another page, use the #REDIRECT [[target command]]. For instance, if you wish to have the pages While and While Loop have the same content, simply have the While page redirect to the While Loop page.

#REDIRECT [[While Loops]]

Document Signing

To sign a document, forever immortalizing your user name in the eyes of first year students if you don't get edited out:

:~~~
:~~~~
:~~~~~

3 squiggles give your name.

Umdrysd6

4 squiggles give your name and the date and time.

Umdrysd6 22:15, 7 February 2007 (CST)

5 squiggles give just the date.

22:15, 7 February 2007 (CST)

Note that your name is the only link and links to your user page.

There are two accepted ways to link to external sources. To link a URL with a name for the page: CS Courses nTreePoint Server:

[http://courses.cs.umanitoba.ca CS Courses nTreePoint Server]

To create a numbered link for a footnote in an article body:

[http://courses.cs.umanitoba.ca/]

Please respect the term "squiggle". It is far superior to the overly technical "tilda".

Tables

Wiki tables are a way of communicating tabular data, such as spreadsheets or lists of items that each have subitems in common. They should be used only when it would be inappropriate or cumbersome to present such information something such as a list. Tables consist of several parts, including rows and columns, an optional caption, and a border. Tables are defined one row at a time, each containing several cells that occur in that row. Additional constructions can be added to a table to help present information, such as row and column headers. These sections demonstrate the usage of MediaWiki's table syntax.

Basic Syntax

{|
|+My First Table
  |-
    |Cell One
    |Cell Two
  |-
    |Cell Three
    |Cell Four
|}

This defines a basic table (delimited by {| ... |}) with a caption of "My First Table", containing two rows (signified by |-), each with two cells (signified by a vertical pipe: |). Note that the spacing used in the example is not necessary, and is merely for illustrative purposes. The only requirement is that the individual cells start on a new line. However, one may optionally use a double vertical pipe to start a new cell without creating a new line.

The result will look like this:

My First Table
Cell One Cell Two
Cell Three Cell Four

Formatting Syntax

Once you have the basic structure of the table created, adding optional formatting and a caption may help communicate the information in the table. The easiest way to introduce formatting is to use a style attribute (taken from HTML, where an attribute is written as a string with an equals sign, followed by double-quote-delimited content) following the character(s) that signify a table, row or cell. Cell formatting takes precedence over row and table formatting, while row formatting takes precedence over just the table. This example demonstrates the usage of various styling options for a table:

{|style="background-color: green; color: red; font-size: small; font-family: serif"
  |-style="background-color: yellow; color: green"
    |style="background-color: blue; color: white"|Blue on white
    |The remainder of the cells in this row...
    |... get yellow on green
  |-
    |The rest of the table...
    |... gets red on green.
|}

This example is displayed as follows:

Blue on white The remainder of the cells in this row... ... get yellow on green
The rest of the table... ... gets red on green.

Border Syntax

Tables have borders... etc (todo)

Additional Table Structure

While rows and cells with a caption can express most information, it is possible to build additional information into tables if necessary. For example, table column headers can be added after the caption, denoted by a single exclamation mark on its own line. Just like cells, you can avoid using separate lines for each header if you double up the exclamation points:

{|
|+Table With Column Headers
!Fruits
!Vegetables
  |-
    |Apple
    |Carrot
  |-
    |Banana
    |Lettuce
|}

This results in headers that appear as such:

Table With Column Headers
Fruits Vegetables
Apple Carrot
Banana Lettuce

Table row headers can be added with exclamation points as well, but this time occuring after the row signifier (the |-):

{|
|+Table With Column Headers
!Color\Class
!Fruits
!Vegetables
  |-
  !Red
    |Apple
    |Radish
  |-
  !Yellow
    |Banana
    |Corn
|}

Note the inclusion of a new column header. This header is used for the column created by the row headers on the left. So, this wiki code presents information with rows and columns labeled thusly:

Table With Column Headers
Color\Class Fruits Vegetables
Red Apple Radish
Yellow Banana Corn

Images

Inserting

This wiki cannot link to any external images. All images MUST be uploaded via the wiki.

To upload an image go to:
left navigation bar > toolbox > special pages > upload file
To view the name of your image file go to:
left navigation bar > toolbox > special pages > file list


NOTE: Uploading is currently disabled on this wiki, so you won't be able to post an image until it is enabled.


Basic syntax for inserting an image
[[Image:myPhoto.jpg]]
myPhoto.jpg would be your specific image file which you would like to insert

Alternatively, as a short cut, once you know the name of your image you can use the editing toolbar to help you remember the syntax.

Pressing the picture in the editing toolbar inserts [[Image:Example.jpg]] at the current cursor position.

Captions

Inserting a caption to an image is a simple addition to Inserting an Image

Syntax for inserting an image caption
[[Image:myImage.jpg|frame|My Caption Text]]
  • myPhoto.jpg would be your specific image file which you would like to insert
  • frame floats the image to the right side of the page
  • My Caption Text would be your desired caption

Sidebars

Creating Sidebars

Sidebars are normally created during the creation of a wiki. Administrators and users with the required permissions are the only ones allowed to edit them. The sidebar may be accessed through the MediaWiki:Sidebar page. To access this page, enter "MediaWiki:Sidebar" into the "search" box and click on the Go button.

When to use Sidebars

Sidebars are used to display the most important locations in a wiki. They allow quick page access for administrators and users alike. Some examples include a link to the main page, the help page, or a forum.


Code

Formatting Code

Code should be placed in pre-formatted text HTML tags: <pre>...</pre>. This will place code in a dashed box and preserve all whitespace/indentation. For example:

public class Sample
{
    public static void main(String[] args)
    {
        System.out.println("This is a sample");
        System.exit(0);
    }
}

Coding Standards

The following coding standards are based on those required for student assignments submitted in COMP 1010.


Comments

With the exception of main, every method should begin with a comment block that describes:

  • The purpose of the method
  • The parameters received by the method and what each one is used/needed for
  • What, if any, value will be returned by the method and what the returned value means


Variable Declarations

All variables used in a function should be declared at the beginning of the function. The exception to this rule is that loop-counters that are used exclusively in one loop may be declared within the loop:

for (int i=0; i<inputString.length(); i++)
     System.out.println(inputString.charAt(i));


Naming Conventions

Ensure that the names for variables are short and meaningful. An acceptable name for a list of student names would be studentNames, whereas s (not meaningful) or namesOfTheStudents (too long) are bad examples.

The following rules should be used when assigning names to variables, classes, functions, and the like:

  • constants: all upper-case with words separated by underscores, name should be a noun (i.e. final char NEW_LINE = '\n')
  • primitives: begin with a lower-case letter, name should be a noun (i.e. int largestValue)
  • object references: same conventions as primitives (i.e. String userName)
  • classes: begin with upper-case letter, name should be a noun (i.e. class BankMachine)
  • functions/methods: begin with lower-case letter, name should be a verb (i.e. void sortList())


Braces, Whitespace, and Indentation

Use whitespace liberally; it improves the readability of your code. Effective places for whitespace are between:

  • Methods
  • Classes
  • Loops
  • Blocks of related code

Code contained within loops, if-statements, switch statements, and any other formal code structure should be indented with four spaces. Braces should be in line with the outside of the structure, on their own lines. Closing braces should be commented to indicate what they are closing. If a loop or other structure contains only one line of code this line should be indented, but no braces are used.

Here is an example of badly-formatted code:

public class BadFormatting{                                   //brace not on its own line

    public static int sumList(int[] array)
        {                                                     //brace indented wrongly
        int totalSum = 0;
        for(int i=0; i<array.length; i++) totalSum+=array[i]; //the code performed by the loop should be on the next line
        return totalSum;
}}                                                            //closing-braces are not on their own lines, and are not commented

Conversely here is an example of properly-formatted code:

public class ProperFormatting
{                                                 //note brace on its own line

    public static int sumList(int[] array)        //this line has been indented 4 spaces
    {                                             //again, brace on its own line
        int totalSum = 0;                         //this line is indented another 4 spaces from the containing structure

        for(int i=0; i<array.length; i++)
            totalSum+=array[i];                   //single-line if statements and loops do not use braces

        return totalSum;
    }//sumList                                    //put a comment saying what the brace is closing
}//ProperFormatting

Page Layout

Page layout should generally have five categories in the following order.

  1. Abstract - Overview of what the article is about. Should describe or define the topic being discussed.
  2. Contents - This should contain a list of linked items to all major and minor headings in the article.
  3. Body - The body of the article should contain all relevant information to the topic.
  4. Links - This should contain links to external or related topics for this article.
  5. References - All materials reference should have either links to source or proper citation.

All categories may not exists. As an example, there may not be any links to related or external information. Take these categories as a guideline for the order of information and not for what must be contained in the article.

Sidebars

Sidebars are a good way to give quick notes on a topic. Avoid overuse as they can compress content to one side of the page. Usually sidebars are only used once in any given article. However, this is not a rule without exceptions. Images with need of specific subtitles such as source and a description can be put in a sidebar. This should be avoid if the image can be put inline with the rest of the article.

Dashed Box

Dashed boxes should be used to contain all code. See the above Code section for how to format code and use Dashed Boxes

A good example of the use of the Sidebar, Contents can be seen on the Wikipedia page for the Java Programing Language. Note the infrequent use of the Sidebar, but used to describe a small image, the Java mascot and to give some imperial data on the Java Programming Language. The Contents for this page is large but gives a good example of how it can be done. Try to avoid going further than three deep into any given section as this can make the Contents overly large.

Change User Options

There are many options that allow you to customize your profile and the wiki's appearance. You can access these options by clicking on "my preferences" at the top right portion of the screen.

The options are sorted into the following tabs:

User profile

Update the following:

  • real name
  • e-mail
  • nickname
  • language
  • password

If the "Remember my login on this computer" option is enabled, you will not have to login each time you visit the wiki.

Skin

This option allows you to change the style of a page display. MonoBook is the default skin. You can always see the preview of the skin style. The other skin options are Classic, Nostalgia, MySkin, Chick, Simple and Cologne Blue.

Files

  • Limit the size of images on image description pages to a specified resolution.
  • Set the size of image thumbnails.

These options are helpful if you are using a slow computer or a slow Internet connection.

Date and time

Set the date format and timezone.

To set the timezone to Central Standard Time (Manitoba time), enter -6 in the Offset box. After setting the time zone all times listed on the wiki (for example, the Recent changes and History pages) will be in Central Standard Time.

Note: When Daylight Saving Time is in effect, enter -5 in the Offset box.

Editing

Set the size of the edit window and other options related to editing.

Recent changes

Options that affect your "Recent changes" page.

The "Recent changes" page lists the most recent changes made to the wiki. You can get to this page by using the link in the navigation panel on the left side of your screen.

Watchlist

Options that affect your watchlist page.

The watchlist is similar to the "Recent changes" page but only shows pages that you have chosen to monitor. You can view your watchlist page by using the my watchlist link at the top right of your screen.

To add a page to your watchlist, click on the watch tab at the top of the page that you would like to watch. The pages that you have chosen to watch will also be bolded on the recent changes page. This will help you to quickly spot changes made to watched pages.

Search

Options that affect your search results.

Misc

Options that affect page formatting.

Discussion Minutes

The following pages are notes from class discussions about assignment 3: