A sample three-tier project [feedback required]

Hamster

Resident Rodent
Joined
Aug 22, 2006
Messages
42,928
Student?

Pretty standard stuff. Nothing wrong with it.
 
Last edited:

Solarion

Honorary Master
Joined
Nov 14, 2012
Messages
21,887
Student yes. Looking for some decent source material to learn from.

Thanks Hamster.
 

Hamster

Resident Rodent
Joined
Aug 22, 2006
Messages
42,928
Student yes. Looking for some decent source material to learn from.

Thanks Hamster.
Project has three layers: UI, Business and DataAccess. The idea is to separate them and talk to each other in a standard way:
UI <-> Business <-> DataAccess. UI never talks to DataAccess.

You also shouldn't share entity classes between UI and DataAccess. Let's say you have a person table and the DataAccess returns a Person object, that Person class should be translated/mapped to another class that was design for UI use. It is more work (overkill even) but it helps to think about it this way: if your DataAccess changes to use a web service instead of a database, why should your UI be affected?

In that example the guy returns datarows and datatables from his DataAccess layer which means he is sort of doing it already. Once you start using something like Dapper which makes your DB coding g life much easier you'll need to keep this in mind and enforce it.
 

Solarion

Honorary Master
Joined
Nov 14, 2012
Messages
21,887
That is a very helpful explanation thanks. I will chew over that for a while. For a while now I have not been happy with my approach of UI accessing the database either directly or by calling a data access class, something has been missing, just not been happy with my coding efficiency (lack of it).

I've naturally been gravitating towards this 3-tier approach without even realizing it. The Business Layer is the missing piece in the puzzle, now to sit down with this sample project and start from there.
 
Last edited:

Hamster

Resident Rodent
Joined
Aug 22, 2006
Messages
42,928
That is a very helpful explanation thanks. I will chew over that for a while. For a while now I have not been happy with my approach of UI accessing the database either directly or by calling a data access class, something has been missing. I've naturally been gravitating towards this 3-tier approach without even realizing it. The Business Layer is the missing piece in the puzzle, now to sit down with this sample project and start from there.
The inverse is true too. If your UI changes, why should your business and DataAccess change? UpdateUser() stays UpdateUser(). This is where interfaces come in. Your UI has access to an IBussiness interface and when you click a button it only calls a method on that interface.

Anyway, you'll cover this as you carry on with your studies
 

Beachless

Executive Member
Joined
Oct 6, 2010
Messages
6,003
Is this MVC basically?

No MVC is a client side methodology but it applies similar principles in that there is a clear separation between components. If you think about writing code in a enterprise/cloud/etc environment you will allways gravitate towards reusable components no matter if it is OOP/SOA/MVC/Entities/etc.
 

Thor

Honorary Master
Joined
Jun 5, 2014
Messages
44,236
Not sure. All my MVC googles have turned up ASP.NET

I'm not sure what the WinApp equivalent is but this project ^ seems to be it.

Not entirely. Same principle, but better to work with.

No MVC is a client side methodology but it applies similar principles in that there is a clear separation between components. If you think about writing code in a enterprise/cloud/etc environment you will allways gravitate towards reusable components no matter if it is OOP/SOA/MVC/Entities/etc.

Just tell me, the laravel framework I use that is MVC right?

I just want to make sure I understand it all.
 

Genisys

Honorary Master
Joined
Jan 12, 2016
Messages
11,218
Just tell me, the laravel framework I use that is MVC right?

I just want to make sure I understand it all.
Google and the Laravel website says it's MVC yes. Not to be confused with 3 tier.
 

Genisys

Honorary Master
Joined
Jan 12, 2016
Messages
11,218
Not sure. All my MVC googles have turned up ASP.NET

I'm not sure what the WinApp equivalent is but this project ^ seems to be it.

ASP.Net is a Web development thing. You can easily create MVC Web apps using C# and asp.net.
 

Pho3nix

The Legend
Joined
Jul 31, 2009
Messages
30,589
Student yes. Looking for some decent source material to learn from.

Thanks Hamster.
WTF you are a student???
Project has three layers: UI, Business and DataAccess. The idea is to separate them and talk to each other in a standard way:
UI <-> Business <-> DataAccess. UI never talks to DataAccess.

You also shouldn't share entity classes between UI and DataAccess. Let's say you have a person table and the DataAccess returns a Person object, that Person class should be translated/mapped to another class that was design for UI use. It is more work (overkill even) but it helps to think about it this way: if your DataAccess changes to use a web service instead of a database, why should your UI be affected?

In that example the guy returns datarows and datatables from his DataAccess layer which means he is sort of doing it already. Once you start using something like Dapper which makes your DB coding g life much easier you'll need to keep this in mind and enforce it.

Very interesting. I'll be honest. Never done that before :eek:
 
Top