Friday, April 27, 2018

A little about TypeScript and Visual Studio 2017 Support

Go Crazy with ES6 JavaScript using TypeScript, But Wait...

Visual Studio 2017 (VS2017) IDE is supposed to just work when it sees TypeScript file added to a project. In that when such a TypeScript file, a source file with the file extension of *.ts, is saved, the TypeScript transpiler, tsc.exe, is executed using the file as input and ES6 compatible JavaScript source is generated and a *.js file is outputted to the same folder as the *.ts source file. But wait, this doesn't happen out of the box. I'm not sure why.

The first time user must first go to the website TypeScriptLang.org, click the Download tab, find and click the Visual Studio 2017 link. This takes you to a Microsoft.com webpage that reveals a download link for "TypeScript SDK for Visual Studio 2017." After the download is completes, and the VS2017 project is closed and reopen, viola, transpiled ES6 compatible JavaScript files sourced from the TypeScript source files. Not so fast...

What's a little madding after it's installed through VS2017, you're not sure where the transpiler is installed and what version was installed. I happened to know I downloaded 2.8.3 which will be soon forgotten and outdated. But where was it install to and what version is currently being used despite that? Was it installed as a NuGet package, a npm package, or apart of the Visual Studio Installer (VSI) environment? VSI lists older versions of the TypeScript SDK as installed and not the new version just downloaded and installed. That can't be good.

