Giter VIP home page Giter VIP logo

wmcsoft's Introduction

WmcSoft

This project contains classes and functions I found useful.

I try to respect the following laws, from "From Mathematics to Generic Programming", by Alexander A. STEPANOV and Daniel E. ROSE.

  • The Law of Useful Return: A procedure should return all the potentially useful information it compute.

  • The Law of Separating Types: Do not assume that two types are the same when they may be different.

  • The Law of Completeness: When designing an interface, consider providing all the related procedures.

  • The Law of Interface Refinement: Designing interfaces, like designing programs, is a multi-pass activity.

For now, all this code is a work in progress. Comments and questions are welcome.

To open the class designers, you may need to add ClassDesigner to the ProjectCapability element

Design notes

To improve readability:

  • Extensions methods calling extensions methods in the same class should be called as function.

      public static IEnumerable<string> Tokenize(this string self, char separator) {
          return Tokenize(self, new CharTokenizer(separator));
      }
    
  • Extensions methods yielding IEnumerable<T> should check the arguments and then return the result from an unguarded version. The unguarded version might be called separately from other places and the verification of the arguments will not be defered until the start of the enumeration. It serves two purpose: not only the unguarded can be called from other algorithms but also the validation of the arguments will be done right away and not when the enumeration starts.

      static IEnumerable<T> UnguardedBackwards<T>(IReadOnlyList<T> source) {
          for (int i = source.Count - 1; i >= 0; i--) {
              yield return source[i];
          }
      }
    
      public static IReadOnlyCollection<T> Backwards<T>(this IReadOnlyList<T> source) {
          if (source == null) throw new ArgumentNullException(nameof(source));
    
          return new ReadOnlyCollectionAdapter<T>(source.Count, UnguardedBackwards(source));
      }
    

    On a side note, it is unfortunate that the convention for a null this argument of the extensions should throw ArgumentNullException instead of NullReferenceException. Not only the latter is what calling a method on a null reference would throw but also we would not have to always guard for null. Anyway, we will follow this convention the Linq context. In all other cases, we prefer to throw NullReferenceException.

  • For readability, extensions methods should not accept a null this. If the method is defined when the first parameter is null, then the method should not be an extension method. using static.

  • Linq-like extensions methods should not mutate the enumerable, therefore ForEach on an enumerable is not recommended, as stated by Eric Lippert in “foreach” vs “ForEach”.

  • Operator overloads should provide the equivalent with a named function. Apparently, the framework does not have a clear policy on whether the function should be static or not. It is static for Complex but not for TimeSpan.

      public static Rational operator -(Rational x) {
          return new Rational(-x._numerator, x._denominator);
      }
      public static Rational Negate(Rational x) {
          return -x;
      }
    

Libraries

WmcSoft.Core

Library of extensions and helpers.

WmcSoft.Mathematics

Library of mathematical objects, such as Rationals, Vectors and Matrices.

The main goal is to have them easy to use. They are not aimed to be the fastest but I hope they will be fast enough.

WmcSoft.Units

Library of units and quantities.

WmcSoft.Business.Primitives

Library of primitives types to build business applications.

  • Time, adapted from http://domainlanguage.com's time & money:

    • TimePoint is equivalent to DateTime in GMT yet it is more abstract as it does not have accessors to its part.
    • DateTime, with a DateTimeKind.Unspecified, replaces CalendarMinute
    • TimeUnit should derive from WmcSoft's units.
    • newOfSameType() factory methods are not required for value types.

QuantLib also defines some time related types. The current implementation of TimeUnit is close to Period. The types might be merged.

Finally, it looks like a Date and TimeOfDay types are being added to the framework therefore the current design should be as close as possible to those.

WmcSoft.Business.Calendars

Library of utilities to manage business calendar.

classDiagram

    class BusinessCalendar {
    }
Loading

WmcSoft.Business

Library of components to build business applications.

  • Security

  • RuleModel

  • Party, PartyRole & PartyRelationship

  • ProductType, ProductInstance, Package

  • Accounting

WmcSoft.Jobs

Library to dispatch jobs. It predates the Task in .Net.

WmcSoft.Components & WmcSoft.Windows.Forms

Libraries of component and windows forms controls.

These are pretty much useless now, as the component model and the windows form are kind of deprecated.

I liked the whole component/designer concept, the idea that we can have different view of the code and how it helped building other component.

Yet, the first drawback I see is that it requires to shape the code in a specific way, especially mutating the component through properties. It made the component sometimes harder to implement, or lead to suboptimal implementations.
The second drawback is related to forms, user controls and inheritance because there is a conflict between access control and visual representation. How do you hide in code what is visible in display? How can you see controls and yet be unable to move them inside the form?

WmcSoft.Interop

Library of classes or functions encapsulating native functions.

WmcSoft.VisualStudio

Library to build custom tools.

This library also provide a declarative, policy based, code generator. The classes are defined in an XML file and then generated in CSharp.

WmcSoft.AI

Library of artificial intelligence algorithms.

This library is so far a collection of algorithm, initially converted from Practical Neural Network Recipes in C++, by Timothy Masters, and C++ Neural Networks & Fuzzy Logic by Rao & Rao.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.