The Structure of a Good Programming Question

11 months ago
43

1

00:00:00,030 --> 00:00:04,020

Hey, hi again and welcome to yet another

lecture. In this lecture I'll show you

3

00:00:04,020 --> 00:00:09,090

how to ask a good programming question.

So I mentioned in the previous lecture

5

00:00:09,090 --> 00:00:14,089

asking a good programming question is

very important to get a good answer and

7

00:00:14,089 --> 00:00:21,109

let me first show you what a bad

programming question. For instance

9

00:00:21,109 --> 00:00:28,410

I'm going to click on ask question and

here is the title of a question. A bad

11

00:00:28,410 --> 00:00:33,420

programming question would have a very

generic title like that. Here is the body

13

00:00:33,420 --> 00:00:36,960

of the question where you

have to describe your question in detail.

15

00:00:36,960 --> 00:00:48,239

Some people do they just say: I got an

error when trying to two numbers and they

17

00:00:48,239 --> 00:00:55,350

just post the question. A better question

would be to include the error, the code

19

00:00:55,350 --> 00:01:00,050

there that you executed like that.

However that is also not enough because

21

00:01:04,140 --> 00:01:09,810

you also need to show the error message.

So let me delete this, and a good program

23

00:01:09,810 --> 00:01:14,509

in question would be We're talking

about questions that have an error,

25

00:01:14,509 --> 00:01:20,820

questions that talk about an error that

you got in your code. So this is your

27

00:01:20,820 --> 00:01:27,780

code. A good title would be to include

the error message, so that one would be a

29

00:01:27,780 --> 00:01:32,070

good fit. If it's a very long message

then you can also you can choose to

31

00:01:32,070 --> 00:01:37,829

include only the name of the error without

that and then a good question woulb

33

00:01:37,829 --> 00:01:50,460

be: Hi, I run the following code and

expected to get division in the last print

35

00:01:50,460 --> 00:01:55,520

statement, but I got an error.

Here is my code, so you put the code

37

00:02:01,030 --> 00:02:08,590

there, your entire script. Don't worry

if your question is long. It's better to

39

00:02:08,590 --> 00:02:19,950

be long than to be incomplete and here

is the error. Here make sure to include

41

00:02:19,950 --> 00:02:28,510

your entire errors trace back including

the output as well. So from this

43

00:02:28,510 --> 00:02:34,209

line of the command line up to the next

line so this entire thing goes to your

45

00:02:34,209 --> 00:02:43,750

question. Just copy it. Don't worry if it's

long. Can you help? So that'd be a good

47

00:02:43,750 --> 00:02:48,099

programming question. Now this is still

missing something very important and

49

00:02:48,099 --> 00:02:52,989

that is the highlighting of the code. You

need to select the code and click on

51

00:02:52,989 --> 00:03:07,870

this icon here. The error as well. And let

me pose the question. External links must

53

00:03:07,870 --> 00:03:14,560

provide free educational content, just

click on proceed and here is the question.

55

00:03:14,560 --> 00:03:18,430

Here is how it looks like

on the other end. So this question has

57

00:03:18,430 --> 00:03:21,940

four good elements that make it a good

question.

59

00:03:21,940 --> 00:03:29,590

The first element is that the poster is

mentioning what he or she expected to

61

00:03:29,590 --> 00:03:36,250

get as output from the script that here

they were running so it says I was

63

00:03:36,250 --> 00:03:39,760

expecting to get the division in the

last print statement which is this one

65

00:03:39,760 --> 00:03:44,620

here, but I got an error so the first

thing is you need to include the

67

00:03:44,620 --> 00:03:48,250

expected output, you need to explain

what you were expecting because

69

00:03:48,250 --> 00:03:53,440

otherwise if you don't explain what you

were expecting the other person who

71

00:03:53,440 --> 00:04:01,780

wants to help you doesn't know the goal

of your code or of your questions so it

73

00:04:01,780 --> 00:04:05,890

doesn't know how to help you to reach to

that goal. So expected output is the first

75

00:04:05,890 --> 00:04:08,830

thing. The second thing is you need to

include your entire code

77

00:04:08,830 --> 00:04:15,970

and make sure that you include your code

as text. It's best to use text,

79

00:04:15,970 --> 00:04:22,360

rather than screenshots because text, the

person who wants to help you can copy

81

00:04:22,360 --> 00:04:29,500

your code and run it all their Python

interpreter, but if you includes

83

00:04:29,500 --> 00:04:35,940

screenshots they are images and it's hard

for other people to try out your code

85

00:04:35,940 --> 00:04:40,060

If you ask this on stackoverflow your

87

00:04:40,060 --> 00:04:44,530

question would get closed because if you

ask it or we're using a screenshot

89

00:04:44,530 --> 00:04:49,660

rather than the text version of your

code, the question will get closed

91

00:04:49,660 --> 00:04:55,620

because there are very strong rules in

stackoverflow to have a high-quality

93

00:04:55,620 --> 00:05:01,690

question and answer site. So that's that

second element. The third element is you

95

00:05:01,690 --> 00:05:09,730

need to include your entire screenshot,

entire error traceback, sorry, so from the

97

00:05:09,730 --> 00:05:14,770

beginning up to the end. So that was the

third element, and the last element, the

99

00:05:14,770 --> 00:05:19,870

fourth element is you need to highlight

your code just like that. You see this is

101

00:05:19,870 --> 00:05:27,400

much more visible and easier for others

to troubleshoot. So the course interface

103

00:05:27,400 --> 00:05:32,440

has that function there that you can

highlight your code. On stackoverflow

105

00:05:32,440 --> 00:05:37,169

you also have that capability so just go

to ask question, you write your code here,

107

00:05:37,169 --> 00:05:46,780

highlight it and then use these curly

brackets. Yeah, that's it. If you ask a

109

00:05:46,780 --> 00:05:51,190

good questions the odds are that you're

going to get a good answer as well. So I

111

00:05:51,190 --> 00:05:55,810

hope this makes sense and I hope I showed

you something that you didn't know and

113

00:05:55,810 --> 00:06:00,000

I'll talk to you later. See you!

Loading comments...