As it turns out, tsc.exe is not installed through node (so a tsconfig.json file won't work) or NuGet (so updating - deleting and then installing - to the latest NuGet package won't work; although I didn't try this).

So I scanned the filesystem and read a little online - the brute force way.

The TypeScript transpiler is installed here by VSI and when you use the Microsoft link presented by the TypeScriptLang.org download webpage:
C:\Program Files (x86)\Microsoft SDKs\TypeScript\[container folders for different versions, e.g "2.6"]\
For VS2017 projects that have actual project files, e.g. *.csproj files and when not using Node and webpack, gulp, or grunt to install and build using TypeScript, go here (first make sure your IDE updated to the latest version) :
https://github.com/Microsoft/TypeScript/wiki/Updating-TypeScript-in-Visual-Studio-2017
For those projects that don't have actual project files, e.g. empty ASP.NET website projects and when not using Node and webpack, gulp, or grunt to install and build using TypeScript, edit this file with the latest installed TypeScript version:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools\vsdevcmd\ext\typescript.bat 
For example, I changed "2.6" to "2.8" in the following section of text: 
...
if exist "%ProgramFiles%\Microsoft SDKs\TypeScript\2.8" (
set "PATH=%ProgramFiles%\Microsoft SDKs\TypeScript\2.8;%PATH%"
set _TypeScript_Found=1
)
if exist "%ProgramFiles(x86)%\Microsoft SDKs\TypeScript\2.8" (
set "PATH=%ProgramFiles(x86)%\Microsoft SDKs\TypeScript\2.8;%PATH%"
set _TypeScript_Found=1
)
...
The way this .bat configuration file is associated with the VS2017 dev environment is through scripts that setup environment variables. Just look at CMD shell shortcuts, specific to VS2017, that are found in the Start menu under the VS2017 folder and located here:
C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Visual Studio 2017\Visual Studio Tools\
and here:
C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Visual Studio 2017\Visual Studio Tools\VC\
Finally, when using Node and webpack, gulp, or grunt to install and build using TypeScript, open the project folder's package.json file and edit the TypeScript entry to something like this:
"typescript": "^2.8.3",
Followed by a "npm install" from the command-line.

Incidentally, when you install node modules globally, "npm install -g [some module/package]", on Windows 10, the binaries are install here:
C:\Users\[your user account name]\AppData\Roaming\npm\node_modules
Clear as mud.

Annoying TypeScript error that may appear after one upgrades to TypeScript 2.6 and beyond

If you see these TypeScript errors after transpiling the VS2017 stock Vue.js template project that is released with ASP .NET Core 2 for VS2017 (see "My Travels into the World of .NET Core" blog entry):
Error TS2345 (TS) Argument of type 'typeof FetchDataComponent' is not assignable to parameter of type 'VueClass'.
  Type 'typeof FetchDataComponent' is not assignable to type 'new () => Vue'.
    Type 'FetchDataComponent' is not assignable to type 'Vue'.
      ...
  C:\Users\Luckyjohn\Desktop\[project folder]\ClientApp\components\fetchdata\fetchdata.ts
Error TS2345 (TS) Argument of type 'typeof CounterComponent' is not assignable to parameter of type 'VueClass'.
  Type 'typeof CounterComponent' is not assignable to type 'new () => Vue'.
    Type 'CounterComponent' is not assignable to type 'Vue'.
      ...
  C:\Users\Luckyjohn\Desktop\[project folder]\ClientApp\components\counter\counter.ts
These can be solved by going here. The explanation of the new feature that causes this error since TypeScript 2.6 absolutely makes no sense to me (and I'm not a dumb guy, well, maybe a little slow).

Friday, April 13, 2018

Too Many React Requests, Time to Know Something About React

Why React now?

I'm speculating here. First it was Angular v1. Then it was rxjs better known as Observables that supported a stream of related events processed into serialized asynchronous steps (seems odd to put those two terms together: serialized, sequenced to async steps). Angular v1, lost favor to Angular v2+. But since Angular v2+ was so different, it seemed to lose favor to React. Then came VueJS which was a light weigh and not so hard on the eyes JavaScript reactive SPA solution. So it seems it's either React or VueJS for JS reactive programming. Of course, I'm sure, this will be different 6 months from now (March 2018).

Sunday, April 08, 2018

My Travels into the World of .NET Core

Running Notes of Creating a Reactive JavaScript Application Using ASP .NET Core and Visual Studio 2017

Overview

The complicated world of Microsoft open source.

Microsoft is trying to center all the .NET platforms around a standard called: .NET Standard. The latest version is .NET Standard 2.0. If your app depend solely on namespaces from the .NET Standard, it practically guaranteed to just work on many different platforms - supposedly - provided that the platform supplies "base" class libraries written to the standard.  So same old song and dance: "write once, run many."

The .NET Core Framework is non-Microsoft, open-sourced, version of .NET which can run on non-Windows machines. Various versions of .NET Core Framework are 100% compatible with the .NET Standard. That is to say, the .NET Core Framework 2.0 platform is compliant with, "exposes all APIs defined in" or "targets" the .NET Standard 2.0 depending on how you want to think about it. At times, however, the .NET Core Framework version can be ahead of or a superset of the .NET Standard.

The .NET Core Framework 2.0 (otherwise known as the .NET Core SDK 2.0) represents really 3 major parts
  1. CoreCLR - the .NET runtime
  2. CoreFX - the .NET framework library 
  3. dotnet.exe - the command-line tool referred to as the "application host CLI" (the part I think should be included when .NET Core Framework is represented)
The .NET Core Framework tool set: all of the above plus Visual Studio 2017 and Entity Framework Core. Visual Studio IDE may lag behind dotnet.exe CLI application as far as supported features and will always lag behind in integrating the latest stable reactive JavaScript application framework releases (but usually you can work around this).

What You Need for a JavaScript ES6 Reactive Single Page App (SPA) .NET Core Framework Webapp "Hello World"

It's OK to start with Visual Studio 2017 Community (VS2017C) so install as first step using the Visual Studio Installer (VSI), a separate product from VS2017C. Don't try to separate out what you think you need from what you don't need for the install process. Install it all even though you probably use 30% of what is installed.

Recently (March 2018), it seems one must use VSI to see if there is an available update to and acquire updates to VS2017C and all involved in developing the "Hello World" SPA webapp. There will be a button labeled "Update" under the VS2017 you have installed which normally would be labeled "Modify". Another indication that major VS2017 IDE and environment update is available is a yellow colored flag icon in the upper right corner of a running IDE. Click on the flag, a notifications window opens and, if a VS2017 update is indicated as pending, click the notification to install the update. This step may not install the .NET Core SPA project templates you need (out of the possible six supported so far: Angular, currently (March 2018) supporting version 4, React, React w/Redux, VueJS, Aurelia, Knockout where half of which are only exposed through dotnet.exe). If so, do this (while VS2017C and VSI are not running) from the command-line (CLI):
dotnet new --install Microsoft.AspNetCore.SpaTemplates::*
Which command-line (CLI) you ask? Well, here are some other pieces you'll need:
  1. "Open Command Line" by Mads Kristensen installed through VS2017C IDE/Tools/"Extensions and Updates"
  2. Git Bash, for you UNIX command-line fans. Git, if not already install by VSI (after VS2017C installation/update step, check first if already installed with "git --version" on the command-line). If Git is not installed, download and install Git Bash that comes with Git from git-scm.com
  3. NodeJS, if not already install by VSI (after VS2017C installation/update step, check first if already installed with "node -v" on the command-line) installed through download from nodejs.org. This installs "npm.exe" which is crucial.
VS2017C uses and manages three different package manager applications (more if you count VSI) to manage project dependencies:
  1. NuGet - Project view: Solution Explorer/twirl open project, twirl open Dependencies/twirl open NuGet - To manage, VS2017C/Tools/NuGet Package Manager/Package Manager Console
  2. npm - Project view: Solution Explorer/twirl open project, twirl open Dependencies/twirl open npm - To manage, the obvious way, open the CLI and go to project's CLI root, edit package.json and execute npm commands.
  3. .NET Core 2.0/dotnet.exe  - Project view: Solution Explorer/twirl open project, twirl open Dependencies/twirl open SDK  - To manage, the obvious way, open the CLI and go to project's CLI root, execute dotnet.exe commands, start with "dotnet -h".

Create a New SPA Project (and Solution) Using a .NET Core Project Template

For Angular (4 currently), ReactJS or ReactJS and Redux:
Open VS2017C, File/New/Project/Visual C#/.NET Core/select "ASP.NET Core Web Application", select/create project folder, name project and click OK. At this point, "New ASP.NET Core Web Application" dialog box pops up where you can select one of the following three project templates: Angular, React.js or React.js and Redux.
For VueJS, Knockout or Aurelia Web Application project template, create and cd into a project's CLI root folder and from the CLI, type:
dotnet new [vue | knockout | aurelia]

Blast Off with  "Hello World"

Open VS2017C, File/Open/"Project/Solution..."/, browse to project folder, select either the project *.csproj file or solution *.sln file and click Open.

Let the IDE pull in what it thinks it needs, find the play button (green triangle), select "IIS Express" (installed by VSI) and click the play button. Edge browser should launch and display JS SPA reactive webapp per the selected project template.

HTML, CSS, Razor, Server Controller and View and JavaScript SPA Source Files

JavaScript and CSS source: VS2017 IDE/Solution Explorer/twirl open ClientApp folder, twirl open Components folder. App is the main component, all other folders are components that are partial views that make up small to large chunk of a webpage.

Server Action source: VS2017 IDE/Solution Explorer/twirl open Controller folder. Take action requests from the browser, providing access to data model and return views as ActionResult

HTML, web dependencies, Razor source: VS2017 IDE/Solution Explorer/twirl open Views folder. Specification of how HTML, CSS, JavaScript, dependencies, data or resources are packaged for return trip to the browser. Under the Views folder you make find a folder name "Shared." Under this folder Razor/HTML templates exist to provided common full or partial page templates.

Data provision: The project template doesn't create a Models folder, the M of the MVC design pattern, probably because not every MVC webapp needs a database therefore no model is needed nor is every MVC application complex enough to warrant the separation of concerns of strongly typed models from a controller or controller method.  When strongly typed models are warranted, plain-old class objects backing, or POCOs, source are usually directly located under the Models folder where any controller or the Razor renderer can find them. The POCOs, with C# properties that somewhat match the attributes or columns of a DB table, mirror or model a DB table.

Deleting, Repairing and Restoring IDE and Project Dependencies

Sometimes dependencies, whether npm, NuGet, .NET Core, and VS2017C, become corrupted. The best thing to do is delete the dependencies and then restore them. Do all steps below in order or just the affected dependency set:
  1. For VS2017C dependencies, close all VS2017C solutions and instances, fire off VSI and under the active IDE, click "More" and select "Repair." After the repair completes, open the solution, click "Build/Clean Solution". VSI can be fired off from VS2017C, from the Tools menu item, click "Get Tools and Features...".
  2. For updating or updating and reinstalling a solution's NuGet dependencies, Microsoft once again provides many confusing ways to do the same thing. I think the simplest method is open the solution in the VS2017 IDE then goto Tools/Nuget Package Manager/Package Manager Console. In the Package Manager Console, to update only, type "Update-Package." To update and reinstall all dependency packages, type "Update-Package -reinstall". BTW, VS2017 IDE won't tell you when some of solution's NuGet dependency packages have updates. To check for NuGet dependency package updates, open the solution in the VS2017 IDE then goto Tools/Nuget Package Manager/"Manage NuGet Packages for Solution..." and click the "Updates" tab for listed available updates.
  3. For .NET Core SDK dependencies, from the root folder of project and from the CLI, type "dotnet restore"
  4. For npm dependencies, delete the node_modules folder in the root of the project folder and from the CLI, type "npm install"
  5. To do a clean VS2017C build and run, open the solution, click "Build/Rebuild Solution" followed by selecting "IIS Express" (to the right of the play button, the green triangle) and then clicking the play button.
Clear as mud.

Saturday, March 24, 2018

The Road to Ruby on Rails

Learning Ruby on Rails

Wow, Ruby and Ruby on Rails is a different animal. What I like about it is that it's monolithic and self-contained and what I don't like about it is that it's monolithic and self-contained. What I mean by this is that Ruby and Ruby on Rails is so different and in its own world, it practically forces you to specialize in it. Specialization is very dangerous thing for software developers because software technologies are constantly and rapidly changing and therefore skills in high demand today could, and most likely, as all things, dry up tomorrow. When you are forced to look to another skill, it's always the "years of experience" over "acquired skills" that count. What hiring managers always fail to understand is that software engineering is software engineering, no matter the programming language, framework or methodology. Blah.

I few Ruby/Rails ways of doing things

-Ruby likes to call what are well-known as an object's "properties" object "attributes."
-Rails has a million short-cuts to do the same thing that really only saves a few characters of typing.
-Ruby and Node.js have many similarities so you have to wonder which came first. I'm guessing Ruby. After that, one has to wonder which came first Ruby or Python. IDC.
-Static class methods are defined/named with the prefix of "self."
-The Ruby gem that is a test suite product to test Ruby code, called RSpec, likes to refer to a "test case" or single "test" as an "example". This test suite gem likes to refer to "assertions" as "expectations." So far, I really like the RSpec gem except for its own terminology for what is well-known, industry-wide, nomenclature.

RSpec is like nothing you've seen before

RSpec is a test framework for testing Ruby programming language and Ruby on Rails applications. It seems to bend over backward trying to couch test implementation as if expressing paragraphs of English sentences. Unfortunately it uses a terminology that is not common to the software development industry - past or present (and I know a little about the past). It's a bit rough to wrap your brain around but I can see that you can get away with using a small subset of the specification to do a decent job at testing your ruby code.

Monday, March 12, 2018

The Spouse is Mightier than the Sword

I have good friend who is a fellow developer, and a great one I should say, that developed a tool he uses in the course of his business as a freelance developer. From the first time he showed me the product, I told him what I thought. That is, I thought the product was too complicated for its rather simple purpose, that he used terminology that no normal user of his product would understand and that had features where the complexity of the feature outweighed the utility and usefulness of the feature. He'd laugh off my feedback.

So way down the road, close to when his tool is nearly completed (in his eyes), he has his wife give him feedback on the product. AND GUESS WHAT! She mostly had the same feedback as me!

So I had a good laugh at the fact that he took his wife's feedback over me and implemented the required radical changes! So now, when I want to change his mind about something, I'll go through his wife.

A powerful lesson for those mere mortals, like myself, when there is a need to influence a brilliant person.

Thursday, February 08, 2018

My Bank's Website Can't Add!

I'm doing my income statement for my taxes and I discover I'm $12,000 off. What! So thinking it's a dumb mistake, I stay up nearly 24 hours without breaking away from my desk, not even to eat, racking my brain and scouring the numbers to see where I went wrong. It finally dawned on me to to recheck the beginning and ending balances for the year.

To get the beginning balance of 2017 for the account, I had to query a range of dates that preceded Jan 1, 2017. So I queried transactions from Nov 1, 2016 to Jan 15, 2017 (there's not much activity in this account). Then I picked the very last transaction of 2016 and called that my starting balance for 2017.



See if you can spot the problem in the attached listing of a range of transactions.

I thought my beginning balance should be $23,290.33. But wait!
the previous balance is 11,289.85. What's 11,289.85 + .48?

It's supposed to be $11,290.33, not $23,290.33.

Take a look at the attachment, you won't believe your eyes.

Anyway, after using $11,290.33 as my new beginning balance, I'm only off by $137. Much better!

Hey Bank executives, you need to stop going with the cheap bids for your online banking websites. Unbelievable.

This Bank's website is particularly bad, riddled with defects, clunky and slow. Ask me what bank it is and I might reveal it.

Tuesday, January 30, 2018

Just added yet another production service...

I'm setup with the hardware and software to render your favorite vinyl LPs to iTune (Apple lossless) audio files. I can even add the meta-data that iTune uses to correctly insert the files in the iTunes library. Of course, the files match CD digital quality.

I can even filter out the rumble and scratches but I personally don't prefer since the rumble and scratches are endearing to me.

So if you want to bring back those fond memories, contact me.

Monday, January 29, 2018

What the heck, going ahead and learning Rails (as in Ruby on Rails)

I know or played with many JavaScript frameworks (including, jQuery, Angular 2++, Vue.JS), a little Cordova WebView targeting, CSS3 and Bootstrap, HTML5, middle-end technologies like NodeJS, PHP and .NET. Meanwhile Ruby on Rails has recouping a surge of popularity (I'm not sure why or it might be a figment of my imagination - if you know, please share). But whatever, I decided to take the next step and am now learning Rails and its companion webserver Puma. What the heck, get it over with. At first look, Rails seems to be what everybody calls a CLI implementation. And, the Ruby on Rails framework is pretty complete, having thought of and providing everything a developer needs under a single project directory structure (minus the language Ruby itself and the database server).

First thing "not" to do. Don't try to integrate MySQL server installed with XAMPP with the Ruby on Rails framework installed using Homebrew and Gems - no work'y and a huge waste of time trying to figure out how to make it work - blah.

So here I go...

Friday, January 19, 2018

What's nuts about the latest, new programming languages and programming language enhancements

1) There is really nothing new about them. In fact, some are a re-hash of languages and days gone by. The authors of these languages just don't know history, leading to history repeating itself, over and over and over... (recursion, infinite looping...). Blah!

2) Most of the languages aim to do one thing, reduce typing. Really? No programmer types these days. Smart editors and IDEs auto-complete and do the typing of all the programming text leaving only data to be typed. And data is always cut or copied and then pasted.

3) The new languages strive to remove the need for syntactic sugar (end-of-statement markers like ';' and '(' and ')' to group parameters, '{' and '}' to mark lexical levels...) reducing the readability of program source, returning code back to the days of terse, unreadable gibberish, mass of random text. Rendering the source difficult to review, visually debug and pass onto the next developer. Blah!

4) Let's not forget, introducing more ways, usually with less keystrokes, to do the same thing bloats the language; bloating it into volumes of documentation. Please, keep the language separate from libraries - don't integrate functionality into the language that can be simply packaged as a library.

