You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SFU Open-Source Development Club decided to utilize a documentation tool to provide valuable resources that help students who want to start learning programming and joining software projects. We will be using Docusaurus, an open-source tool made by Meta (Facebook) and will try to provide valuable tools to them. This tool will be open to everyone at Simon Fraser University. The update with our documentation will be shown in the Blog section. This idea has been suggested by Jiin Kim and deployed by Tommy Oh.
Copy file name to clipboardExpand all lines: blog/2025-01-16-purpose-of-blog-feature.md
+3-5Lines changed: 3 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,17 +1,15 @@
1
1
---
2
-
slug: welcome
2
+
slug: blog-feature
3
3
title: Purpose of blog feature
4
4
authors: [tommy]
5
5
tags: [how-to-use, docusaurus]
6
6
---
7
7
8
8
<!-- truncate -->
9
9
10
-
The SFU Open Source Development Club will use the Docusaurus Blog feature to document the responsibilities and tips of project leads and club executives. The blogs can be based on personal experience or basic knowledge.
11
-
12
-
With permission from the club presidents, any SFU OS Dev Club executives, ex-executives, project leads (project managers), and project members can write blog posts. Blog posts can be .md or .mdx format.
10
+
The SFU Open Source Development Club will use the Docusaurus Blog feature to show the documentation update and may add acknowledgement of the documentation. Writing blog posts strictly only for Presidents and Director of Technology.
13
11
14
-
If you are willing to write blog, please make your profiles in <code>authors.yml</code>:
12
+
If you are writing blog, please make your profiles in <code>authors.yml</code>:
Up until January, SFU Open-Source Development Club has updated Documentation about Windows Subsystem for Linux (WSL), Git Documentation, and Code Styling. Thank you for your contribution: [Sean Wotherspoon](https://github.com/Seanspoons), [Mehrab Uddin](https://github.com/uddinmehrab), and [Yoonsang Yoo](https://github.com/Yonny04).
Copy file name to clipboardExpand all lines: docs/code-styling/bad-code-styling.md
+20-11Lines changed: 20 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,13 +1,18 @@
1
1
---
2
2
sidebar_position: 3
3
3
---
4
+
4
5
# Bad Code Style Examples
6
+
5
7
These examples show how poor code style practices can lead to code that is difficult to read, maintain, and debug. Issues such as unclear naming, improper use of language features, inconsistent formatting, and poor error handling can all contribute to technical debt and reduce code quality.
8
+
6
9
## Example 1: C - Addition Function
10
+
7
11
```c
8
12
intadd(int a,int b){printf("%d",a+b); // adds two numbers}
9
13
```
10
-
## Why This is Bad Code Style:
14
+
15
+
### Why This is Bad Code Style:
11
16
12
17
No Spaces After Commas: There are no spaces between parameters (a,int b), making the code harder to read.
13
18
@@ -18,11 +23,13 @@ Inline Comment Without Spacing: The comment (// adds two numbers) is directly at
18
23
Single-Line Function Body: The entire function is written in one line, which reduces readability and makes debugging difficult.
19
24
20
25
## Example 2: Python - Improper List Sorting
26
+
21
27
```py
22
28
def srt(lst):
23
29
return lst.sort()
24
30
```
25
-
## Why This is Bad Code Style:
31
+
32
+
### Why This is Bad Code Style:
26
33
27
34
Non-Descriptive Function Name: The function name srt is not descriptive, making it unclear what the function does.
28
35
@@ -31,20 +38,22 @@ Misuse of sort(): The function uses lst.sort(), which sorts the list in place an
31
38
Lack of Documentation: There is no docstring or comment to explain what the function does or what parameters it takes.
32
39
33
40
## Example 3: JavaScript - Inconsistent Error Handling
41
+
34
42
```js
35
43
functiongetData(url) {
36
-
fetch(url)
37
-
.then(response=> {
38
-
if (response.status!=200) {
39
-
console.log('Error: '+response.status);
40
-
}
41
-
returnresponse.json();
44
+
fetch(url)
45
+
.then((response)=> {
46
+
if (response.status!=200) {
47
+
console.log("Error: "+response.status);
48
+
}
49
+
returnresponse.json();
42
50
})
43
-
.then(data=>console.log(data))
44
-
.catch(error=> {});
51
+
.then((data)=>console.log(data))
52
+
.catch((error)=> {});
45
53
}
46
54
```
47
-
## Why This is Bad Code Style:
55
+
56
+
### Why This is Bad Code Style:
48
57
49
58
Inconsistent Error Handling: The catch block is empty, which means that errors are not properly handled or logged, making debugging difficult.
Copy file name to clipboardExpand all lines: docs/code-styling/good-code-styling.md
+18-18Lines changed: 18 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,6 +3,7 @@ sidebar_position: 2
3
3
---
4
4
5
5
# Good Code Style Examples
6
+
6
7
These examples illustrate the benefits of following good code style practices, such as using descriptive naming, proper spacing, clear documentation, and effective error handling. These practices help improve readability, maintainability, and reduce the likelihood of bugs.
7
8
8
9
## Example 1: Java - Calculator Class
@@ -22,13 +23,13 @@ public class Calculator {
22
23
}
23
24
```
24
25
25
-
## Why This is Good Code Style:
26
+
###Why This is Good Code Style:
26
27
27
28
Readable Function Name: The function name (addNumbers) is descriptive and follows a consistent naming convention, making it easy to understand the purpose of the function.
28
29
29
30
Proper Spacing: The code uses spaces between parameters (a, b) which makes the function signature more readable.
30
31
31
-
Descriptive Documentation: The comment block (/***/) provides detailed information about the function, including parameters and the return value. This helps other developers understand the code quickly.
32
+
Descriptive Documentation: The comment block (/\*\*\*/) provides detailed information about the function, including parameters and the return value. This helps other developers understand the code quickly.
32
33
33
34
## Example 2: Python - Sorting a List
34
35
@@ -45,7 +46,8 @@ def sort_numbers(numbers):
45
46
"""
46
47
returnsorted(numbers)
47
48
```
48
-
## Why This is Good Code Style:
49
+
50
+
### Why This is Good Code Style:
49
51
50
52
Descriptive Function Name: The function name sort_numbers clearly describes what the function does.
51
53
@@ -54,28 +56,26 @@ Docstring: The function includes a detailed docstring that describes the paramet
54
56
Simplicity: The function body is simple and uses Python's built-in sorted() function, demonstrating a clear and efficient approach.
55
57
56
58
## Example 3: JavaScript - Fetching Data from an API
57
-
```js
59
+
60
+
```js
58
61
asyncfunctionfetchData(url) {
59
-
try {
60
-
constresponse=awaitfetch(url);
61
-
if (!response.ok) {
62
-
thrownewError('Network response was not ok');
63
-
}
64
-
constdata=awaitresponse.json();
65
-
console.log(data);
66
-
} catch (error) {
67
-
console.error('There has been a problem with your fetch operation:', error);
62
+
try {
63
+
constresponse=awaitfetch(url);
64
+
if (!response.ok) {
65
+
thrownewError("Network response was not ok");
68
66
}
67
+
constdata=awaitresponse.json();
68
+
console.log(data);
69
+
} catch (error) {
70
+
console.error("There has been a problem with your fetch operation:", error);
71
+
}
69
72
}
70
73
```
71
-
## Why This is Good Code Style:
74
+
75
+
### Why This is Good Code Style:
72
76
73
77
Error Handling: The use of try...catch ensures that errors during the fetch operation are properly handled, making the code more robust.
74
78
75
79
Clear Function Name: The function name fetchData makes it immediately clear that the function is fetching data.
76
80
77
81
Readability: Proper indentation and spacing make the code easy to follow. The use of descriptive error messages ('Network response was not ok') helps with debugging.
SFU Open-Source Development is a student club at SFU aimed at bringing together talented individuals from tech, design, and business. Our primary goal is to collaborate on projects that contribute to the community while providing valuable learning opportunities for our members.
4
+
5
+
This documentation will talk about general policies that executives need to follow, the description and requirements of each executive position, and good-to-have skills for executives.
6
+
7
+
This is for current executives for reference but also for people who want to apply for executive positions.
8
+
9
+
DO NOT EDIT this documentation section except presidents of the club.
0 commit comments