Let’s have another quick word about one of the hardest tasks in programming.
Choosing a Data Structure
00:00 You already heard this today, but I’m going to repeat it because it’s very important when you are talking about named tuples, you’ve seen similarities with other data structures.
00:09 For example, data classes. In fact, data classes and named tuples are a bit similar. There are differences, but you can use one whenever you want to use the other one.
00:21 In choosing a data structure for your application, you know, you have a project you’re working on, a program you’re working on, you have some data you want to store and you think, what is the right data structure for this?
00:33 It’s not an easy task, it’s not a problem that has a right or wrong answer. Many of the data structures, we’ve covered quite a lot of them and there are others we haven’t covered in the course.
00:46 There’s always overlap between the data structures and there are many factors that you need to consider.
00:54 Do you care about how much memory you’re using?
00:58 Do you want efficient data structures in the sense that you can, for example, access items efficiently or add or remove items efficiently? Is the speed at which you can do that important? Is the
01:15 time it takes to create an object of a certain data structure important?
01:20 Depending on your application, some of these will be important, some of them won’t. Or maybe they’re all important, maybe none of them are, and these are the decisions you need to make when deciding what is the ideal data structure for a certain application.
01:37 You might get, this is one of those, you might have a problem and you ask a hundred different programmers, what is the right data structure for this application?
01:47 You might get a hundred different answers or even 200 different answers. So choosing the right data structure is a tricky task. And don’t worry if you are uncertain about whether to choose one data structure or the other.
02:03 There isn’t a perfect one. It often depends on preferences of individual programmers, preferences within a certain code base that you’re using.
02:14 So, think about whenever you need to choose a data structure, of course, think about the characteristics you need, the characteristics needed in your application, and based on what you’ve learned in the course and beyond the characteristics of the various data types and see how you can match them together, but you will not get it right all the time and don’t worry about that.
You must own this product to join the conversation.