Single Value Objects as C# structs

Slides:



Advertisements
Similar presentations
STRING AN EXAMPLE OF REFERENCE DATA TYPE. 2 Primitive Data Types  The eight Java primitive data types are:  byte  short  int  long  float  double.
Advertisements

Pointers Prasun Dewan Comp 114.
CHARLES UNIVERSITY IN PRAGUE faculty of mathematics and physics C# Language &.NET Platform 6 th Lecture Pavel Ježek
C# Language Report By Trevor Adams. Language History Developed by Microsoft Developed by Microsoft Principal Software Architect Principal Software Architect.
Composition CMSC 202. Code Reuse Effective software development relies on reusing existing code. Code reuse must be more than just copying code and changing.
C#: Data Types Based on slides by Joe Hummel. 2 UCN Technology: Computer Science Content: “.NET is designed around the CTS, or Common Type System.
 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
1 Chapter 4 Language Fundamentals. 2 Identifiers Program parts such as packages, classes, and class members have names, which are formally known as identifiers.
3. Data Types. 2 Microsoft Objectives “.NET is designed around the CTS, or Common Type System. The CTS is what allows assemblies, written in different.
Integer, Floating-Point, Text Data, Variables, Literals Svetlin Nakov Telerik Corporation
Programming in C# Language Overview
3.1 Documentation & Java Language Elements Purpose of documentation Assist the programmer with developing the program Assist other programers who.
Comp 248 Introduction to Programming Chapter 4 - Defining Classes Part A Dr. Aiman Hanna Department of Computer Science & Software Engineering Concordia.
Introduction to Java Appendix A. Appendix A: Introduction to Java2 Chapter Objectives To understand the essentials of object-oriented programming in Java.
.NET Data types. Introduction ٭ A "data type" is a class that is primarily used just to hold data. ٭ This is different from most other classes since they're.
Variable, Expressions, Statements and Operators By: Engr. Faisal ur Rehman CE-105 Fall 2007.
EXACT ONLINE APP CENTER THE ROADMAP Dimitri Braakman (Product Marketing Manager) Ruben Mijwaart (Product Manager)
BPJ444: Business Programming using Java Java basics Tim McKenna
C#C# Introduction CS3260 Dennis A. Fairclough Version 1.0 Introduction CS3260 Dennis A. Fairclough Version 1.0.
Lec 6 Data types. Variable: Its data object that is defined and named by the programmer explicitly in a program. Data Types: It’s a class of Dos together.
Certain statements in this presentation concerning our future growth prospects are forward-looking statements, which are subject to a number of risks,
GP3, Martin Lillholm 1 Introductory Programming (GP) Spring 2006 Lecture 3 We start at 13:00 Slides are available from the course home page Feel free to.
Comp 248 Introduction to Programming Chapter 4 & 5 Defining Classes Part C Dr. Aiman Hanna Department of Computer Science & Software Engineering Concordia.
Java™ How to Program, 10/e © Copyright by Pearson Education, Inc. All Rights Reserved.
Java Basics.  To checkout, use: svn co scb07f12/UTORid  Before starting coding always use: svn update.
Applications Development
Telerik Software Academy Telerik School Academy Integer, Floating-Point, Text Data, Variables,
Chapter 6 Introduction to Defining Classes. Objectives: Design and implement a simple class from user requirements. Organize a program in terms of a view.
C# C1 CSC 298 Elements of C# code (part 1). C# C2 Style for identifiers  Identifier: class, method, property (defined shortly) or variable names  class,
Bill Campbell, UMB Microsoft's.NET C# and The Common Language Runtime.
Chapter 5 Objects and Classes Inheritance. Solution Assignments 3 & 4 Review in class…..
Chapters 2 & 3. .NET Software development model that allows applications created in disparate programming languages to communicate Universal data access.
Java Programming, Second Edition Chapter Two Using Data Within a Program.
CHARLES UNIVERSITY IN PRAGUE faculty of mathematics and physics C# Language &.NET Platform 8 th Lecture Pavel Ježek
 In the java programming language, a keyword is one of 50 reserved words which have a predefined meaning in the language; because of this,
Java Classes Chapter 1. 2 Chapter Contents Objects and Classes Using Methods in a Java Class References and Aliases Arguments and Parameters Defining.
Object Oriented Software Development 4. C# data types, objects and references.
Inheritance and Composition Reusing the code and functionality Unit - 04.
Ceg860(Prasad)L8Obj1 Objects Run-time Structure and Organization.
1.2 Primitive Data Types and Variables
 2005 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
Spring 2009 Programming Fundamentals I Java Programming XuanTung Hoang Lecture No. 8.
Object Oriented Programming Session # 03.  Abstraction: Process of forming of general and relevant information from a complex scenarios.  Encapsulation:
 Variables are nothing but reserved memory locations to store values. This means that when you create a variable you reserve some space in memory. 
