C# 7 and .NET Core Cookbook - podcast episode cover

C# 7 and .NET Core Cookbook

Jun 06, 202610 min
--:--
--:--
Download Metacast podcast app
Listen to this episode in Metacast mobile app
Don't just listen to podcasts. Learn from them with transcripts, summaries, and chapters for every episode. Skim, search, and bookmark insights. Learn more

Episode description

A wide range of programming solutions across sixteen chapters, covering modern updates like C# 7.0 features, asynchronous programming, and multithreading. Beyond language syntax, the text provides instructions for building mobile applications via Xamarin and Cordova, as well as developing cloud-based microservices and serverless functions on Azure and AWS. Each section is structured to facilitate learning through specific recipes that detail preparation, implementation, and the underlying mechanics of the code. Ultimately, the book aims to help software engineers navigate the rapidly evolving .NET ecosystem by providing clear, efficient strategies for real-world software development.

You can listen and download our episodes for free on more than 10 different platforms:
https://linktr.ee/cyber_security_summary

Get the Book now from Amazon:
https://www.amazon.com/C-7-NET-Core-Cookbook/dp/1787286274?&linkCode=ll2&tag=cvthunderx-20&linkId=958d2a34aeb2a817d7fa54de6baa379d&language=en_US&ref_=as_li_ss_tl

Discover our free courses in tech and cybersecurity, Start learning today:
https://linktr.ee/cybercode_academy

Transcript

Speaker 1

Imagine you're building an application that handles like a million transactions every single second.

Speaker 2

Oh wow, Yeah, like a global banking app or a massive multiplayer game or something.

Speaker 1

Right exactly, And every time your code runs, it creates this tiny temporary file in your system's memory just to hold a couple of numbers right now, multiply that by a million. Eventually a background process has to come through and clean up those million tiny files, and when it does, your entire server suddenly.

Speaker 2

Just grinds to a complete halt.

Speaker 1

Exactly. Users get disconnected, carts crash, it's a mess. So today we're looking at how a seemingly minor tweak in a programming language completely eliminates that problem.

Speaker 2

It really is the butterfly effect of software development, you know, a microscopic change, and how developer types a line of code cascading upward to save entire server architectures from collapsing.

Speaker 1

Welcome to today's deep dive. We are exploring the c Sharp seven and dot net Core cookbook. It's written by Dirk Strauss, who is a seasoned software developer and a Microsoft MVP.

Speaker 2

Yeah he really knows his stuff, he does.

Speaker 1

But we aren't just like reading you a manual today. The mission here is to help you cut through the noise of modern software documentation. We're tracking an evolutionary leap in how developers think about and write code.

Speaker 2

And we're eventually going to zero in on one specific highly anticipated feature from c Shark seven point zero release.

Speaker 1

Right. And to really understand why this feature matters, we have to look at the environment that well forced it into existence.

Speaker 2

Yeah, the macro context is huge. Here the forward of this book, it's written by doctor James McCaffrey for Microsoft Research, and he paints a pretty intense picture of the industry.

Speaker 1

He really does.

Speaker 2

He calls it this astonishing explosion of new technologies and a title wave of various forms of documentation.

Speaker 1

I mean, tidle wave almost feels like an understatement. If you look at the sheer scope of what developers are expected to manage today, it's it's honestly paralyzing. Oh. Absolutely, You've got your legacy syst but now you're also expected to build cross platform apps with net core one point one that run seamlessly on Windows, Linux, mac op.

Speaker 2

Right, and you're creating mobile apps using Zamorin and Cordova.

Speaker 1

Yeah, and you're moving from old school monolithic architectures where everything lives on one big server, to these cloud based micro services on Azure service fabrics exactly.

Speaker 2

Not to mention serverless computing right aws, Lambda S three Azure functions. For a developer trying to stay relevant, it really is just pure information overload.

Speaker 1

So okay, let's unpack this. Yeah, because it's like standing in front of this massive, globally themed all you can eat buffet.

Speaker 2

That's a great way to put it, right.

Speaker 1

You've got sushi, tacos, roast, beef pasta, all just staring at you. You're holding an empty plate, and if you just start piling everything on without a strategy, it's gonna be a complete.

Speaker 2

Mess, a total disaster on a plate.

Speaker 1

Yeah. So, how is a developer supposed to navigate this massive landscape without feeling, you know, entirely paralyzed by all this info overload?

Speaker 2

Well, if we connect this to the bigger picture, this is exactly why a cookbook approach is vital. A cookbook doesn't ask you to eat the whole buffet. It offers quick, targeted solutions, you know. But here's the underlying thread that connects that massive buffet. Whether you are building a native iOS app or an AWS lambda function. You are ultimately relying on the foundational syntax of c sharp.

Speaker 1

The language itself is the kitchen. So if we want to survive this shift, we have to make sure our kitchen tools are ruthlessly efficient.

Speaker 2

Exactly, you can't afford memory leaks when you're running millions of automated cloud function.

Speaker 1

Right, And that architectural pressure actually forced the c Sharp language designers to rethink something as basic as how a method hands data back to a developer.

Speaker 2

Which brings us to the blockbuster feature of c sharp seven point zero. Matt's Turgerson, the Sea Sharp program manager, went on a record saying that, alongside pattern matching, the biggest feature by far.

Speaker 1

Was tupples tuples. Okay, let's establish the technical floor here, because the core problem top will solve is like incredibly relatable.

Speaker 2

Oh yeah, every developer faces it.

Speaker 1

Often. You write a function and you want that function to give you back more than one piece of data, right, But.

Speaker 2

A method naturally just wants to return one thing. It calculates a result, hands it back, closes out right, But real world logic rarely fits into a single result.

Speaker 1

