Dan Wahlin teaches Web Development and .NET Visual Studio classes at Interface Technical
In future posts, we’ll address the following:
- Key Language Differences
- ECMAScript 6 (ES6) Features – The Future Look of C#
The answer there is “There are a lot of good reasons to do it, such as single‑page applications or validation, and much more that we’re going to talk about.”
The good news is it’s not nearly that bad. It’s actually pretty nice to work with once you know some of the key aspects of the language and how it works.
Obviously, it’s nice to give the Client that type of instant feedback. You’ll of course have to validate on the Server-Side, as well, but this will give the client an instant feedback scenario.
One of the big downfalls, I think, of the traditional Web applications is that every time you blink, it feels like, you’re doing a full‑page postback.
Today, we’re really moving a lot of data from the server‑side load down to the client side. I recently got a Galaxy Note 3 with a quad‑core processor right on my phone. Why not let the phone do more of the heavy lifting and go that route?
I’ll do a quick demo of a server‑side app versus a client‑side app. The first demonstration we’re going to look at is a pure ASP .NET app with C# on the back end. It has normal postbacks.
We’ll open it and you can see it’s very basic, just has a drop‑down.
As you switch the drop‑down, it’s going to load some customers.
We’ll go load all the customers in British Columbia. No big deal, right?
We’ll look at it using Chrome Developer Tools, you can hit F12 or do command or control‑shift‑I.
If We’re going to monitor the network requests. We can actually take a look at what is actually going back and forth over the wire.
We’ll select Alberta from the dropdown.
It looks like the size of that was 11.3K for this customer ASPX. Let’s go look at Arizona, there’s more in Arizona it’s 13K.
Let’s do one more. Montana is about 13K.
You can see the size of the page actually coming back is fairly consistent but it depends on your data.
This is using a little library called “KnockoutJS” to do data binding. It’s going to look the same, but let’s look at the actual data that’s sent back and forth.
Here’s the same type of app, but this is 100‑percent client‑side.
The server just serves up the initial HTML and then we make an API call, specifically Web API. This returns JSON data. It does the same thing, but let’s take a look at the size of the data that’s coming back now.
I’m going to click on XHR, which will mean our XML HTTP request, in other words, AJAX calls.
Let’s run British Columbia.
It looks like that was 1.8K of data. Not bad.
Let’s go to Montana again.
It looks like that was only 256 bytes. Not bad.
You can imagine if you’re designing your apps to run on a phone or a tablet or desktop, then this is a big deal.
Now, by leveraging AJAX, I’m able just to send the raw data that you can see here.
Both languages use functions. I think any language out there uses a lot of functions. That’s very common.
Finally, the conditional “if” statements, “switch” statements and “for loop” statements are practically identical in both languages. We’ll display those as well.
In this demo I have some C# code in a class called “Similarities.cs.”
I’ve broken down different parts of this. Variables.
We’re going to talk about some properties and some other features.
Let’s start with the one that’s open. In C#, we’re all used to doing something like prop tab tab to get a property definition. It looks like this.
You have a Get and a Set.
The current version, that this.age = 0 would be a very similar definition to a property.
It almost looks like a field it’s very similar.
You might wonder what the heck is this? It’s similar to C# however it changes context.
Basically, whoever calls into “this” is what “this” is. Whereas in C#, it always represents the actual object itself. A little bit different but very similar as far as what you can define.
Let’s go to a simple variable.
Here we have a C# method, called “GetName,” that returns a string.
You’ll notice it’s almost identical, aside from needing to input the “function” keyword.
Arrays – Loops – Conditionals
Finally, Arrays, Loops, and Conditionals are also very similar. Here, we have a little field names.
Pretty standard C# code, a bit contrived, but good for the demo.
We’re going to loop through. As we loop, if it equals zero (0), we’re going to add into the list up top, the list of string, first name. If it’s not zero (0), then, we’re going to add name, plus, whatever it is as we’re looping.
We use the function. Notice that the for loop is identical, because we can use var in C# if we want, for type inference. The if is identical. As we move down, everything looks pretty good.
You May Also Like
Government Edition – Encrypting a USB Flash Drive in Windows 100 269 2
In this video, Security Instructor Mike Danseglio demonstrates how to use BitLocker in Window 10 to secure files on a USB Flash drive that adhere to stricter data protection requirements as found inside Government entities. BitLocker 2-day instructor-led training is now available at Interface: BITLOCK: Planning and Deploying BitLocker Drive Encryption Training Video Transcription: Hi. … Continue reading Government Edition – Encrypting a USB Flash Drive in Windows 10
How to Build in a PSMethod to your PowerShell Code0 68 0
In this video, PowerShell instructor Jason Yoder shows how to add Methods (PSMethod) to your code using free software that’s added into the PSObject. For instructor-led PowerShell courses, see our course schedule. Microsoft Windows PowerShell Training Download the Building Methods PowerShell script</a> used in this video. <# ╔══════════════════════════════════════════════════════════════════════════════╗ ║ ║ ║ Building Methods ║ ╟──────────────────────────────────────────────────────────────────────────────╢ … Continue reading How to Build in a PSMethod to your PowerShell Code
Configuring Windows Mobility Center and How to Turn it On and Off1 1413 1
Video transcription Steve Fullmer: In our Windows training courses, we often share information about the Windows 8.1 Mobility Center. Mobility Center was introduced for mobile and laptop devices in Windows 7. It’s present and somewhat enhanced in Windows 8. Since we don’t have mobile devices in our classrooms, I decided to take a little bit … Continue reading Configuring Windows Mobility Center and How to Turn it On and Off