Adrian Hand
Adrian Hand

Reputation: 490

Architecting of a business layer between WCF data layer and WPF front end

I am designing a data driven windows application, to be fed not by the underlying SQL Server but by a WCF service, so as to allow access locally and remotely.

Said WCF provides specific features for the retrieval of users, stock, customers etc, and actually performs the ADO operations, along the following lines:

[OperationContract]
UserAdapter GetUserByWindowsIdentity(string Domain, string Account);

Which returns one of:

[DataContract]
public class UserAdapter
{
    [DataMember]
    public int? ID;

    [DataMember]
    public string Domain;

    [DataMember]
    public string Account;

    [DataMember]
    public string Name;
}

Rather than have specific references to my WCF client in my WPF front end application, I should like to abstract some further functionality in another layer in between - for example, validating a users logon via their WindowsIdentity belongs neither in the data layer, nor the presentation layer, but an intermediary business logic layer.

I am uncertain how to go about this. I'd prefer in my presentation layer to be able to do something along the lines of:

User.Login();

and for the User object to abstract the same properties like Domain, Account, etc, as per my UserAdapter class, but I can't subclass this because I can't downcast the objects returned by my data layer.

Any suggestions where I can take this, including 'chuck it out' would be very much appreciated. Thank you all!

Upvotes: 0

Views: 723

Answers (1)

Filippo Pensalfini
Filippo Pensalfini

Reputation: 1714

An additional layer in between makes absolutely sense if you have some business logic, the implementation details depend on your requirements of course.

If you think about it, the underlying data class should not know how to login, since that is already business logic: this is actually the real problem behind the approach you considered.

Hiding the business logic behind another set of services is also an option you should consider, getting all the benefits (and the cost of ownership) of WCF at business logic level.

Dino Esposito wrote a good book about architecting enterprise applications, maybe you can find some inspiration there for implementing your layered architecture.

Upvotes: 1

Related Questions