Skip to content

Instantly share code, notes, and snippets.

Avatar

simpleprogrammer-shared

View GitHub Profile
@simpleprogrammer-shared
simpleprogrammer-shared / techniques-to-make-apis-easier-to-use-5.cs
Created Jul 20, 2016
3 Simple Techniques to Make APIs Easier to Use and Understand 5
View techniques-to-make-apis-easier-to-use-5.cs
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 Jul 20, 2016
3 Simple Techniques to Make APIs Easier to Use and Understand 4
View techniques-to-make-apis-easier-to-use-4.cs
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 Jul 20, 2016
3 Simple Techniques to Make APIs Easier to Use and Understand 3
View techniques-to-make-apis-easier-to-use-3.cs
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 Jul 20, 2016
3 Simple Techniques to Make APIs Easier to Use and Understand 2
View techniques-to-make-apis-easier-to-use-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 Jul 20, 2016
3 Simple Techniques to Make APIs Easier to Use and Understand
View techniques-to-make-apis-easier-to-use-1.cs
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 Jul 20, 2016
3 Simple Techniques to Make APIs Easier to Use and Understand
View techniques-to-make-apis-easier-to-use-1.cs
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 Jul 20, 2016
Getting Started With Meteor Tutorial (In the Cloud) 7
View getting-started-with-meteor-tutorial-7.js
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 Jul 20, 2016
Getting Started With Meteor Tutorial (In the Cloud) 6
View getting-started-with-meteor-tutorial-6.js
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 Jul 20, 2016
Getting Started With Meteor Tutorial (In the Cloud) 5
View getting-started-with-meteor-tutorial-5.js
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 Jul 20, 2016
Getting Started With Meteor Tutorial (In the Cloud) 3
View getting-started-with-meteor-tutorial-3.html
<head>
<title>Spartan TODO</title>
</head>
<body>
<h1>DO OR DIE!</h1>
{{> list}}
{{> controls }}
</body>
You can’t perform that action at this time.