Isolation, Integrity and some pitfalls in design

Time ago I worked in an application with Silverlight, I Try to create a design where the “core” would be maintainable and re-usable for a long time (of course inside of Microsoft C# technology)
After six year I open again the Solution for this project in Visual Studio 2013 with Windows 10 64 bit (it was created in Windows 7 32bits and VS2010) and I got a list of errors

2016-05-11_3-06-49

The type or namespace name ‘MatchTimeoutInMilliseconds’ could not be found

Generated code for Silverlight references MatchTimeoutInMilliseconds, which does not exist

2016-05-11_19-56-17

I look for the problem (no resolve yet) but I found that the problem is in the UI layer, because this use Silverlight and now this is deprecated. Fortunately the business logic is Ok

2016-05-11_3-02-42

So here some lections to learn.

Don’t be a “fan-boy” with trending technology

Silverlight was good and time ago there was much support, but now is deprecated by Microsoft, at the same time in 2010 HTML5 staring to grown, so is important  employ Standard Techniques. Despite Microsoft still supporting Silverlight, but   if the application was written in a language more “Standard” like HTML5, maybe now not have problems with UI

Decouple the domain is SO IMPORTANT

I’m not an expert in Architecture and design but fortunately I try to follow the guidelines of DDD to decouple business logic (Domain Drive Design) here some examples how it was applied:
This is the main concept take for the book“Domain-Driven Design: Tackling Complexity in the Heart of Software” by Eric Evans

2016-05-11_18-39-57

Leave a comment

Filed under Develop, RiaServices, Visual Studio

Prepositions of time

Here nice links for learning English starting with”Prepositions of time”

http://www.bbc.co.uk/programmes/p02r3zg0/player

In, at, on with time expressions

 

Prepositions of time —– Video here

 

 

330px-pieter_bruegel_the_elder_-_the_tower_of_babel_28vienna29_-_google_art_project_-_edited

Leave a comment

Filed under Language

Using GUID With Entity Framework and Ria Services

A simple Domain Sample

The GUID (uniqueidentifier) represents “The Persistent Objet Id”, this is utilized to identify unique object state in a database

Why GUID

Why not use an Identity Field? Because I Think “Identity” breaks the Unit of work Pattern

Martin Fowler say:

“Maintains a list of objects affected by a business transaction and coordinates the writing out of changes and the resolution of concurrency problems”

With identity you don’t know the ID before inserting the record, you need a round trip to database to know it

Let’s start by creating some new Student instances and persisting them to the database.

var newStudent = new Student
                                {
                                    Id = System.Guid.NewGuid(),
                                    firstName = "Elisha",
                                    lastName = "C."
                                };
           //..............................
           //......................
           //............
           // ..Domain.SubmitChanges();

Nice! GUID not need a round trip to database because is generated in the client side

So what happen if I decide use a Silverlight DataFrom to get a rapid CRUD in my application?usingGuidEfRiaSrvs_2usingGuidEfRiaSrvs_3

The GUID is not auto generated!!, the new GUID is all zeros! Next time I will get an error

I ask on twitter and get this response by @ColinBlair usingGuidEfRiaSrvs_4

How I do that?

Go to msdn for documentation: Customizing Generated Code

Client Side:

1. Add a partial class with the same name and namespace as the generated class you want to customize

2. Implement the method that is executed at the time when your custom code must be executed.

Our case: OnCreated() : Executed when the DomainContext object is instantiated.

usingGuidEfRiaSrvs_5

Done!! Every time the GUID is generated at the client side

I hope that the next WCF Ria Services version there a better way to solve this

Please go vote to get support for “Enable client generated keys for associations”

Leave a comment

Filed under Develop

Getting started with Git and Visual Studio

GitVs_01 (1)

I use Git with Visual Studio. But I don’t use the GUI,I just keep a command line open as well as Visual Studio. (We are developers and we love typing code )

But here a nice GUI tool that integrates git with Visual Studio

Introduction

This post talk about how to make a simple environment to personal source control with Git Bash, Git GUI and Visual Studio 2010

Some Basic Git Concepts

What is Git:

Git is a distributed version control system that records changes of you software projects.

Repositories

A Git repository is simply a database containing all the information needed to retain and manage the revisions and history of a project. **

Commits

In Git, a commit is used to record changes to a repository. **

Branches

The best way to understand what is a branch is doing commits, when you commit in Git, Git stores its data as a series of snapshots. “Every time you commit, in Git, it basically takes a picture of what all your files look like at that moment and stores a reference to that snapshot.” ** If you make some changes and commit again, the next commit stores a pointer to the commit that came immediately before it. A branch in Git is simply a lightweight movable pointer to one of these commits. A branch often represents an individual customer release. The default branch in a repository is named master

Installing Git (msysGit)

First, download the latest version from: http://code.google.com/p/msysgit/downloads/list After the download completes, run the installer

GitVs_01 (2)

For easier msysGit run, check the two pertinent boxes, to add in the Windows Explorer, as shown

Let’s get started

Git is simple to use. Go to All Programs and open Git Bash

GitVs_01 (3)

Or just open a Command Prompt and type Git.

Configuring the Commit Author

Before making many commits to a repository, you should establish some basic configuration options.

  1. Start Git Bash
  2. git config –global user.name “Your Name”
  3. git config –global user.email “your@mail.com

Create a new Visual Studio Solution with a project (for this example a Silverlight application)

GitVs_01 (4)

Write Code and Save Changes or run the application (F5)

< Rectangle Width="300" Height="100" Fill="Red" />

GitVs_01 (5)

Creating an Initial Repository

Go to solution folder and select “Git Bash here” or at the Command Prompt type “cd path\to\your\solution\folder “

GitVs_01 (6)

To initialized empty Git Repository in your path

GitVs_01 (7)

At Command Prompt Type:

  • git init
  • git add .
  • git commit –m “first commit ( with a rectangle )

Now to get a UI tool Type: gitk We have a first version of our application

GitVs_01 (8)

Now let’s make some modifications

We can add more files (class, service etc.) and commit this changes

< Ellipse Width="300" Height="200" Fill="Purple" />

GitVs_01 (9)

Save changes in Visual Studio and add the change to Git

Making another Commit

At Command Prompt Type:

  • Git add .
  • Git commit –m “Change to Ellipse And so on for other changes in your solution

Viewing the Commit History

Once you have one or more commits in the repository, you can inspect it

At Command Prompt Type:

• Gitk

Our History of changes:

GitVs_01 (10)

What happen if we want back to first commit?

Simple in gitk select “Reset master branch to here”

GitVs_01 (11)

GitVs_01 (12)

Next Visual Studio will detect the changes and reload the solution

GitVs_01 (13)

GitVs_01 (14)

We Back to First Version

GitVs_01 (15)

We can back to other version commit

GitVs_01 (16)

GitVs_01 (17)

GitVs_01 (18)

GitVs_01 (19)

The .gitignore File

You can skip any file by adding its name to .gitignore in the same directory.

For this example in visuals studio , Those are irrelevant files:

bin/ |obj/ |_ReSharper.* |*.csproj.user |*.resharper.user |*.resharper |*.suo |*.cache | *.user |~$*

As you have seen, git is awesome, faster, has ability to handle large projects, distributed, no heavy services or relational database to stored data.

There are lots to learn, but at the moment that’s all folks.

References:

** Version Control with Git: Powerful Tools and Techniques for Collaborative Software Development

Leave a comment

Filed under Develop

Let’s start setting our development environment

VS2010SP

Integrate Visual Studio 2010 with Service Pack ?

Slipstreaming Visual Studio 2010 ServicePack?

Is possible?… The answer is NOT (for VS2010) see more info here
Is there any alternative? I got this idea from here

How to prepare an installation of Visual Studio 2010 and Service pack 1 automatically

Make a directory for VS2010 and a subdirectory for Service Pack

For example, <Your drive>:\VS2010\ And <Your drive>:\VS2010\SP1
Copy the contents of Visual Studio DVD and SP to the respective folders
VS2010 and SP1 (1) If you want to install all features, jump to the next step

Making unattended File

To deploy a custom installation you need tell what feature you want to implement, for it is necessary create unattended file ( a |*.ini | file )

  • Second click on the Visual Studio DVD and Press the “shift” key at same time , select “Open command window here”
    VS2010 and SP1 (3)
  • Type “cd setup”
  • Type “setup.exe/createunattend c:\VS2010_deployment.ini”
    VS2010 and SP1 (4)_thumb[1]
  • Follow the directions
  • Select the features that you want and then click Save Settings. VS2010 and SP1 (1)

Create a batch file and Put “VS2010_deployment.ini” in the VS2010 folder

Now to install Visual Studio 2010 RTM and Service Pack 1 together, we need a create a batch to run all automatic

VS2010 and SP1 (2)_thumb[2]

Now all ready, just run this batch file and it will install all automatically. Go for coffee and wait

1 Comment

Filed under Develop