Monday, January 19, 2015

W3C Free Tool for HTML5 Markup Validation

In this article we describe Step by Step How to use a W3C Free Tool for HTML5 Markup Validation in 5 minutes,  with a simple HTML5 markup , introducing the W3C Online Markup Validator .
HTML5 is a computer language , and it has therefore its own vocabulary, syntax and grammar. However, there are times when the documents written in HTML5 do not complain those grammar rules, and therefore they are considered invalid HTML5 web sites.
The action of verifying whether an HTML5 markup follows the HTML5 syntax rules is called "Validation". Thus, Validity is considered a quality criteria for an HTML5 web page.
We'll make use of the best HTML5 validator: the free tool by the W3C Consortium. It is called HTML5 Markup Validator :

W3C Free Tool for HTML5 Markup Validation



W3C Free Tool for HTML5 Markup Validation





First browse to the HTML5 Markup Validator web site:


W3C Free Tool for HTML5 Markup Validation 1

Once there, select the "Validate by direct input" tab:

W3C Free Tool for HTML5 Markup Validation 2


Open your HTML5 markup:

W3C Free Tool for HTML5 Markup Validation 3


Copy the HTML5 markup and paste it inside the text box at the W3C Markup Validator:

W3C Free Tool for HTML5 Markup Validation 4


Essentially , you'll get the validation information. However, when you click the "Check" button, you may receive a list of validation errors:

W3C Free Tool for HTML5 Markup Validation 5


Now is time to fix the validation errors. Scroll down the validator to see the errors that were found:

W3C Free Tool for HTML5 Markup Validation 6


As you can see, the errors found in this sample case, refer to an Attribute not found in HTML5 syntax. That's because were using here the AngularJS Framework for building SPA (Single Page Applications) apps. Let's fix it by replacing all "ng-xxx" attributes with "data-ng-xxx":

W3C Free Tool for HTML5 Markup Validation 7

After you fixed all the specific errors on your web page , copy-paste again the resultant markup into the Validator:


W3C Free Tool for HTML5 Markup Validation 8


Now Check the HTML5 document. Hopefully it is now "valid" :

W3C Free Tool for HTML5 Markup Validation 9





That All!!!   In this article we learned Step by Step How to perform HTML5 Markup Validation  in 5 minutes. 
Happy programming.....

      by Carmel Schvartzman


כתב: כרמל שוורצמן




Friday, January 9, 2015

How to Fix the Entity Framework error "Problem in mapping fragments"


In this article we see How to Fix the Entity Framework error "Problem in mapping fragments" : "Non-nullable column  is mapped to a nullable entity property" :


How to Fix the Entity Framework error "Problem in mapping fragments"




 How to Fix the Entity Framework error "Problem in mapping fragments"


This Entity Framework error is originated when your Data Model contains an Entity with a nullable property , while at the Data Store, the mapped column has been defined as non-nullable.
Let's see the Error Message : some "Non-nullable column" has been mapped to a  "nullable entity property" , therefore let's locate at the Model (not at the "Store") that property : in our case, is the property "name" :

How to Fix the Entity Framework error "Problem in mapping fragments"  1


Now we open the "Details" window to take a look at the property :
How to Fix the Entity Framework error "Problem in mapping fragments"  2

We find there that the Entity Model property mapped to the non-nullable column , has not set the "Nullable" field.

So set it in the way that conforms to the Store's column definition:
How to Fix the Entity Framework error "Problem in mapping fragments"  3


After that, you can "validate" the Entity Data Model by right clicking on the property :

How to Fix the Entity Framework error "Problem in mapping fragments"  4

In this case, because there is only one property wrongly mapped, the Data Model is validated with no errors:
How to Fix the Entity Framework error "Problem in mapping fragments"  5



By Carmel Shvartzman

עריכה: כרמל שוורצמן

Monday, January 5, 2015

Abstract Classes Vs Interfaces in .Net


What is preferable? To create Abstract base classes to inherit from? Or to design Interfaces to implement them in other objects?
While it is up to the characteristics of your application project to decide whether to design interfaces or abstract classes, there are some very important points to have clear before you start developing your software.
Essentially, an Interface is just an empty contract, while an Abstract Class is really a plain standard class, but containing at least one abstract member. An Abstract Class can contain indexers, constants, fields, properties and plenty functional methods.
First, let's see some examples of abstract inheritance and some of interfaces implementation.
The following graph represents an inheritance chain from abstract classes :
The abstract classes can have its own inner functionality and concrete methods, as you can see in the following code:


abstract class Parent
{
   public
abstract void DoIt();
}


This is an abstract base class, no functionality. And this other one is also abstract, but inherits from the former, and owns some behavior:

abstract class Base : Parent
{
  protected Parent component;

  public void Setup(Parent component)
  {
    this.component = component;
  }
  public override void DoIt()
  {
    if (component != null)
    {
      component.DoIt();
    }
  }
}



This last one inherits from the abstract class:

class Child : Base 
{
  public override void DoIt()
  {
    base.DoIt();
    ExtendedFunctionality();
    Console.WriteLine("You are at 
Child .DoIt()");
  }

  void 
ExtendedFunctionality()
  {
    // TODO
  }
}

Interfaces are just empty contracts:

interface IContract
{
void DoIt();
}

class SomeClass : IContract
{
   public void DoIt()
  {
     // TODO
  }
}



I have summarized in this table the main differences between interfaces and abstract classes:


Characteristics
Interfaces
Abstract Classes
Definition
Empty contract
Class with at least one abstract member
Functionality
No: just empty methods
Yes : all kind of class behavior
Access modifiers
No : all public
As you wish
Relevance
Adds secondary functionality to a class
Intended to be used as Base or Core Class
Performance
Wastes time searching the appropriate method
Fast
Properties
Yes : always empty
Yes
Constants, Fields & Indexes
No
Yes
Multiple Inheritance
Yes: a class can implement several interfaces
No: a class can have only one base class
Versioning
        Not recommended
             Straightforward



Important:
Before you start building some project or application take into account the versioning problem: if after you deployed the software, it happens to be that you must add new behavior to an interface (adding a new method to an existing interface), the whole application will cease working, because at compile time the classes which implement the interface will incur in error while lacking the new method's implementation.
However, if you add a new method to an abstract base class, the application will keep running, because the child classes do not have to implement the method necessarily. It can remain unimplemented until you want.


Happy programming.....
        By Carmel Schvartzman
כתב: כרמל שוורצמן