Introduction to C# Anders Hejlsberg Distinguished Engineer Developer Division Microsoft Corporation.
Programming in AS3. AS3 vs MXML MXML is content/structure AS3 ties in with the MXML to create the a functioning program.
Creating Database Objects
Basic Introduction to C#
JAVA MULTIPLE CHOICE QUESTION.
Single Value Objects as C# structs
Transactions in Entity Framework
Java Primer 1: Types, Classes and Operators
Internet and Java Foundations, Programming and Practice
Java package classes Java package classes.
Microsoft Dynamics Retail Conference 2014
Microsoft .NET 3. Language Innovations Pan Wuming 2017.
Serialization.
Single Value Objects as C# structs
Computing with C# and the .NET Framework
Chapter 2.
.NET and .NET Core 5.2 Type Operations Pan Wuming 2016.
Chapter 3 Introduction to Classes, Objects Methods and Strings
Java Classes and Objects 3rd Lecture
DISCLAIMER and COPYRIGHT RESERVATION
Morgan Stanley Technology Media & Telecoms Conference
Data Types Imran Rashid CTO at ManiWeber Technologies.
Java Programming Language
Chap 2. Identifiers, Keywords, and Types
Creating Database Objects
Forward Looking Statements
Presentation transcript:

Single Value Objects as C# structs Domain-Driven Design bottom-up Corniel Nobel, 2016-06-08, A’dam

About me Corniel Nobel Energetic, optimistic, creative, out of the box thinking, experienced software engineer Exact (2014-current) Senior software engineer Qowaiv community (2013-current) Founding member TJIP (2004-2014) OGD ICT-diensten (2003-2004) IT-Professional 2B Insite (2002-2003) Software engineer

Program Structs in C# DDD in short Single Value Objects Design choices Qowaiv Demo Questions Program 3 - Single Value Objects as C# structs

Structs in C# 4 - Single Value Objects as C# structs

Reference Types & Value Types Pointer to data elsewhere in memory Mutable by default Inheritable by default Examples Object String* Type[] Value Type Stores own data (or point to data) Immutable by design* Sealed by design Examples Single, Double, Decimal Byte, SByte Int16, Int32, Int64 UInt16, UInt32, UInt64 Boolean, Char, DateTime, Guid 5 - Single Value Objects as C# structs

DDD in short 6 - Single Value Objects as C# structs

DDD in short Domain Subject area of the software Model Repositories Aggregate roots Entities (Single) Value Objects Ubiquitous Language Language structured around the domain (Bounded) Context 7 - Single Value Objects as C# structs

Single Value Objects 8 - Single Value Objects as C# structs

Single Value Objects in DDD Subset underlying primitive type Self-descriptive Immutable Equal by value 9 - Single Value Objects as C# structs

Example SVO’s Percentage Date Week date Year Month Country Currency Stream size UUID Seed SQL Timestamp Initials Gender House number Email address Postal Code BMI IBAN BIC BSN License plate Elo 10 - Single Value Objects as C# structs

Example Stream Size var size = StreamSize.FromMegaBytes(12.4); var size = StreamSize.Parse("13 kb"); StreamSize size = 1400; Console.WriteLine("The file was {0:0.0 F}.", size); // The file was 13.0 Kilobyte 11 - Single Value Objects as C# structs

Example Postal Code var code = PostalCode.Parse("1234ab"); if (code.IsValid(Country.BE)){ /* ... */ } Console.WriteLine(“Your postal code: {0:NL}", code); // Your postal code: 1234 AB 12 - Single Value Objects as C# structs

Example IBAN var iban = IBAN.Parse("nl20ingb0001234567"); Console.WriteLine(“Your IBAN: {0:F}", iban); // Your IBAN: NL20 INGB 0001 2345 67 13 - Single Value Objects as C# structs

Design Choises 14 - Single Value Objects as C# structs

Creation & conversion No (public) constructor Parse(string) & TryParse(string) Create(underlying) & TryCreate(underlying) TypeConverter Casting String (explicit) Underlying type (implicit and/or explicit) 15 - Single Value Objects as C# structs

Validation Potential valid False positive/negative IsValid() Context independent IsValid(context) 16 - Single Value Objects as C# structs

Serialization RunTime Serializable Attribute System.Iserializable Ctor(SerializationInfo, StreamingContext) XML System.Xml.IXmlSerializable JSON void FromJson() void FromJson(String;Int64;Double;DateTime) Object ToJson() 17 - Single Value Objects as C# structs

Formatting & debugging IFormattable ToString() ToString(string) ToString(IFormatProvider) ToString(string, IFormatProvider) [DebuggerDisplay("{DebuggerDisplay }")] private string DebuggerDisplay { get; } Unified internal string representation* 18 - Single Value Objects as C# structs

Qowaiv 19 - Single Value Objects as C# structs

Qowaiv community Open Source .NET library MIT licence Code generator GitHub github.com/Corniel/qowaiv NuGet packages Qowaiv Qowaiv.Web Qowaiv.Json.Newtonsoft 20 - Single Value Objects as C# structs

21 - Single Value Objects as C# structs

Questions? 22 - Single Value Objects as C# structs

Disclaimer This document contains certain statements and expectations that are forward looking, and which are based on information and plans that are currently available. By their nature, such forward-looking statements and expectations generate risk and uncertainty because they concern factors and events in the future and depend on circumstances that may not occur. Unforeseen factors that could influence the statements and expectations may, for instance, be changes in expenditures by companies in the markets we operate in; economic, political and foreign exchange fluctuations; possible statutory changes; changes in salary levels of employees; or future takeovers and divestitures. Exact can therefore not guarantee the accuracy and completeness of such statements and expectations, nor that such statements and expectations will be realized. Actual results may differ materially. Exact refuses to accept any obligation to update statements made in this document.

Exact. Cloud business software.