Search

Categories

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Send mail to the author(s) E-mail

# Friday, July 25, 2014
( Git )

This solves the problem in VS2013 git - it can get confused and seemingly ignore the gitignore file.

Take an existing solution eg:

image
Already compiled, and has NuGet packages

image
Do a git init from the command line.

image
Make a  .gitignore.   (otherwise windows wont let you name it), a good community example is from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
 

image
Add all files to git

image
Open up the solution, and now we have everything excluded that we want

image
Push to GitHub

image
Then do a clone in VS as a sanity check

image

image
NuGet getting packages as it should.  Cloned solution works.

| | # 
# Thursday, July 24, 2014

Looking in the Event Viewer, System, ever since I’ve had this PC I’ve been getting:

Windows Hardware Error Architecture

WHEA-Logger warnings:

A corrected hardware error has occurred.

Reported by component: Processor Core
Error Source: Corrected Machine Check
Error Type: Cache Hierarchy Error
Processor APIC ID: 2

The details view of this entry contains further information.

image

http://social.technet.microsoft.com/wiki/contents/articles/3567.event-id-18-microsoft-windows-whea-logger.aspx

update BIOS and drivers for motherboard

maybe bump up voltage. offset +0.100?

image

https://downloadcenter.intel.com/Detail_Desc.aspx?agr=Y&DwnldID=19792

Tested okay

http://www.gigabyte.com/products/product-page.aspx?pid=4960#dl

BIOS is at latest version – F7

Updated all drivers on their website ie LAN, Audio, VGA

image

Device manager happy.

2014-07-25 13.31.55
Set motherboard back to optimized defaults.

Tried vCore up to 1.4  No difference

2014-07-25 14.49.44
Memtest running - fine so far.  It passed

image
I notice there are more errors the higher the processor load

Updated BIOS to F8b (beta) which made no difference.

http://forum.giga-byte.co.uk/index.php/topic,14859.0.html

image
On low CPU load, the warning happens every minute or so

| | # 
# Tuesday, July 22, 2014

Getting the most out of your machine:

http://www.cpuid.com/softwares/cpu-z.html

image

CPU: 4790K

image

Have gone from BIOS F6 to F7

Motherboard: Z97X-UD3H

Intel Devil's Canyon Core i7-4790K CPU Cinebench results

http://www.theregister.co.uk/2014/06/30/review_intel_devils_canyon_cpu/

So possible 10% increase in perf going from 4.4 to 4.8

 

Look at BIOS update..

http://www.gigabyte.com/products/product-page.aspx?pid=4960#bios

latest is F7 – 19/06/2014.  Had to format a mem stick to Fat32, copy the files over, then reboot and run the flash update in the BIOS.

http://www.gigabyte.com/products/product-page.aspx?pid=4960#driver  - management?

 

image

Overclocked to 4.5GHz

http://www.overclock.net/t/1490835/the-gigabyte-z97x-overclocking-guide – Changed the Performance Upgrade switch in the BIOS

image

no overclock (4.4GHz.. or 4.0?)

image

4.5GHz

Also how to find drivers http://social.microsoft.com/Forums/en-US/9adcf4df-0dfd-47f0-a955-2dd1cb56e151/driver-question-pci-simple-communications-controller?forum=whssoftware

Installed :  Intel Management Engine Inerface.. got rid of 1 device not there.

And an INF update.. all good.

EasyTune.. need Gigabyte AppCenter utility

image
4.6GHz

| | # 
# Wednesday, July 16, 2014

image

Going for a minimal install, but with client tools.  Also put on mixed mode authentication.  Rest are defaults.

| | # 

Disabling outlook alerts (2013)

http://www.howtogeek.com/tips/how-to-disable-desktop-notifications-in-outlook-2013/

setup power saving (if using desktop) to performance

 

setting up mstsc (inbound) – proving to be hard as I’m on a VPN to a corp network, so it should just work.

| | # 

“DI is a way to enable loose coupling, and loose coupling is first and foremost an efficient way to deal with complexity”

image

“Anyone can draw a three-layer application diagram, and [this] proves that I can, too”!

Building a tightly coupled application

MVC, EF and MSSQL application.  E-commerce.

  • List of featured products
  • If user is a preferred customer, the price on all products should be discounted by 5%

Data Layer

image
Creates a table in SSMS

image
Uses EF to create an Entity Model (db first).  She has changed Featured to IsFeatured in the model

Domain Layer

How to know who is a preferred customer?

    public partial class ProductService {
        private readonly CommerceObjectContext objectContext;

        public ProductService() {
            this.objectContext = new CommerceObjectContext();
        }

        public IEnumerable<Product> GetFeaturedProducts(
            bool isCustomerPreferred) {
            var discount = isCustomerPreferred ? .95m : 1;
            var products = (from p in this.objectContext
                                .Products
                            where p.IsFeatured
                            select p).AsEnumerable();
            return from p in products
                   select new Product {
                       ProductId = p.ProductId,
                       Name = p.Name,
                       Description = p.Description,
                       IsFeatured = p.IsFeatured,
                       UnitPrice = p.UnitPrice * discount
                   };
        }
    }

She implements this in the domain layer.  However she needs a reference to the DAL as ObjectContext is defined there.

UI Layer

public ActionResult Index() {
    bool isPreferredCustomer = this.User.IsInRole("PreferredCustomer");

    var service = new ProductService();
    IEnumerable<Product> products = service.GetFeaturedProducts(isPreferredCustomer);
    this.ViewData["Products"] = products;

    return this.View();
}

