From the course: Write Performative Programs with C# by Microsoft Press

Unlock this course with a free trial

Join today to access over 24,800 courses taught by industry experts.

Program a program with complexity in mind

Program a program with complexity in mind

Over here, I have the FeedGrain class. This FeedGrain class correlates to a CSV. I do some operations on here very naively and simply to check if it's -- the strings are empty. If it's empty, it gets a zero. We parse it and so on and so forth down the list. I also have a function here to actually generate it. So there's a constructor that's private, but there's also this function that actually generates the FeedGrain because we have to do some nasty operations here to split up the data. We could do this a little bit better. This whole thing could be better. But this is just to wrap the data from the CSV. First thing you're going to notice is this read input method. We're going to talk about this a little bit later. It returns a span of strings. The power of spans is when they allocate, they only allocate once. So lines equals read all lines, that's going to give us an array. If I didn't make this a span and I sliced into a regular array, it would allocate a new array and we don't want…

Contents