1
00:00:02,340 --> 00:00:04,500
So we learned these basics about classes,

2
00:00:04,530 --> 00:00:06,320
let me come back to that class field

3
00:00:06,330 --> 00:00:07,700
versus property thing

4
00:00:07,710 --> 00:00:10,280
because it is important to get that right.

5
00:00:10,350 --> 00:00:12,690
If you have a class that looks like this,

6
00:00:12,690 --> 00:00:16,600
then this here would be called a class field,

7
00:00:16,800 --> 00:00:22,440
this here when you will use it in the constructor would be called a class property right away,

8
00:00:22,440 --> 00:00:27,910
so title is a class property, category is a class field but it's important to know that in the end, this

9
00:00:27,920 --> 00:00:30,900
is just a theoretical separation,

10
00:00:31,140 --> 00:00:33,630
a field becomes a property,

11
00:00:33,630 --> 00:00:38,970
when we create an object based on the class, we just call it property in the constructor function right

12
00:00:38,970 --> 00:00:44,010
away because the constructor gets called during that object creation process

13
00:00:44,040 --> 00:00:46,210
so there we get a property right away.

14
00:00:46,290 --> 00:00:52,890
You don't really have to memorize this difference though, in the end fields are like properties, we define

15
00:00:52,890 --> 00:00:59,430
them in a class so that we have a property when we create that object based on the class.

16
00:00:59,550 --> 00:01:04,320
The thing here at the bottom print info by the way would still be called a class method or an object

17
00:01:04,320 --> 00:01:10,380
method. In our code here, the implication is that all these things here in the constructor function are

18
00:01:10,380 --> 00:01:15,480
properties, of course I got fields of the same name which is no problem because these would be created

19
00:01:15,480 --> 00:01:18,330
as properties when we instantiate the product,

20
00:01:18,390 --> 00:01:24,360
now we basically overwrite everything we set up there in the constructor and therefore you can actually

21
00:01:24,420 --> 00:01:25,380
remove that.

22
00:01:25,380 --> 00:01:32,010
This definition here is not required to be able to assign values, in the constructor you can add properties

23
00:01:32,010 --> 00:01:33,410
for the first time,

24
00:01:33,480 --> 00:01:39,000
so without having defined fields for them before just like that with the this keyword and indeed it

25
00:01:39,000 --> 00:01:43,860
makes no sense or it rarely makes sense to define fields here

26
00:01:43,920 --> 00:01:49,890
if you're assigning a value to them in the constructor right away anyways because then you just basically

27
00:01:49,950 --> 00:01:56,100
overwrite that default logic where every field would be translated to a property because you manually

28
00:01:56,190 --> 00:02:01,740
assign a value to that property and therefore add that property anyways in the constructor.

29
00:02:01,740 --> 00:02:03,360
So this can be removed here,

30
00:02:03,450 --> 00:02:08,520
it's just something which will become important later again where we also work with fields which we

31
00:02:08,520 --> 00:02:11,000
don't initialize in the constructor. For now

32
00:02:11,010 --> 00:02:12,060
that's not the case,

33
00:02:12,090 --> 00:02:16,560
so our object can just look like this, our class can just look like this for the moment.
