Posted 10 hours ago

fuckyeahterminals: C# is a sink for language features

fuckyeahterminals:

Sort of a throw back to This Post About Conditionals since the learning curve is “high” for Haskell, I thought I’d bring it to you in a language you might be more familiar with.

For those of you that know python or haskell this is what the commands look like

Python   Haskell   C#    
map       map        Enumerable.Select
filter       filter        Enumerable.Where
reduce   foldl        Enumerable.Aggregate

So in C# it would look a little something like this.

Func<int, bool>[] conditions = { (x) => x <= 100, (x) => x > -3, (x) => x != 5 }; 
int toTest = 10;
IEnumerable<bool> results = conditions.Select(f => f(toTest));
bool meetsRequirements = results.Aggregate((x, y) => x && y);
if (meetsRequirements)
{
   //Do Stuffs
   System.Diagnostics.Debug.WriteLine("Met Requirements");
}    

Alright so what’s going on here…

Because function aren’t first class in C# there’s a little prep work that needs to be done.

First you’ll notice the Func<int, bool> signature, this is how it handles Functions, it says this is a Function object that takes in an integer and returns abool. You’ll notice I can call .Select on an array, that makes sense because an array is enumerable and therefore allows me to use the interfaceIEnumerable. Here’s where I feel things get murky, I have to catch the results of the select into an IEnumerable, I can’t catch it in an array of bool, that’s some OOP bullshit right there, fine, whatever. and then I can foldl it or “.Aggregate” it by and to see if it meets all my requirements.

I feel this is cleaner and more concise, especially in the case of validation for weird business logic, you can feed a list of (field, type) tuples that you can insert into various conditions that would give you a clean result. As opposed to writing if statement after if statement after if statement….

Posted 1 month ago
Posted 1 month ago

femfreq:

When I opened the latest issue of Game Informer magazine I was surprised to see a quote from my own GDC talk “Equality or GTFO: Navigating the Gendered Minefield of Online Gaming Spaces.”  

The section titled “Overheard at GDC” features many female voices including Robin Hunicke, Brenda Romero, Susan O’Connor and Elizabeth Sampat discussing their desire for a more inclusive gaming industry.

“With thousands of programmers, animators, and producers in attendance, the Game Developers Conference is a great place to take the pulse of the industry.  This year, much of the chatter had to do with challenging the game industry to move out of its comfort zone, whether that be escaping well-worn game design conventions, embracing more diverse characters, or making the development culture more inclusive to women.”

Posted 1 month ago
The 11 in C++ 11 refers to the number of legs [..] nailed onto the dog whilst attempting to build a better octopus.
Posted 1 month ago

blurintofocus:

shananaomi:

noirbettie:

mightyhunter:

This 17-Year-Old Coder Is Saving Twitter From TV Spoilers

Imagine you forget to watch a new episode of Game of Thrones the night it airs. Even if coworkers stay mum about important plot points, Twitter is abuzz with spoilers. Fortunately, there’s Twivo, a new program that allows Twitter users to censor their feeds from mentioning a certain TV show (and its characters) for a set time period. Jennie Lamere, a 17-year-old girl, invented the software last month—and won the grand prize at a national coding competition where Lamere was the only female who presented a project, and the only developer to work alone. Internet: Meet the reason we need more women in tech.

(From Mother Jones)

I’m so excited by all of the teenagers in science and tech that we’re hearing about these days. MORE GIRLS PLEASE! 

At SXSW, we talked about how we can’t wait to see the apps fangirls create to make the internet further work the way THEY want. What we may have not said so clearly is that it’s really the way that EVERYONE wants the internet to work. Go girl.

^^^  so into this.

Posted 1 month ago
Posted 2 months ago
git-animals:


git checkout -b refactor

git-animals:

git checkout -b refactor

Posted 2 months ago

Unittests should follow the F.I.R.S.T. rules

  1. Fast: test should run quickly. If the method you are testing depends on a time consuming operation, mocking this will speed up the test enormously.
  2. Independent: any test could be run at any time and all test should run in any order. This is probably where mocks help less.
  3. Repeatable: test should be repeatable in any environment and at any time. Stubs are the best friends in this case: not only you can run them in any environment but you can easily reproduce any scenario.
  4. Self-validating: the success of a test should be determined in an automated way. In the case you want to make sure a certain operation has been invoked, expectations are probably the only way to go.
  5. Timely: unit test should be written just before production code. Once again, the impact of mocks is huge! They allow to test methods which depend on code that has not been implemented yet. Even more, they allow to test methods which depend modules that have not been designed at all! By using something that does not exists yet, you can design it from the perspective of the client. In this case the client is the System Under Test. This allows you to design API which simple, easy to use and tailored for the client's needs. This technique is called interface discovery"
Posted 3 months ago

Instacode - the instagram for code :)

Posted 3 months ago

vilcins:

Twitter’s Oscar Boykin: Programming Isn’t Math.

Functional programming has a rich history of drawing from mathematical theory, yet in this talk, Twitter data scientist Oscar Boykin make the case that programming is distinct from mathematics. This distinction is healthy and does not mean we can’t leverage many results and concepts from mathematics.

As examples, Oscar will discuss some recent work — github.com/twitter/{algebird,bijection,s­calding} — and show cases where mathematical purity were both helpful and harmful to developing products at Twitter.

(Source: )