Let's make a new rule. If your programming language can't be described in a book with the same number of pages or less than "The C Programming Language" by Kernighan & Ritchie, please just stop. And, yes every programming language needs documentation - a language is only intuitive to the person who authored it. Really.

Monday, May 30, 2016

So What Happened with the Job Interview?

Well it's been two years since my last post. In my last post, I talked about a job interview with a small startup where if I was extended an offer and decided to take it, I would walk away from a mega-company that I've been working at for twenty-five years.

Well I did get an offer. And it did pay more than my salary at the mega-company so I left the mega-company after twenty-five years. Pretty stupid ah? I left without taking an early retirement or downsizing severance package because I promised myself I wouldn't leave unless I had a comparable or better paying new job. The timing, of course, never worked out.

The position with the startup didn't last - the startup didn't have product or a viable idea for a product. I see that the startup's name is still mounted on the side of the building but I don't know how the startup could possibly be sustained at this point.

Nevertheless, I was a fifty-plus-year-old out of a job in the midst of Obama's utopian shrinking economy. That'll put a spring back into my step.

So what happened to me? Are you dying to know? You would be amazed.

Sunday, May 18, 2014

The Dreaded Software Job Interview

I was at a job interview the other week. It's something I dread. It's like taking tests in college, I just freeze up over the easiest of technical questions. I practically have to start counting with my fingers and toes. Also, while my brain freezes, my mouth starts to run, talking about all the observations and strange things that occur in the software industry and in my current job. These observations are sometimes perceived as painting me as being a maverick, someone who bucks the system, someone who is not optimistic and can drag a team down. This perception can't be further from the truth.

