Busy CLR Developer's Guide to NakedObjects

ted@tedneward.com | Blog: http://blogs.tedneward.com | Twitter: tedneward | Github: tedneward | LinkedIn: tedneward

Objectives

Why are we here?

History

Where it all began

Smalltalk: Overview

The original O-O language

Overview

Smalltalk is...

... programming language

... and environment

Overview

Current Smalltalk implementations

Smalltalk

A History

History

Smalltalk's history is long and distinguished

History

Smalltalk influenced...

History

Smalltalk influenced...

History

Smalltalk influenced...

History

Smalltalk influenced...

History

Began on a bet

History

Objects introduced in Smalltalk-80

History

Smalltalk incorporated IDE and runtime into one tool

Model/View/Controller

Separating display from logic

Model/View/Controller

MVC is a design pattern that appears frequently in GUI systems

Model/View/Controller

Origins lie in Smalltalk

Model/View/Controller

MVC showed up in a number of GUI systems

Model/View/Controller

In the original MVC...

Model/View/Controller

Parting thoughts

Model/View/Controller

MVC has spawned a lot of similar ideas/patterns

Model/View/Controller

Resources

Naked Objects

Wait.... what?

Naked Objects: Overview

In the old days...

Naked Objects: Overview

What's wrong with the way we do applications today?

Naked Objects: Overview

New idea: Let the UI center around the objects

Naked Objects: Overview

Benefits:

Naked Objects: Basics

Understand the principles of Naked Objects

Basics

Naked Objects frameworks core concepts

Basics

Domain objects

Basics

Properties

Basics

Actions

Basics

Value types

Basics

Services

Basics

Factories/respositories

Basics

External services

Basics

Contributed actions

Getting Started

Naked Objects in .NET: NOF Framework

Getting Started: .NET

Step 1: Download Template project and docs

Getting Started: .NET

Step 2: Unzip Template solution

Getting Started: .NET

Step 3: Build/Run

Naked Domain Objects in .NET

Building naked objects in C#

Naked Domain .NET Objects

Start with "simple" O-O domain class

Naked Domain .NET Objects

Student

public enum Subject { CompSci, Philosophy, BasketWeaving }
public class Student
{
  public virtual int Id { get; set; }
    
  public virtual string FullName { get; set; }
  public virtual int Age { get; set; }
  public virtual Subject Subject { get; set; }
    
  public virtual void HaveBirthday() { Age++; }
}

Naked Domain .NET Objects

Properties

Naked Domain .NET Objects

Actions

Naked Domain .NET Objects

Student

public class Student
{
  // This property will never be seen in the UI
  [NakedObjectsIgnore]
  public virtual int Id { get; set; }
    
  // This property will be used for the object's title
  [Title]
  public virtual string FullName { get; set; }
  public virtual int Age { get; set; }
  public virtual Subject Subject { get; set; }
  public virtual void HaveBirthday() { Age++; }
}

Naked Domain .NET Objects

Presentation is derived from class definitions

Naked Domain .NET Objects

Persistence is handled by EntityFramework

Naked Domain .NET Objects

Object (per-instance) Menus

Naked Domain .NET Objects

Numerous "tweaks" to customize object presentation

Naked Domain .NET Objects

Numerous "tweaks" to customize object presentation

Naked Domain .NET Objects

Object lifecycle

Naked Domain .NET Objects

Object lifecycle methods provide notifications

View Models

Presentation-leaning (naked) objects

NOF View Models

ViewModels provide "views" over domain objects

Services in .NET

Building naked object services in .NET

.NET Naked Object Services

Services perform three roles

.NET Naked Object Services

Services are plain .NET classes

.NET Naked Object Services

Factories/Repositories

.NET Naked Object Services

Factory/Repository service

public class ExampleService
{
  public IDomainObjectContainer Container { set; protected get; }
  public Student CreateNewStudent()
  {
    return Container.NewTransientInstance<Student>();
  }
  public IQueryable<Student> AllStudents()
  {
    return Container.Instances<Student>();
  }
  public IQueryable<Student> FindStudentByName(string name)
  {
    return AllStudents().Where(c => c.FullName.ToUpper().Contains(name.ToUpper()));
  }
}

.NET Naked Object Services

Shared logic

.NET Naked Object Services

External functionality

.NET Naked Object Services

Dependent services are dependency-injected

Auth & Auth

Handling authentication and authorization in NOF

Auth & Auth

Authentication

Authorization

Auth & Auth

Authentication: client

Auth & Auth

Authentication: server

Auth & Auth

Authorization

Auth & Auth

Auditing

Naked Objects: Resources

Where to go for more information/ideas/etc

Resources

Reading

Summary

So... where are we?

Credentials

Who is this guy?