Software Development

New Horizons

I am pleased to announce the completion of a recent side-project. This side-project is also the reason for my hiatus over the last few months. I have been looking for a new blogging platform.
I sought finer control of the site, and the satisfaction that comes with doing-it-yourself.
I found this happy medium in a static site generator called Hexo. It took some time to find a generator I was comfortable with. Then it took time to actually transition my blog. And finally it took time to sort out hosting. All in all, I spent about a week actually doing code stuff. I spent the rest either researching generators, or finding the right host.
To my delight, I have enough material to populate a blog series. If the topic interests you, I invite you to my new blog site: daniel.scheufler.io for the rest of the series.
Until then, I would like to leave you with this blessing, in case we are here parting ways: ‘
May the road rise up to meet you.
May the wind be always at your back.
May the sun shine wamr upon your face;
the rain fall soft upon your fields
and until we meet again,
may God hold you in the palm of His hand. ‘
– Old Irish Blessing
Advertisements
Standard
Work Projects

TechFest Fall 2018

My Blog has moved! You can find my latest content at daniel.scheufler.io!
The kind organizers of Houston TechFest recently announced the speakers. I am pleased report I am among their number! I am stoked for the event, and will be presenting on the following:
  1. Designing and Running Effective Meeting
    • Do meeting at your company drag on and on and on… ? Do you wish they’d get to the point already? Have you ever had to have a meeting after the meeting to make the real decisions? What if there was a way to fix this broken process? What if we could make meetings effective again? Come learn some guiding principles to help make your meetings more effective, and not just the ones you lead! Tips include how to organize your meeting, how to help ensure decisions are made, and suggestions for follow-ups to communicate the decisions, so they don’t die in the meeting!
  2. Web UI Testing? Yes, You can! – Co-presenting with Claudio Lassala
    • Those back-end guys really seem bought into this TDD idea. What with their interface mocking and SOLID design principles. But is such a thing even possible in the Front-End? Besides everyone knows UI tests are painfully slow!
    • Guess what ?! Not only can TDD be used in the Front-End, it will improve your designs, just like it does in the back-end. What’s more is you can do with without having to write laboriously slow UI tests! Come learn how to improve the design of your React Components and Redux Store using TDD Best practices, and see why mocking is even easier in Javascript than it is in C#!
  3. Demystifying the Whiteboard Interview
    • Its no secret that Whiteboard interviews are widely panned by the industry. Just as well known is that you will inevitably have to face one every-time you interview. But why? There must be some pattern or principle that can be learned to make the process less unpleasant, right? Indeed there is! Come learn some simple steps and tool you can use to improve your next whiteboarding interview!
Looking forward to seeing you all there! More information on the conference is available at their website. And don’t forget to pre-register!
P.S. If you haven’t seen Claudio speak, I highly recommend attending one of his User Group presentations! Plus his blog has some great stuff too!
Standard
TodayILearned

TIL… How to test a window-redirect using Mocks

My Blog has moved! You can find my latest content at daniel.scheufler.io! Please continue reading here.

I was testing an action, which upon completion needed to redirect the user to a new page. Normally, in javascript you can redirect using :

window.location = "newPath";

But that’s hard to test for. Thankfully there is a better way:

window.location.assign("newPath");

You can then mock the assign function and test for that call! My thanks to the creators of jest for that insight!

Standard
TodayILearned

TIL… How to run a single suite of Tests in Jest

So I was writing unit tests for my reducers, but got frustrated with the slow process of running the full test suite when I was tweaking a single test. I though, there’s got to be a better way!

To the Internet! And TaDa, there was! Once you install Jest globablly, you can run a simple command to select the suite or suites you want to run:

jest –runInBand “{matchString}”

This command will run any file whose name matches the given string. So if you wanted to run all the tests associated with the SuchAndSuchModule. You could use:

jest –runInBand “SuchAndSuch*”

My thanks to be brilliant folks who answer stack-overflow questions! You can find the answer I did here

Standard
TodayILearned

TIL… How to Resolve false-positive ESLint Errors

So a colleague of mine was struggling with our local build process. Every time he ran the npm command, which ran a webpack build, He’d get numerous errors for ‘import/no-unresolved’. The associated message would complain that the file casing did not match the underlying file system.

As it turns out, the warning was technically correct. When we checked his command line, we found that the interface reported the folder name with a lowercase. To be clear the folder, as it existed in the file system, was capitalized. So we spun up a new CLI, and tried it with a capitalized version of the folder. Lo and behold, it worked perfectly.

Be sure to check your CLI, when a command returns with very odd errors.

Standard
TodayILearned

TIL… How to use ToDictionary

So I was creating a bulk action in a controller. I needed to map a list of Ids to a dictionary of said Ids and their respective results. My initial thought was to use ForEach, but there was a great deal of unnecessary boiler-plate code involved. There had to be a better way. And of course there was.

Naturally the ToDictionary function was invented by brilliant minds in anticipation of such a need. Here’s a rough example:

listOfId.ToDictionary(key=> key, value => MethodtoGetValue(value,otherParams));

Note that the key, and the value both come from the entry in the List, and are used to create the resulting key-value pair. Meaning that you could create a Key and a Value from functions that use the list entry as an input.

Standard
TodayILearned, Work Projects

TIL… How to use Map and Reduce

While working on a React app, I needed to translate a bit of Redux shape into one needed by an Api. Due to the normalization we imposed on the Redux state, I had to navigate to the desired information through s couple of lists. These entities each had a list of ids of children, and I needed the grand-children of a given entity.

Instead of manually composing this list, I found map and reduce were far better suited to the task, as you might imagine. In order to get the list of grandchildren, I first mapped the list of children ids to a list of lists of grand-child ids. These lists were accessed through the children. Then I took the list of lists and reduced it , effectively merging it into a single, long list of all grandchildren. Helpful hit, always include an initial value for the list. It helps avoid bugs when inputs are empty. Finally I mapped the list of grand-child ids to the grandchildren themselves.

As an experiment I did try to manually iterate through the lists without Map and reduce, and found that those three lines replaced something like 12-15 lines. Further, the 12-15 line code was… obtuse at best. Got to love it when succinct code is also easier to understand.

Standard