But wait, couldn't developers already return multiple values using other clunky workarounds before this. I mean, I remember inheriting legacy code where they used out parameters everywhere. Ah.

Speaker 2

Yes, the classic out parameter trap.

Speaker 1

It's so messy it breaks the entire flow. You have to preemptively declare empty variables before you even call the method. It sounds like going to a drive through and being forced to make a separate transaction for your burger, your fries, and your drink instead of just being able to order the number two combo.

Speaker 2

That is exactly what it felt like. And if you didn't use out parameters, you had to build an entirely new custom class or struct just to transport the data, which is just boilerplate clutter exactly. So the tupple is your number two combo. It's a lightweight structure that packages multiple values together cleanly. But what's fascinating here isn't just that tupples exist. It's the technical specifics of how they are implemented.

Speaker 1

Right, because not all data containers are created equal.

Speaker 2

Precisely, in C sharp, tupples are implemented as strucks, meaning they are value types rather than reference types.

Speaker 1

Okay, that's a huge distinction.

Speaker 2

It really is. It means they are created locally and passed by copying the content.

Speaker 1

So no heat allocation exactly.

Speaker 2

No heat allocation, which means the garbage collector doesn't have to come clean it up later. It is friction free data transport. And they are completely mutable with public mutable fields.

Speaker 1

Which makes perfect sense. If I hand you a combo meal, you shouldn't have to jump through hoops just to change out the fries for a salad.

Speaker 2

Right, it's your local data exactly. It's lightweight, it's performance, and it saves memory.

Speaker 1

So what does this all mean, Like, how does this actually change the code on a practice level.

Speaker 2

Well, Strauss uses this really great scenario in the book to demonstrate.

Speaker 1

This, well, the student's score dilemma.

Speaker 2

Yes, imagine you have a method that needs to calculate the average score for a class, but because class sizes vary, the method also needs to return the count of students processed.

Speaker 1

Two pieces of data, the average and the count.

Speaker 2

Right, And he provides this hard coded input array of scores in the text just to ground it.

Speaker 1

I actually have that right here. The array is seventeen forty six thirty nine sixty two eighty one seventy nine, fifty two, and twenty four perfect.

Speaker 2

So with the new c sharp seven point zero return type syntax, you just declare the methods return type using a set of parentheses. You write public int innt, get average and.

Speaker 1

Account just int innt. That's so clean it is.

Speaker 2

And inside the method as a dummy implementation, he shows you can just write var return tuple equals zero zero using a tupple literal.

Speaker 1

Okay, but here's where I have to push back a little on the implementation. Yeah, because the calling code still has to consume it, and historically tuples rely on these default properties, right.

Speaker 2

Right, item one and item two.

Speaker 1

Yeah, you have to type f item one for the average and s item two for the count. That is so confusing. Imagine reading that code three months later. Is item one the average, that the count is the highest score.

Speaker 2

It's completely opaque, You have zero context.

Speaker 1

It's a breeding ground for bugs.

Speaker 2

Oh absolutely, I completely agree. And that exact limitation of default tuble naming is what leads to the final most elegant feature of c sharp seven point zero tuples.

Speaker 1

Here's where he gets really interesting, because.

Speaker 2

They fixed this, right they did. You can declare variable names directly in the return type now, so.

Speaker 1

Instead of just inint INNT, you can write public int average in student count, get average in count.

Speaker 2

Exactly. You are attaching the semantic meaning right there in the signature, and the.

Speaker 1

Impact that has on the calling code is massive, because you jump from generic item one tags to named elements inside an interpolated string. You just type s dot average in s student count, which.

Speaker 2

Is incredible readable, and you can even name tupple literals internally, like var return tupple, I've ave dot average, scout dot.

Speaker 1

Right. It isn't just about making the code run faster, It's about making it human readable for the nice person who inherits the project.

Speaker 2

And this raises an important question about how language features fundamentally change team collaboration. Oh, for sure, writing code is as much about communicating intent to other developers as it is about giving instructions to a compiler, exactly.

Speaker 1

But we do need warn people about a specific setup requirement.

Speaker 2

Right, Yes, the gotcha, gotcha? If you are working in Visual Studio twenty seventeen release candidate, this doesn't just work right out of the box, right.

Speaker 1

Because the core compiler didn't natively know how to process value tech toples yet exactly.

Speaker 2

So developers have to go to the new Get package manager and actively install a package called system dot value tuple.

Speaker 1

And hit accept on the Microsoft license agreement that pops up.

Speaker 2

Yes, you have to accept the agreement for it to work. It's a small hurb, but if you don't know it's required, you'll be staring at compiler errors for hours completely baffled.

Speaker 1

Yeah, well, I think that brings us full circle on this deep dive. We started out looking at this overwhelming macro world, right, micro services, serverless architecture, cross platform app, giant buffet, the giant buffet, and we seemed all the way down into the elegant micro level syntax of c shark seven point zero tuples.

Speaker 2

And mastering these precise quick solutions is exactly what makes a developer truly formidable.

Speaker 1

It really is, and it leads you with a final somewhat provocative thought to mull over. Yeah, think about it. If programming language syntax is constantly evolving to mirror natural human logic, like seamlessly packaging and naming multiple related ideas at once, like we saw with tuples, how close are we to a future where code structure becomes almost indistinguishable from plain English.

Speaker 2

Wow, that's a huge question.

Speaker 1

Right, And how are the tools you use today subtly shaping the way you actually think about problems evolving in your everyday life.

Speaker 2

We shape our tools, and then our tools shape us.

Speaker 1

Exactly something to think about the next time you write a line of code. Thanks for joining us on this deep dive.

Speaker 2

Thanks for having me

Transcript source: Provided by creator in RSS feed: download file
For the best experience, listen in Metacast app for iOS or Android