Needs a reference to Domain layer, and DAL (as products are defined there). 

image
The answer as to why this was failing to compile on line 12 becomes clear when you use the type explicitly

image

Ahh, it is Product. Need a reference to System.Data.Entity (EF4) for EntityObject which Product inherits from.

MVC5

As I couldn’t get the project to compile easily (MVC3) in VS2013, I created a new MVC5 and fitted in the code.

@using Ploeh.Samples.Mary.ECommerce.Data.Sql

<asp:Content ID="indexTitle" ContentPlaceHolderID="TitleContent" runat="server">
    Home Page
</asp:Content>

<asp:Content ID="indexContent" ContentPlaceHolderID="MainContent" runat="server">
    <h2>Featured Products</h2>
    <div>
        @foreach (var prod in (IEnumerable<Product>) ViewData["products"]){
            @prod.Name
            <br />
            @Html.Encode(prod.Name)
            <br />
            @prod.UnitPrice
            <br/>
            @Html.Encode(prod.UnitPrice.ToString("C"))
            <br/><br/>
        }
    </div>
</asp:Content>

and web.config

  <system.web>
    <authentication mode="None" />
    <compilation debug="true" targetFramework="4.5.1">
      <assemblies>
        <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
      </assemblies>
    </compilation>

to get a reference to System.Data.Entity.  Also had to make sure the connection string was pointing to .\SQLEXPRESS where I generated the database.

Evaluation

Did Mary succeed?  No.  It looks like the coveted layered application, but the code is tightly coupled

image
Dependency graph showing how the modules depend on each other.  The arrows point towards a module’s dependency

The UI is dependant on both the Domain and Data Access layers!  It seems the UI may bypass the Domain in certain cases.

Evaluating Composability

Is it possible to use each module in isolation?

What is we want to replace the UI with a WPF one? – yes because nothing depends on the UI

Want to replace the DAL with one for Azure Table Store – no because domain and UI depend on it

IEnumerable<Product> products = service.GetFeaturedProducts(isPreferredCustomer);
  • UI reference Product which is defined in the DAL
this.objectContext = new CommerceObjectContext();
  • Domain library – tightly coupled to the DAL
  • A public Product class belongs in the Domain Model
  • Preferred Customer code is in UI whereas it belongs in the Domain Model
  • ProductService in Domain relies on web.config (for EF) – should be impertively configurable by callers
  • View contains specific string formatting.. should be in underlying model

Rebuilding the Commerce Application

Outside-in technique.  Here that means starting from the UI.  Closely related to You Aint Gonna Need It YAGNI.

He wrote a lot of unit tests in writing this application, as uses TDD

UI - FeaturedProductsViewModel

image

Interfaces or Abstract classes? – Important part is that you program against some sort of abstraction

custom IControllerFactory which will create an instance of the concrete ProductRepository and supply it to the home controller’s ctor.

image
Success!

Composition Root

Push the burden of controlling the dependency into another class – a composition root at the top of the application.  Where the different modules of an application can be composed.

Data Access

Using a separate Product POCO in the domain compared with auto generated Product in the DAL.  Aneimic model.

image
How dependencies are being connected

  • Injects SqlProductRepository into a new instance on HomeController
  • Index creates a new ProductService passing SqlProductRepository and invoking GetFeaturedProducts

image
Domain library has no dependencies!

  • Can we replace the WebUI with a WPF one.  Yes.  Nothing is dependant on it
  • Can we replace the Data Access library.  Yes.  It is loaded with late binding and the type is defined in web.config.

image
Late binding cannot find the DAL type – this can be solved by adding a reference from the UI to SQL layer.  Defeats the object (I think) though!  Ahh  - http://www.manning-sandbox.com/thread.jspa?threadID=47901  so the point here was to show they are separate.  Copy in the dll and all will be well.  No direct references so everything is separate.

Domain Unit Tests

image
For fun am going to explore the tests he wrote while developing this application.  Split tests into

  • ProductTest
  • DiscountProductTest
  • ProductServiceTest

Uses AutoFixture https://github.com/AutoFixture/AutoFixture  which he is a author on.  Design to:

“minimize the 'Arrange' phase of your unit tests”

Also Moq and xUnit

MVC Unit Tests

More difficult as lots has changed in MVC5.2 from 3.

| | # 
# Monday, July 14, 2014
( Resharper | Xunit )

Resharper Manage Extensions

image

| | # 
# Friday, July 04, 2014

Rohans talk

What book?

Dave Kerr.. knows about messaging

 

Framework for doing a distributed application

Separate machines eg Web -> create user -> Console app picks up message to save... -> raise an event that this has happened

Another ConsoleApp picks up that message and then sends an email

 

MSMQ, RabbitMQ, Tables(!) in a DB, Azure

  • Error queue
  • Auditing

 

Why have an Interface over an Attribute for NServiceBus eg ICommand (a marker interface)

Command is somehting want to happen

Event is something after it happens

Resilient... eg if emailler console app went down.

Starbucks Analogy

1person - take order

cup is the message (written on)

1 person - makes

 

Other Products

NServiceBus and MassTransit started using MSMQ

EasyNetQ is a light .NET wrapper around RabbitMQ (Erlang open source)

RabbitMQ is a much more feature rich queuing system.. than MSMQ... perf slightly better at 8k messages per sec compare to 5k

| | #