Script & Style Show: Episode 5: Q&A

On this week’s episode:  Todd’s back from vacation while David’s knee-deep in a Firefox Debugger breakpoint UI update.  We eventually move on to viewer questions that range form JavaScript knowledge, the Array.flatten controversy, front-end testing (TDD vs. BDD), and mastering work-life balance.  Enjoy! As always, please get in touch if you have episode topic or […]
The post Script & Style Show: Episode 5: Q&A appeared first on David Walsh Blog.

Link: https://davidwalsh.name/script-style-show-5

Tracking Uncertainty of Work

Ryan Singer writes about project and time management issues that I’ve been experiencing lately. He describes two states of every project: uncertainty and certainty, or “figuring things out” and “making it happen.”
Ryan describes it like this:
Work is like a hill with two sides. There’s an uphill phase of figuring out what to do and how to approach the problem. That’s the climb. After you reach the top, there aren’t anybody [sic] ruinous unknowns. You can see down to …
The post Tracking Uncertainty of Work appeared first on CSS-Tricks.

Link: https://www.feltpresence.com/work/hill-climb

Depending on Functions Instead of Interfaces: Why and How

Here’s a simple, contrived example of a class that depends on an interface, IDoesMath, followed by the same class modified to depend on a function instead. As you’ll quickly see, there is no immediate benefit. The change doesn’t make this a better class. So are there any benefits to depending on functions rather than interfaces? I think that at least in some cases, depending on functions has potential to improve the long-term maintainability of our code (Can I be any more careful to qualify that statement?).
Depends on an Interface
public class ClassThatDependsOnMath
{
private readonly IDoesMath _math; // interface

public ClassThatDependsOnMath(IDoesMath math)
{
_math = math;
}

public Single Calculate(Single value1, Single value2)
{
return _math.DoMath(value1, value2);
}
}
Depends on a Function
public class ClassThatDependsOnMath
{
private readonly Func _doMath; // function

public ClassThatDependsOnMath(Func<Single, Single, Single> doMath)
{
_doMath = doMath;
}

public int Calculate(Single value1, Single value2)
{
return _doMath(value1, value2);
}
}
Again, I don’t see a compelling difference. The interface actually makes it a little bit easier to see what the dependency does (more on that later.) So why would we ever consider the second approach?

Link: https://dzone.com/articles/depending-on-functions-instead-of-interfaces-why-a-1?utm_medium=feed&utm_source=feedpress.me&utm_campaign=Feed%3A+dzone%2Fwebdev