Design issue( creation of objects)

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

H
My application consists of three layers, presentaion layer(PL), Business Logic layer(BLL) and Data Access layer(DAL)
my application is a single windows form application
now BLL consits of couple of classes, in one class of BLL, i need to access a function of PL
the function declaration is as..... public void MyFunc().......which is not a static one
and there r lot of functions which use the above function.. s
in the middle of the application development i cant change the Function into a static one. At this situation i created a object of the PL and used in the BLL class , Can i do like this
Is my approach is a bad one
I heard that only upper layers should use the objects of the lower layers classes..

My PL class is having an object of my BLL class and my BLL class is having an object of the PL class, is this bad design
PL <----------> BL

-----need hel
---------seas
 
Hi
My application consists of three layers, presentaion layer(PL), Business
Logic layer(BLL) and Data Access layer(DAL). my application is a single
windows form application. now BLL consits of couple of classes, in one
class of BLL, i need to access a function of PL, the function
declaration is as..... public void MyFunc().......which is not a static
one. and there r lot of functions which use the above function..

This is not right, semantically. Never call a method in tier N+1
from tier N if tier N+1 is laying on top of N. So your BL tier shouldn't
call methods from the GUI, as the BL is a black box for the GUI, it
provides a service API to the GUI. Calls are always from the GUI to BL and
from the BL to the DAL, never the other way around. You'll get cyclic
references as well, which is a signal something is wrong.

If you need to use some logic in the GUI and BL tier, place it in
some separate project, UtilityClasses or whatever, code which is not tied
to a single tier. Then use this utility code in both the GUI and the BL
tier.
so in the middle of the application development i cant change the
Function
into a static one. At this situation i created a object of the PL and
used in the BLL class , Can i do like this?

well... you probably can (however with project references it might
be a problem: gui references BL, BL references GUI), but it's not wise, as
it makes the BL tier semantically part of the GUI.
Is my approach is a bad one?
I heard that only upper layers should use the objects of the lower
layers classes...
true.

My PL class is having an object of my BLL class and my BLL class is
having an object of the PL class, is this bad design? PL <---------->
BLL

It's not that great :) I'd opt for the separate utility lib option,
so you can keep the gui and bl tiers separated.

What kind of code is located in the Method you want to call from
the BL? Perhaps it is better you'd place that call in the BL anyway.

FB
 
Hi seash

Just as Frans said, it is not good practice. BL is supposed to service the PL, not the other way round

Though the actual situation is not clear, I believe delegates and events might help you out

Regards
fbhca
 
Back
Top