VB .Net circular dependency error

G

Guest

I have a method in a "Business" Class that needs to call a method in a "UI"
Class
Currently, the "UI" Class calls methods in the "Business" Class...this I
can't change.

When I tried to add a reference to the "UI" in the "Business" project, I got
an error saying I couldn't because of circular dependency...which I get.

I believe creating a public interface is probably my only option, but I'm
not exactly sure how to go about doing it. Any help or suggestions would be
greatly appreciated.

Thx,
-- djm
 
K

Kevin Spencer

A business class should never call any method in a UI class, first of all.
The purpose of separating the layers is to enable other UIs to use the
Business class(es). The Business class(es) should know nothing about the UI,
but only provide business functionality with regards to the data being
manipulated. The UI class may know anything about the publicly-exposed
members of the Business class(es).

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Show me your certification without works,
and I'll show my certification
*by* my works.
 
G

Guest

Hi Kevin and Thx for the quick response.

I agree, but I'm involved in a project to convert a very big vb6 application
into .Net and the first phrase is to just convert and integrate the new code
in to the application.

Here's the problem.
I have methods in many different business layers that need security
clearance and I need the user to supplier their password.

How can I accomplish this in n-tier architecture?

Thx,
-- djm
 
R

Rob R. Ainscough

You could also just create a new class that references both your UI and
Business class. But if you already have methods in the Business class
calling methods in the UI class, then your sorta screwed. You really should
considered the benefits or migration to a more structured .NET version.
..NET does not lend itself to poor OOP implementations of VB6.
 
K

Kevin Spencer

Here's the problem.
I have methods in many different business layers that need security
clearance and I need the user to supplier their password.

How you handle this depends upon the type of security you're implementing.
Is it role-based, for example? In any case, the UI layer should be agnostic
of the user. All it should provide is the interface for the user to log in.
The business layer should handle the actual security. Remember, all the UI
layer is, is an interface for the user to interact with the business layer.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Show me your certification without works,
and I'll show my certification
*by* my works.
 
S

SP

djm said:
I have a method in a "Business" Class that needs to call a method in a "UI"
Class
Currently, the "UI" Class calls methods in the "Business" Class...this I
can't change.

When I tried to add a reference to the "UI" in the "Business" project, I
got
an error saying I couldn't because of circular dependency...which I get.

I believe creating a public interface is probably my only option, but I'm
not exactly sure how to go about doing it. Any help or suggestions would
be
greatly appreciated.

Your UI should respond to events from your business layer.

SP
 
G

Guest

Yep, I'm pretty much screwed, so I'm going to leave the main function that
is giving me so much grief in VB 6 for now and use xml to call the process
until we can re-architect our security model.
Thx for your input.
 
G

Guest

Security is not role based. It is based on access levels within the
application.
Depending on your access level, you may only be able to view certain screens
or fields in the UI...or you may have to provide your (non-windows) password
to be able to view or edit screens or fields.

I need to move on, so I'm going to leave the function in vb6 and call it via
xml until we can refactor our security model.

Thx for your help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top