Skip to content

Instantly share code, notes, and snippets.

@simpleprogrammer-shared
simpleprogrammer-shared / techniques-to-make-apis-easier-to-use-5.cs
Created July 20, 2016 04:15
3 Simple Techniques to Make APIs Easier to Use and Understand 5
public void LoginAsCustomer(LoginInfo loginInfo, CustomerType customerType = CustomerType.NEW_CUSTOMER, int numberOfTries = 3)
{
// ...
}
var loginInfo = new LoginInfo("Darth Vader", "ihatewookes");
LoginAsCustomer(loginInfo);
// What if we need to override a default? No problem.
@simpleprogrammer-shared
simpleprogrammer-shared / techniques-to-make-apis-easier-to-use-4.cs
Created July 20, 2016 04:14
3 Simple Techniques to Make APIs Easier to Use and Understand 4
public void ValidateCustomer(int maximumAge)
{
//...
}
ValidateCustomer(25);
// Using an Age class to restrict values
public class Age
@simpleprogrammer-shared
simpleprogrammer-shared / techniques-to-make-apis-easier-to-use-3.cs
Created July 20, 2016 04:13
3 Simple Techniques to Make APIs Easier to Use and Understand 3
public enum CustomerType
{
NEW_CUSTOMER,
REWARDS_CUSTOMER,
REGULAR_CUSTOMER
}
public void LoginAsCustomer(LoginInfo loginInfo, CustomerType customerType, int numberOfTries)
{
// ...
@simpleprogrammer-shared
simpleprogrammer-shared / techniques-to-make-apis-easier-to-use-2
Created July 20, 2016 04:12
3 Simple Techniques to Make APIs Easier to Use and Understand 2
public void LoginAsCustomer(LoginInfo loginInfo, string customerType, int numberOfTries)
{
// ...
}
var loginInfo = new LoginInfo("Darth Vader", "ihatewookes");
LoginAsCustomer(loginInfo, "New Customer", 3);
@simpleprogrammer-shared
simpleprogrammer-shared / techniques-to-make-apis-easier-to-use-1.cs
Created July 20, 2016 04:11
3 Simple Techniques to Make APIs Easier to Use and Understand
public void LoginAsCustomer(string userName, string password, string customerType, int numberOfTries)
{
// ...
}
// Code to call the method
LoginAsCustomer("Darth Vader", "ihatewookies", "New Customer", 3);
@simpleprogrammer-shared
simpleprogrammer-shared / techniques-to-make-apis-easier-to-use-1.cs
Created July 20, 2016 04:11
3 Simple Techniques to Make APIs Easier to Use and Understand
public void LoginAsCustomer(string userName, string password, string customerType, int numberOfTries)
{
// ...
}
// Code to call the method
LoginAsCustomer("Darth Vader", "ihatewookies", "New Customer", 3);
@simpleprogrammer-shared
simpleprogrammer-shared / getting-started-with-meteor-tutorial-7.js
Created July 20, 2016 04:07
Getting Started With Meteor Tutorial (In the Cloud) 7
Items = new Meteor.Collection("items");
if (Meteor.isClient) {
Template.list.helpers({
items: function() {
return Items.find();
},
doneClass: function() {
if(this.done)
return "done";
@simpleprogrammer-shared
simpleprogrammer-shared / getting-started-with-meteor-tutorial-6.js
Created July 20, 2016 04:06
Getting Started With Meteor Tutorial (In the Cloud) 6
Items = new Meteor.Collection("items");
if (Meteor.isClient) {
Template.list.helpers({
items: function() {
return Items.find();
},
});
Template.controls.events({
@simpleprogrammer-shared
simpleprogrammer-shared / getting-started-with-meteor-tutorial-5.js
Created July 20, 2016 04:05
Getting Started With Meteor Tutorial (In the Cloud) 5
Items = new Meteor.Collection("items");
if (Meteor.isClient) {
Template.list.helpers({
items: function() {
return Items.find();
},
});
}
@simpleprogrammer-shared
simpleprogrammer-shared / getting-started-with-meteor-tutorial-3.html
Created July 20, 2016 04:04
Getting Started With Meteor Tutorial (In the Cloud) 3
<head>
<title>Spartan TODO</title>
</head>
<body>
<h1>DO OR DIE!</h1>
{{> list}}
{{> controls }}
</body>