Was DI a dumb idea?
David Ford's Programming blog
by David Ford
1y ago
I am old and have written many apps with and without DI. I sometimes wonder if DI is a stupid pattern. This post explains why. DI was kind of born in the world of Java and OOP, at a time when we were possibly over-obsessed with OOP. I am a big fan of OOP. It really is the preferred paradigm for many cases. But not all. Services as objects One pattern that seems to be popular in Java, but less so in other language ecosystems, is using objects as “services”. That is, grouping service-type functions into a service class and then passing dependencies (like a jdbc DataSource) into th ..read more
Visit website
Fast, Easy Issue Reporting
David Ford's Programming blog
by David Ford
2y ago
This is kind of a no brainer, but if one has a software product or open source project, you want bug reporting and feature requests to be freakishly easy and fast. How do I know this? Because (perhaps selfishly) I often blowoff reporting issues simply because I don’t want to take the time. If reporting a bug is a 1 minute side track, I’ll do it. If it’s a 5 minute side track, I’ll skip it. If you have to choose “fast and easy” vs “require all sorts of tags and categories”, chose fast and easy. If you want customer feedback, make it fast and easy ..read more
Visit website
Make TypeScript/Webpack 4 Times Faster with line of config
David Ford's Programming blog
by David Ford
2y ago
I use TypeScript, React and webpack and my TypeScript has gotten very large. And very slow. Not in execution. But in the compile/bundle step. It’s particularly annoying when working on UI: Move a div 3 pixels to the left. Wait an eternity. That doesn’t look right. Let me move it a few more pixels to the left. Wait an eternity. Crap moved it too far. Wait an eternity. Let’s try one pixel to the right. Wait an eternity. You get the drift. But this one tiny, tiny change made the process 4 times faster. All I did was, in webpack.config, change this line: use:"babel-loader" to this ..read more
Visit website
React Text Input Losing Focus After Each Keypress
David Ford's Programming blog
by David Ford
2y ago
This bug took me a while to figure out, so I thought I would share the cause and the fix. I had a simple text input on a form. And if you typed, say an ‘r’ into the that text input, it would display the ‘r’ and then the focus would jump elsewhere. Not really sure where. But no longer in the text input. Thus the second character they typed would not show up. If you wanted to type a whole word, like “foo”, you would have to type an ‘f’. Then click back into the text input. Then type ‘o’. Click back into the text input. Then type the final ‘o’. Obviously that is messed up ..read more
Visit website
React Text Input Losing Focus After Each Keypress
David Ford's Programming blog
by David Ford
2y ago
This bug took me a while to figure out, so I thought I would share the cause and the fix. I had a simple text input on a form. And if you typed, say an ‘r’ into the that text input, it would display the ‘r’ and then the focus would jump elsewhere. Not really sure where. But no longer in the text input. Thus the second character they typed would not show up. If you wanted to type a whole word, like “foo”, you would have to type an ‘f’. Then click back into the text input. Then type ‘o’. Click back into the text input. Then type the final ‘o’. Obviously that is messed up ..read more
Visit website
One Area Where Pair Programming is a Waste
David Ford's Programming blog
by David Ford
2y ago
We like pair programming. But for everything. One area in particular is tweaking the UI. Especially on large systems where each tweak involves a long compile time (as in TypeScript or Android). Move one pixel to the left. 3 minutes to compile. Two pixels to the right. 3 minutes to compile, ad Infinitum. What are some other, fairly clear cut examples where pairing is less than optimal. Note: The above recommendation totally disregards the fact that I am color and design challenged and may need to pair in that respect ..read more
Visit website
Is Readable Code Bullshit?
David Ford's Programming blog
by David Ford
2y ago
To me the answer is half yes and half no. Almost every day, someone is telling me that this or that code is not clean. Not readable. Not maintainable. But there are some gaping logic farts with this whole concept. Any teacher knows it is vitally important to know your audience. A talk that is spot-on for one person may be completely incomprehensible to another. The same is true for code. As a teacher of code, I can’t count the number if times I have showed the class some new language feature/pattern/idiom only to have some student inform me that they will not be using said ..read more
Visit website
JetBrains Pulls out of Russia
David Ford's Programming blog
by David Ford
2y ago
This makes me so happy. I have built my career around JetBrains. Of any software company on the planet, JetBrains has always been the one I admired the most. https://blog.jetbrains.com/blog/2022/03/11/jetbrains-statement-on-ukraine ..read more
Visit website
Prevent Double-Click Dups in React
David Ford's Programming blog
by David Ford
2y ago
Prevent Double-Click Dups in React ..read more
Visit website
Language Injection IntelliJ
David Ford's Programming blog
by David Ford
2y ago
IntelliJ has the ability to treat a String literal as a language (SQL or RegEx, for example). And then, within that String, IntelliJ will provide syntax coloring and auto-completion for the language specified. Here is what it looks like in action: JetBrains calls this Language Injection. All you have to do is tell IntelliJ what language you are trying to type in your string literal. There are a number ways, but here are my 2 favorites: 1. In Preferences The prepareStatement method (from java.sql.Connection) takes 1 argument of type String. But more specifically, one argument of type ..read more
Visit website

Follow David Ford's Programming blog on FeedSpot

Continue with Google
Continue with Apple
OR