Many companies do a terrible job at evaluating candidates - and I'm talking about both small and mega companies. In a typical interview, there is usually the "How would you move Mount Fuji" type questions. That is, they want to see your thought process in approaching and attempting to solve an impossible task. For me, the problem is not the question, but that it's asked in a highly stressful situation. So in a sense it's a stress test. Here's the problem with a stress test for software engineering candidates: it's not reality. Good software choices can never be rushed and good software practises never come out of a stressed, quick-turnaround environment. Good software takes research, collaboration, a lot of rework, a lot of testing, making trade offs and back-of-the-mind, secondary, subconscious thought. The usual form is you take all of that and ram it into a time-table that in no way can resemble a schedule that can be depended upon. To me, the formulation and translation of tasks to scheduled releases is pure hocus-pocus - only managed by extraordinary individuals possessing great common-sense, experience (in regards to "real" software engineering) and patience. A good software engineer has to deny himself and quietly and quickly advance the judgement of others.

I have to tell to you though, I was very encouraged by this last interview. Why? Because one of my interviewers shared with me his thoughts about how so many software companies interview candidates wrong. Wow, I thought to myself, this guy gets it. I WANT TO WORK HERE!

I don't know if I'm going to get an offer but I hope I do. My opinions and observations that I can't help myself from expressing are opportunities. That is, opportunities to create something really special, to increase the efficacy of a project team or product, to meet customer needs, etc... Really, they're just problems that I observe and notice that might have a solution. A solution to implement and move forward from so that the next problem can be taken on.

