meta data for this page
Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Last revision Both sides next revision | ||
courses:ct30a5000:generic_instructions_and_requirements [2009/09/29 15:56] julaakko |
courses:ct30a5000:generic_instructions_and_requirements [2012/08/20 19:22] julaakko |
||
---|---|---|---|
Line 1: | Line 1: | ||
Network programming [[https://noppa.lut.fi/noppa/opintojakso/ct30a5000/etusivu|@ Noppa]] | [[courses:ct30a5000:start|@ wiki]] - | Network programming [[https://noppa.lut.fi/noppa/opintojakso/ct30a5000/etusivu|@ Noppa]] | [[courses:ct30a5000:start|@ wiki]] - | ||
- | Updated: --- //[[jussi.laakkonen@lut.fi|julaakko]] 2009/09/29 15:22// | + | Updated: --- //[[jussi.laakkonen@lut.fi|Jussi Laakkonen]] 2012/08/20 17:38// |
---- | ---- | ||
+ | |||
+ | Updates: | ||
+ | > 16.9.2011: Added clarification for README file | ||
+ | |||
====== Generic instructions and requirements ====== | ====== Generic instructions and requirements ====== | ||
* INDIVIDUAL WORK – **NO COPYING** – NO GROUPWORK (discuss but do not share code) | * INDIVIDUAL WORK – **NO COPYING** – NO GROUPWORK (discuss but do not share code) | ||
- | * Except Assignment 1 - [[:courses:ct30a5000:assignment1|see the assignment description.]] | + | * If you're caught copying directly from others or from Internet/books your grade is 0. |
- | * Use **C-language** and **GCC compiler** | + | * Remember the difference between plagiarism and adaptation. |
+ | * Use **C-language** and **GCC compiler** (see //man gcc//) | ||
* Eliminate warning-messages (use ''-Wall'' for ''gcc'') | * Eliminate warning-messages (use ''-Wall'' for ''gcc'') | ||
- | * <del>Follow ANSI standard (C89/90 = ''-ansi'', C99 = ''-std=c99'' for ''gcc'')</del> | + | * Try to follow coding standards (''-ansi'' **is not required**), use extended C99 standard: GNU99: ''-std=gnu99''. |
- | + | * Program can be **run in Linux** (on [[admin:pentinkulma|computers in classroom 6218]]) | |
- | > **Since some new network address structures and functions aren't yet added to ANSI standard, this requirement is removed.** | + | * Do not use external libraries (use only system libraries, all required should be installed into classroom 6218 machines) |
- | + | * Use iterative approach (__no threads or fork()__ unless requested) | |
- | * Program can be **run in Linux** (on [[admin:pentinkulma|computers in classroom 6325]]) | + | * **Graphical user interface __IS NOT REQUIRED__, NOR RECOMMENDED** |
- | * Do not use external libraries (use only system libraries) | + | |
- | * Use iterative approach (no threads unless requested) | + | |
* Use a **make file** (see //man make// or use a [[http://www2.it.lut.fi/courses/CT30A5000/material/Makefile|Makefile template]]) | * Use a **make file** (see //man make// or use a [[http://www2.it.lut.fi/courses/CT30A5000/material/Makefile|Makefile template]]) | ||
* Compile: make build | * Compile: make build | ||
Line 20: | Line 23: | ||
* **Comment** and **document** your code | * **Comment** and **document** your code | ||
* Comments directly to source code files | * Comments directly to source code files | ||
- | * Add name, student number and email into beginning of **EVERY** file. | + | * Add name, student number and email into the beginning of **EVERY** file. |
+ | * All documentation either in __English__ or in __Finnish__ | ||
* Use **good structure** for your code | * Use **good structure** for your code | ||
* Divide code to functions based on responsibilities. | * Divide code to functions based on responsibilities. | ||
Line 26: | Line 30: | ||
* C-code in .c files and header descriptions in .h files. | * C-code in .c files and header descriptions in .h files. | ||
* **ONE MAIN FUNCTION IS NOT GOOD STRUCTURING OF CODE** ! | * **ONE MAIN FUNCTION IS NOT GOOD STRUCTURING OF CODE** ! | ||
- | * **!!!!!!! NO GOTO !!!!!!!** People it is the year 2009, we're not anymore living in the 80s! | + | * **!!!!!!! NO GOTO STRUCTURES !!!!!!!** |
- | * See [[courses:ct30a5000:generic_instructions_and_requirements#using_multiple_files|short example about how to use multiple files]] | + | * See [[courses:ct30a5000:generic_instructions_and_requirements#using_multiple_files|short example about how to use multiple files]]. |
- | * Write a **readme file**, which contains: | + | * Write a **readme file**, **AS PLAIN TEXT, !__NO DOC/ODT/PDF/__!, **which contains: |
* How to run the program. **Follow the given instructions on __every__ assignment** | * How to run the program. **Follow the given instructions on __every__ assignment** | ||
- | * Description of the task (what has been done, __what references used__) | + | * Description of the task (what has been done) |
+ | * List what **references were used** (books, Internet pages/tutorials, etc.) | ||
* Features that were implemented | * Features that were implemented | ||
- | * Description of division of code to separate files | + | * Description of division of code into separate files |
- | * Own ides (text) or solutions (code) for improving the task | + | * Own ideas (text) or solutions (code) for improving the task |
* __Own improvements must clearly be a new feature__, i.e. separate feature that enhances functionalities of the application. | * __Own improvements must clearly be a new feature__, i.e. separate feature that enhances functionalities of the application. | ||
* __Must be documented__! No documentation about own feature(s) → no additional points | * __Must be documented__! No documentation about own feature(s) → no additional points | ||
Line 39: | Line 44: | ||
* Debug with GDB (see //man gdb//) | * Debug with GDB (see //man gdb//) | ||
* Check that there are **no memory leaks** (use Valgrind, see //man valgrind//) | * Check that there are **no memory leaks** (use Valgrind, see //man valgrind//) | ||
- | * **REMEMBER TO __CLOSE__ SOCKETS** | + | * **REMEMBER TO __CLOSE__ SOCKETS when they're not used** |
- | * **Free** what you have allocated | + | * **Free** the memory that was allocated. |
===== Using Multiple files ===== | ===== Using Multiple files ===== | ||
Files: | Files: | ||
- | * main.c - main file, contains main() and run()-functions. | + | * main.c - main file, contains implementations of main() and run()-functions. |
- | <code c> | + | <code c main.c> |
#include "main.h" | #include "main.h" | ||
int main(int argc, char *argv[]) | int main(int argc, char *argv[]) | ||
{ | { | ||
- | printf("Main"); | + | printf("Main\n"); |
run(argc); | run(argc); | ||
Line 60: | Line 65: | ||
void run(int _type) | void run(int _type) | ||
{ | { | ||
- | check(_type); | + | if(check(_type) < 0) printf("Error\n"); |
+ | else printf("Success\n"); | ||
} | } | ||
</code> | </code> | ||
Line 66: | Line 72: | ||
* main.h - header for main.c, contains prototype for ''run()''-function. | * main.h - header for main.c, contains prototype for ''run()''-function. | ||
- | <code c> | + | <code c main.h> |
- | #include <stdin.h> | + | #include <stdio.h> |
void run(); | void run(); | ||
</code> | </code> | ||
- | * file.c - additional file, contains check()-function. | + | * file.c - additional file, contains implementation of check()-function. |
- | <code c> | + | <code c file.c> |
#include "file.h" | #include "file.h" | ||
Line 84: | Line 90: | ||
* file.h - header for file.c, contains prototype for ''check()''-function. | * file.h - header for file.c, contains prototype for ''check()''-function. | ||
- | <code c> | + | <code c file.h> |
#define RIGHT 0 | #define RIGHT 0 | ||
Line 92: | Line 98: | ||
To use the function defined in file.h and implemented in file.c in the main.c following steps are needed: | To use the function defined in file.h and implemented in file.c in the main.c following steps are needed: | ||
- | - Include the file.h in main.c <code c>#include "file.h"</code> | + | - Include the file.h in main.c (or in main.h) |
+ | * main.c after modifications:<code c main_mod.c> | ||
+ | #include "main.h" | ||
+ | #include "file.h | ||
+ | |||
+ | int main(int argc, char *argv[]) | ||
+ | { | ||
+ | printf("Main\n"); | ||
+ | |||
+ | run(argc); | ||
+ | |||
+ | return 0; | ||
+ | } | ||
+ | |||
+ | void run(int _type) | ||
+ | { | ||
+ | if(check(_type) < 0) printf("Error\n"); | ||
+ | else printf("Success\n"); | ||
+ | } | ||
+ | </code> | ||
* After this the compiler and linker can find the function ''check()'' used in ''run()'' since it is defined in one of the headers included. | * After this the compiler and linker can find the function ''check()'' used in ''run()'' since it is defined in one of the headers included. | ||
- Add file.c into the Makefile of the application as source (remember to separate multiple files with spaces), in this case <code>SOURCES=main.c file.c</code> | - Add file.c into the Makefile of the application as source (remember to separate multiple files with spaces), in this case <code>SOURCES=main.c file.c</code> | ||