0
votes

I want to obtain a 3-tier architecture: UI<-BLL<-DAL.

My DAL is a "super" object that can handle different DB tecnologies like sql server, mysql, ecc..

And this is what i think to be the business logic layer:

/// <summary>
/// Customer entity
/// </summary>
public class Account
{
    public String Username;
    public String Email;
}


public class AccountService<T>
    where T : Account
{

    IEntitymanager entityManager;

    public AccountService(IEntitymanager entityManager)
    {
        this.entityManager = entityManager;
    }

    public void Register(T account, 
                         String confirmPw, 
                         String verificationEmailBody)
    {
        // Validate parameters...
        // Check email uniqueness...
        // then write  account to db...
        if (entityManager.Save<T>(account))
        {
            // Send verification email whit GUID
        }
    }

    public void Verify(String guid)
    {
        T account = entityManager.Get<T>(new Parameter("Guid", guid));
        // Verify account
    }
}

Now i have some questions about this:

  • Is this an example of business layer or this is a service layer or what?
  • It is correct to validate input in business logic?
  • In Register method, where account was created? Is it correct that it is created in the UI layer (read value from an input form, create the account object and pass it to Register)?
  • Is correct that my BLL can access Db through entityManager?
  • I need other layers if i think to build a client and a web GUI using this kind of BLL?
1

1 Answers

0
votes

You can achieve support for multiple RDBMS technology by implementing Repository pattern i.e. a set of common interfaces where each RDBMS data access components can implement.

Your business logic is isolated into a separate class but if you do not expose them via a boundary i.e. using SOAP or REST, then you don't really have a service layer. Not every application needs a service layer. It will depend on your requirements and projected future growth of the system.

Validation can be challenging. If the inputs to your system is only from the UI, then validation in UI should be sufficient. However, if you have a service layer, then you may need to replicate some of the validations to the business layer as well.

You may want to refer to this article for a better view on Layered Architecture http://serena-yeoh.blogspot.com/2013/06/layered-architecture-for-net.html

You can also download sample implementations from here http://layersample.codeplex.com/