But I needed to update a form field regex validation, so I tackled it head-on and won.
As a side note, regular expression creation is also one of the best examples of where Test Driven Development (TDD) works well. You really cannot create or maintain a regex without having all the test cases written first.
For a value entered in the field, it:
Cannot start with a space.
Cannot end with a space.
May contain a one or more sapces (surrounded by other allowed characters).
May also contain the following characters: A-Z, a-Z, 0-0, “-“, “_”, “\”, “/”.
If a value is entered in the field the total character count may be from 1 to 20 characters.
If the string contains only 1 character, ensure it is a valid character.
OR, for the second set of 3 groups:
Ensure the first character is a valid character.
Ensure 0-18 of the next characters is a valid character.
Ensure the last character is a valid character.
The combination of point 2.1, 2.2 & 2.3 handle scenarios of 2 up to 20 characters.
kkdkd df sdf lk aj33<-- Pass
kjlf l-Ka034-/\_ kj0<-- Pass
adsfdsafsdaf dsfsdfa<-- Pass
adsfsdas sdafsdafsa<-- Pass: Contains multiple spaces in a row
- dsf<-- Pass
_ sdfjlksdaflk jasdf<-- Pass
123456789012345678901<-- Fail. More than 20 charactesr
asdf<-- Fail: Starts with a space
adsfsdas sdafsdafs#<-- Fail: Ends with a #
adsfsdafsdfsdfsadds<-- Fail: Starts with a space
dfsdafljkasdfklsdsd <-- Fail: Ends with a space
#<-- Fail: Invalid character only<-- Fail: Space only
2 <-- Fail: Ends with space
2<-- Fail: Starts with a space<-- Ignore: Blank line
I’m working on a project that uses ‘webpack’. After pulling in a code update that required developers to clear out node_modules and update yarn, I started receiving the following prompt when running webpack:
The CLI moved to a separate package: webpack-cli Would you like to install webpack-cli? (That will run yarn add -D webpack-cli) (yes/NO)
(I found running this – even manually running the yarn command – didn’t actually install the CLI and in fact, produced further errors).
Even trying to return the webpack version raised the prompt:
The problem, I have been told, is the version of webpack being loaded with “npm install -g webpack” was higher than the version we actually wanted and included ‘webpack-cli’ being split into a separate package. Specifically, we want to work with version 3.8.1.
This is a quick post inspired by a problem I helped a colleague with yesterday.
The problem is a “date.getFullYear is not a function” error was thrown when calling getFullYear() on a TypeScript Date object.
This was happening when the Date object was populated from a deserialized JSON string and the deserialization was silently failing in the background in the app.
It happens due to the format of the date string, and on top of that, the string is in the format “dd/mm/yyyy” (the short date format used by most of the world)..
How do we fix this?
There are 2 parts to the answer:
We need to explicitly set the target/deserialized date variable/field to a Date()
i.e. myObject.myDate = new Date(“date-string-in-accepted format”);
For example: myObject.myDate = new Date(“05/18/2018”).
Ensure the string we are passing into the Date() object is in an allowed format (best format is ISO: yyyy-mm-dd).
myObject.myDate = new Date(“2018-05-18”) – using ISO date format.
myObject.myDate = new Date(“05/18/2018”) – using US date format.
Below you can see it a quick running code sample I whipped up to demonstrate this.
Play around with commenting.uncommenting the “json = “…”;” lines and the “let dataObject: DataObject = JSON.parse(json);” line.
NOTE: You can pop the editor open in a new window by selecting “Edit On StackBlitz” in the bottom-left of the inserted window.
Select the folded-page icon at the top of the left column (below the StackBlizt blue/white icon) to see the list of files.
A common example is a function or short comparison statement you write and pass into a function on a list that then performs a mapping or reduction on the list (e.g. to find a subset of items in the list that contain the value(s) your predicate function or statement is checking for).
For example, if I have a list or array of People objects and each object has an Age property, I can write a predicate …
(Person p) => (p.Age >= 18)
… that I pass into a select() function on the list to return only those people who are age 18 or older.
var australianDrinkingAgePeople = fullList.Select(Person p => p.Age >= 18);
In this case, it’s a shortcut for writing your own big for loops and if statements over the list (although there’s nothing to say that the select() statement doesn’t implement that logic behind the scenes).
It’s nice to know you can still discover new things after 20 years in the industry.
Last week while investigating a defect of some data import work I’d done in SQL SERVER, one of my initial steps was to query the database for the imported records. For example:
SELECT * FROM [MyTable] WHERE [SomeField] = ‘SomeValue’;
That’s a standard, simple query. Nothing tricky about it.
However, what I had already discovered from inspecting the value returned to the application that uses it, is my value actually had a trailing space (i.e. ‘SomeValue ‘).
What surprised me was when I ran the query above it still returned the record.
That is: [SomeField] actually equals ‘SomeValue ‘ (with a trailing space) in the database record, yet my comparison to ‘SomeValue’ (no trailing space) still returned the record.
It turns out this is a quirk of SQL SERVER’s implementation of SQL.
It also turns out in all my years working with databases I must have been cleansing my data enough to never encounter this (in this instance I was generating SQL statements in Excel and was explicitly told not to touch import values [some of which included an incorrect trailing space]).
An embedded page at widgets.wp.com says
Request failed. Returned status of 404
It turns out I’m not the only one with this issue (as this WordPress Support page indicates) and the problem looks to be coming from the JetPack plug-in.
After finding a few keywords on that support and testing on my own site, it turns out the problem is being caused by the “Show Likes.” feature on the post:
Untick the “Show Likes.” option and save the post again and the problem goes away.
Now we just need to wait for a fix from JetPack (which seems a bit slow coming).
These are my views and approaches on leading software development teams and managing people in general. They come from the culmination of a few years of on-and-off leadership, and a lifetime of observation (plus a share of suffering under poor regimes along the way).
In no particular order:
Work for your team.
Protect your team.
Never pass problems down the line.
Don’t talk about money with the team. They don’t need to know if the project is running over budget. They don’t even need to know the budget. That’s a management concern, not a worker’s concern.
(Definitely, don’t use budget issues as a motivator to make the team work more.)
Push back on upper management if their requests and expectations are unreasonable.
Give the team the tools they need to do their job.
Don’t be cheap on tools and equipment. Supply computers with appropriate specifications, decent chairs, multiple monitors.
Give the team the information they need to do their job.
Give the team the support they need to do their job.
Don’t reprimand people. Be a “guide” for team members not performing to your standards.
Be very clear about standards and KPIs if you’re going to hold people to them.
If someone is not performing to a standard you expect, talk with them, work with them, help them be better. Raise the issue and talk to them early (don’t wait until the annual performance review).
Leadership and management will mean tough, icky conversations. If you don’t have the stomach for that, don’t do the job. Skirting tough conversations is dangerous for the team and work outcomes.
Don’t set estimates when you already have a deadline in mind. Just say the deadline and work with the team to figure out how to deliver.
Don’t ask for estimates then hold people to it (Dr Evil style). It’s called an estimate for a reason.
Software estimation is hard. Really hard. Really, very hard. Always remember that.
Be clear about deadlines. And why the deadline was set.
Realise that almost every single software delivery deadline set by business is arbitrary. And will slip. And people will burn out and get angry pushing to deliver for a deadline that slips anyway.
Agile “story points” only work in true agile projects that don’t have time-based deadlines. Those projects are rarer than hen’s teeth.
If you’re going to hold a team to story point velocity, you’re doing it wrong (and everyone better be very clear from day one what the real effort of a point is).
You have smart, capable people in your team. Let them think and contribute.
Team discussion is good, healthy, and expected.
After the discussion, the decision at the end of the day is yours. That’s part of your responsibility.
Don’t dictate to people. Direct and guide.
Good leaders realise they have a team of smarter people or capable people, and enable the team to do good work. That’s the job of a leader – enabling.
Don’t allow or make people feel guilty about mistakes.
Understand the hurdles people face. Understand their problems. Understand the blockers.
Understand what’s slowing people down. It’s not about working people like slaves but making sure the natural pace is not slowed down (e.g. by inadequate equipment, poor process, lack of understanding, stress bubbling from management).
Don’t push people like slaves.
People are people, not resources. Never call a person a resource.
Praise goes to the team. Blame stops with leaders (never pass blame down to the team). A leader’s reward for a job well done is internal satisfaction.
Software developers need time to breath, take a break, and refresh during the day. And during the week. And periodically over a long, hard project.
Software coders should not be in front of their computer coding 8 hours per day. If they’re doing that then something is wrong.
Working software developers hard for long periods will lead to burn-out and discontent.
I don’t believe a rewards or hall-of-fame type system should exist for people who do extra work (hours) or produce extra stuff. That a) is the encouragement of overtime and, b) isolates the 90% of good people just getting their job done.
Don’t ask for overtime. Ever. (Unless you can absolutely guarantee a time-off-in-lieu soon after the reason for overtime has passed). Overtime just means fuck-up somewhere up the management or sales chain that software developers are going to pay for by fixing it.
Ask what people enjoy doing and want to do. What motivates people? What are their interests?
Give people training.
Give people support in career progression.
Don’t presume you know everything as a leader/manager – you don’t. Don’t presume you have all the answers – you don’t. That’s not your job.
Leaders don’t need to know everything. That’s why you have a team.
A leader’s job is to have enough knowledge and experience to ask the right questions, trust their staff, do research and make good decisions.
Draw the best knowledge, experience and ability out of people in the team.
A leader needs to be “people” person. They need good social and communication skills. They need empathy and reflection. They need patience and a thick skin.
Managers also need at least some of this.
Never assume a team member has a certain level of knowledge, especially in software languages, technology and tooling. For example, don’t assume everyone has the same level of Git knowledge (I recently made that mistake and had to correct it). Keep asking questions – basic questions – to understand everyone’s knowledge and comfort levels.
Don’t talk “at” people.
Don’t talk over people.
Don’t micromanage your team, even those who are slow or make mistakes. Micromanaging is just a band-aid. If there’s a problem, work at finding and resolving the root cause – whether it’s a change of process, education or allowing someone time to learn and practice a new way of thinking and working.
Often a problem one person is having is a [silent] common problem across a team.
A soldier needs to learn to shoot a rifle on their own. Different soldiers need different paths to reach proficiency. A leader’s job is to help each person on their own path, so when the time comes to use the rifle each soldier can do it on their own without a leader on their shoulder telling them what to do.
Keep processes simple.
Keep simple checklists.
Keep help easy to find.
Think like soldiers and pilots.
Document. Document. Review. Document.
Never stop thinking about how to improve processes, information, and team conditions.
Never bring your ego.
Don’t elevate a good senior technical person to a lead role that they’re not prepared for, wanting to do, or able to do.
I’ve seen too many good “senior developers” with poor people skills placed in a lead role that end up hurting teams (at worst the team and project becomes toxic).
Leave technical people in technical roles.
This is a problem that had me stumped for a moment today until I searched and found the answer.
I was using Excel functions to generate SQL INSERT scripts in Excel for a database import.
It was working fine until suddenly each cell I copied from Excel pasted with a double-quote (“) around the value.
The first answer to my Google search made we realise the problem: I’d added a line-break in the middle of my formula to help while I was constructing a SQL query. It turns out when you add line breaks to cells in Excel, copied values are surrounded by quotes.
This actually makes sense when you think about it (think about it in the context of working with CSV files). It just didn’t occur to me because I’d never encountered them in this context.
Remove the line break and no more quotes being added to the copied values.
You really should be using 2 Factor Authentication (2FA or MFA) in your online accounts whenever it is available, especially if you re-use your passwords across accounts. Regardless, it’s a good extra layer of security to help protect your important assets.
For all Google’s greatness their documentation, like documentation of most large (and small) tech companies, is good but still hard to find and navigate through unless you know what you’re looking for (in fact most tech companies product zero to atrocious documentation in my humble opinion).
Here are 2 links to Google Support to help you get started with 2FA on your Google accounts:
With Google/GSuite accounts you can setup 2FA using: one or all of SMS, phone call, the Google Authenticator app (Play Store / iTunes), and downloadable one-time backup codes (store those in your password manager, like LastPass or 1Password. You have one of those, right?).
I particularly like the Google Authenticator app. It’s really easy to use and other services use it to (e.g. Evernote, Dropbox and DigitalOcean).