If I get hired, I might start like going to work again. Wow, what a concept. (But really, I never stopped working.)

Saturday, April 26, 2014

I'm back.

I started reading a book entitled "Choosing Yourself" by James Altucher. The author is pretty eccentric. But I'm starting to implement what the author calls "Daily Practice." Why? Because I have to get out of my current blood sucking employment situation where I've been for twenty plus years. Yes, I'm a software developer working for a major corporation. James Altucher contends that the days of cradle-to-grave corporations are toast. That corporations really, really want to get rid of their cubicle employees (and remote employees, for that matter). And I see this on a daily basis, the desperation is thick.

I really need to stop blogging about politics and the stupid stuff I hear in the news. In fact, I have to stop watching the news because there is nothing I can do about it. It makes my head explode. Instead I'm going to blog about what I know about - me. HA! I choose me to blog about. AND GUESS WHAT - I'M MORE INTERESTING than the crap on the news. Just ask my friends. Accept for Chris, he's really an interesting tormented soul - maybe more about him later.

OK, let me talk about one of the many things that happened at work this last week. It's so funny and typical.

A colleague and friend of mine, who is the smartest guy I know, had to integrate a software change (get it in the finished product). However, the software change had to be matched in two software repositories. (For those not in the industry, a repository is where to place your supposedly finished, tested, and approved software changes so the changes can be bundled into the customer installable software product). If the software change was not matched in the two separate repositories, the change is rejected. So my brilliant friend submits the same change to repository A and then to repository B, because there is no way to submit to both A and B at the same time. The change is rejected with a grammatically and semantically incorrect error message that I wish I could share with you but I can't. So my brilliant friend submits the change to repository B and followed by repository A. Same rejection and error message. And as you could of guessed, there was only one person in the entire corporation that knew how to get around the problem. And yes, he wasn't available. I think my friend and I going to have tee shirts made with the text of the error message - IT WAS THAT FUNNY!

The tee shirt will go something like this:
"I work at a place where I get this error message:
[Error Message]
Can you help me?"

Going on sale soon. Please submit your orders.

A new business idea: a tee shirt company which makes tee shirts with real world examples of implemented gibberish. (Coming up with new business ideas is part of my "Daily Practice" - thank you Mr. Altucher)