Upgrade to Pro — share decks privately, control downloads, hide ads and more …

What__Why__How_Create_OSS_Libraries_-_過去に制作した30のライブラリから見るC_コーディングテクニックと個人OSSの原理原則.pdf

Yoshifumi Kawai
October 01, 2016
88

 What__Why__How_Create_OSS_Libraries_-_過去に制作した30のライブラリから見るC_コーディングテクニックと個人OSSの原理原則.pdf

Yoshifumi Kawai

October 01, 2016
Tweet

More Decks by Yoshifumi Kawai

Transcript

  1. class EqualityComparer<T> : IEqualityComparer<T> { readonly Func<T, T, bool> equals;

    readonly Func<T, int> getHashCode; public EqualityComparer(Func<T, T, bool> equals, Func<T, int> getHashCode) { this.equals = equals; this.getHashCode = getHashCode; } public bool Equals(T x, T y) { return equals(x, y); } public int GetHashCode(T obj) { return getHashCode(obj); }
  2. // (object x) => (object)((T)x).name static Func<object, object> CreateGetValue(Type type,

    string name) { var x = Expression.Parameter(typeof(object), "x"); var func = Expression.Lambda<Func<object, object>>( Expression.Convert( Expression.PropertyOrField( type.IsValueType ? Expression.Unbox(x, type) : Expression.Convert(x, type), name), typeof(object)), x); return func.Compile(); }
  3. #4 2010-04-30 http://dynamicjson.codeplex.com/ // Parse (JsonString to DynamicJson) var json

    = DynamicJson.Parse(@“ { ""foo"":""json"", ""bar"":100, ""nest"": { ""foobar"":true } }"); // "Json" - dynamic(string) var r1 = json.foo; // 100 - dynamic(double) var r2 = json.bar; // true - dynamic(bool) var r3 = json.nest.foobar;
  4. #4 2010-04-30 http://dynamicjson.codeplex.com/ // Parse (JsonString to DynamicJson) var json

    = DynamicJson.Parse(@“ { ""foo"":""json"", ""bar"":100, ""nest"": { ""foobar"":true } }"); // "Json" - dynamic(string) var r1 = json.foo; // 100 - dynamic(double) var r2 = json.bar; // true - dynamic(bool) var r3 = json.nest.foobar;
  5. public class DynamicObject : IDynamicMetaObjectProvider { public virtual IEnumerable<string> GetDynamicMemberNames();

    public virtual DynamicMetaObject GetMetaObject(Expression parameter); public virtual bool TryBinaryOperation(BinaryOperationBinder binder, object arg, out object public virtual bool TryConvert(ConvertBinder binder, out object result); public virtual bool TryCreateInstance(CreateInstanceBinder binder, object[] args, out objec public virtual bool TryDeleteIndex(DeleteIndexBinder binder, object[] indexes); public virtual bool TryDeleteMember(DeleteMemberBinder binder); public virtual bool TryGetIndex(GetIndexBinder binder, object[] indexes, out object result) public virtual bool TryGetMember(GetMemberBinder binder, out object result); public virtual bool TryInvoke(InvokeBinder binder, object[] args, out object result); public virtual bool TryInvokeMember(InvokeMemberBinder binder, object[] args, out object re public virtual bool TrySetIndex(SetIndexBinder binder, object[] indexes, object value); public virtual bool TrySetMember(SetMemberBinder binder, object value); public virtual bool TryUnaryOperation(UnaryOperationBinder binder, out object result); }
  6. public struct ConvertableString { readonly string value; public ConvertableString(string value)

    { this.value = value; } public static implicit operator Boolean(ConvertableString self) { return Boolean.Parse(self.value); } public static implicit operator Int32(ConvertableString self) { return Int32.Parse(self.value); } // ... }
  7. #16 2013-12-23 https://github.com/neuecc/LightNode public class My : LightNodeContract { public

    string Echo(string x) { return x; } public Task<int> Sum(int x, int? y, int z = 1000) { return Task.Run(() => x + y.Value + z); } }
  8. public enum RespType : byte { SimpleStrings = (byte)'+', Erorrs

    = (byte)'-', Integers = (byte)':', BulkStrings = (byte)'$', Arrays = (byte)'*' }
  9. List<T>.Enumerator構造体 再帰イテレーター is Evil IEnumerable<GameObject> Descendants(GameObject root) { yield return

    root; foreach (Transform item in root.transform) { foreach (var child in Descendants(item.gameObject)) { yield return child.gameObject; } } }
  10. #27 2016-06-07 https://github.com/neuecc/ObserveEveryValueChanged public partial class MainWindow : Window {

    this.ObserveEveryValueChanged(x => x.Width); this.ObserveEveryValueChanged(x => x.Height); }
  11. TBD

  12. linq.js, UniRx, LINQ to GameObject, LINQ to BigQuery LINQとは何であるかの掲示 ChainingAssertion

    流れるようなインターフェイスや英語的なるものへの反逆 ReactiveProperty MVVMへの異質なアプローチ NotifyPropertyChangedGenerator Roslyn時代のコーディング手法 LightNode, PhotonWire 現代的な観点でのRPCの再評価 ライブラリは思想の塊であり、 言葉だけよりも、むしろずっと 流暢に語ってくれる 言葉に、より強い証明、よ り強力な説得力をもたらす