James Hickey's Blog

Looking At Software Related Ideas Using Short And To The Point Code Samples :)

Menu Close

Page 2 of 2

Functional Programming With C#: Simple Use Case

Update: I created a YouTube video based on this post, if you are interested….

During the past year and a half I have been making a point to learn about and develop my skills in functional programming. For the majority of this experience, I have been using JavaScript and TypeScript. After moving onto another project at work, I was brought back to “C# and SQL world.” Long story short, I noticed the way I was thinking about software problems in C# were totally different than before.
Read more

Code Smell: Stinky Managers

In software development, indications of “bad” or poorly designed code have been given the title of “code smell(s)”. If it smells bad, it is probably bad. One of the smells I’ve learned to identify is what I’ll call “Stinky Managers.”

This smell is easily identifiable – in software code, if you see anything post-fixed with “Manager” – it probably stinks. Read more

Tips For Readable And Maintainable Unit Tests In JavaScript / TypeScript

I’ve started using ts-jest for a project at work and have really enjoyed it. It works great because you can write your tests in TypeScript and ts-jest will just compile on-the-fly then run your tests like you would expect. However, tests can easily become unreadable or harder-to-read (which isn’t limited to ts-jest, of course).

Improving Readability

In order to make the tests more readable, I am creating generic functions that I can re-use in my test cases. Read more

TypeScript Decorators: Bind Constructor Parameters Automagically

The more I use TypeScript the more I really like it. I’m starting to use the advanced features – and realize how powerful they are. TypeScript decorators are one of those fantastic features that let’s you automate common tasks and apply them in a sort of “meta-programming” fashion.

One of the use-cases I built for a project at work was a class decorator to automate binding a constructor’s parameters as properties on the new object. Read more

It’s The Little Things In Life: Gulp Notifications

I needed a way to issue notifications from gulp / node…

I always have a command line open so I can manually run my gulp tasks. For the project I work on the most at work, our gulp build (on a fast machine) takes around 6 seconds – we’re compiling TypeScript into JavaScript, transpiling that into ES5 compatible code, concatenating third-party scripts, compiling SASS into CSS, adding third-party stylesheets to that, etc. So I suppose 6 seconds isn’t too bad…

When making a tiny change to see if I fixed a bug, or to see a SASS mixin render in the browser, etc. – 6 seconds is a long time to wait until I can refresh my browser. And yes, I’ve tried browser sync – it doesn’t work with our set-up.

And, I found npm package “node-notifier” to be perfect. Read more

Using TypeScript Decorators To Clean-Up Mixins

Lately I’ve been migrating a JavaScript framework I built (for a work client) over to TypeScript. The core UI components are built using mixins. Using jQuery extend(), the JavaScript code would have done something like:

var TextBox.prototype = $.extend({ ...some object with functions and state....}, CanDoExtraStuff, CanDoOtherCoolStuff);

One of the first things I was hoping TypeScript would allow was to clean this up and make it clearer what was going on.

Read more

© 2018 James Hickey's Blog. All rights reserved.

Theme by Anders Norén.