If you know me well then you probably know how in love I am with serverless backends, cloud functions, lambdas, and whatever other fancy names they can give for basically a pay-only-for-what-you-use server. I'm also pretty fond of the Serverless Framework (https://github.com/serverless/serverless) which let's you easily scaffold out a new project meant to be run on a serverless architecture. Although I've only been using it for AWS Lambda, I recently made a little mistake that turned out to be a great discovery, and in this post I'll tell you all about it!
0 Comments
This tip works for many languages, and it’s not explicitly stated all the time when starting out. I had already known that you could do this, but kudos to the book “Javascript & JQuery” by Jon Duckett for inspiring me to write a post about it. It’s a very colorful and friendly book that is actually read fun to read which is a huge accomplishment for a book about programming. Anyway, this is a useful little tip to remember when crafting your functions.
Let’s think about the function signature in different (statically typed) languages. Remember, the compile breaks out of the function when return method is called, and nothing after it is run. The function defines a return type, and to a naive programmer looking at the signature it seems that one can only return a single thing. And it’s true- you can only return one thing. But, that thing can be an Object or an Array. This is a really cool, simple method for sketching out what you want your code to do. I came across this flowcharting method from page 23 of the great book “Javascript and JQuery” by Jon Duckett (screenshots below). He describes the motivation for them like this:
“Often scripts will need to perform different tasks in different situation. You can use flowcharts to work out how the task fit together. The flowcharts show the paths between in step.”
One of the great things about C# is how you handle variables. Variables are statically typed, have access modifiers, and can even use a nifty shorthand trick to easily and flexibly create "global" variables without wordy getter/setter methods. Let's dive in to how variables work in C#!
|
AuthorThe posts on this site are written and maintained by Jim Lynch. About Jim...
Categories
All
Archives
March 2023
|