locked
Architecture Question RRS feed

  • Question

  • Hi,

    I'm getting started with C# and I have what i believe to be a architecture question.

    As far as i understand, applications can be made in the 3 layer base, Display / UI Layer, Business Logic Layer and Data Acess Layer, so far so good.

    If i get it right Business Logic Layer holds all Bussiness-related validation of input, as well as the CRUDs for insert/delete/update on a table.

    Now finally the question, where exactly do I treat select querys to the database? usually they are made through a congregation of tables, so they might not fit in any of the Business Logics classes.

    Plus, one needs to filter those selects, and go again into field validation. Maybe all filters are used, maybe none, so what would be the ideal solution? a class just for query handling?

    I do understand one can make and validade research by research, but that's not very code wise, is it?

    Any links, sample code, constructive critic is appreciated. Thanks in advance.

    Monday, September 19, 2011 11:00 PM

Answers

  • On 9/19/2011 7:00 PM, Ariel_Nessi wrote:
    > Hi,
    >
    > I'm getting started with C# and I have what i believe to be a
    > architecture question.
    >
    > As far as i understand, applications can be made in the 3 layer base,
    > Display / UI Layer, Business Logic Layer and Data Acess Layer, so far so
    > good.
     
    There can be UI/Presentation Layer/Business Layer/Service Layer and Data
    Access Layer.
     
    >
    > If i get it right Business Logic Layer holds all Bussiness-related
    > validation of input, as well as the CRUDs for insert/delete/update on a
    > table.
     
    The Business Layer method can call The Service Layer method and the SL
    method call the DAL with the DAL methods doing CURD operations against
    the data stor.
     
    Or it could be the BLL methods calling the DAL methods with the DAL
    again doing CRUD operations against the data stor.
    >
    > Now finally the question, where exactly do I treat select querys to the
    > database? usually they are made through a congregation of tables, so
    > they might not fit in any of the Business Logics classes.
     
    They belong in the DAL.
    >
    > Plus, one needs to filter those selects, and go again into field
    > validation. Maybe all filters are used, maybe none, so what would be the
    > ideal solution? a class just for query handling?
     
    It sounds like BLL logic.
     
    The Service Layer will be shown to you in the link. Also, you see MVP
    being used with Web Form or Windows form application using the same
    backend of BLL, SL and DAL.
     
     The MVC is for WEB UI based solutions.
     
     MVP can be used for Web and Windows desktop UI(s).
     
     
    • Marked as answer by Ariel Nessi Wednesday, September 21, 2011 5:32 PM
    Monday, September 19, 2011 11:32 PM

All replies

  • On 9/19/2011 7:00 PM, Ariel_Nessi wrote:
    > Hi,
    >
    > I'm getting started with C# and I have what i believe to be a
    > architecture question.
    >
    > As far as i understand, applications can be made in the 3 layer base,
    > Display / UI Layer, Business Logic Layer and Data Acess Layer, so far so
    > good.
     
    There can be UI/Presentation Layer/Business Layer/Service Layer and Data
    Access Layer.
     
    >
    > If i get it right Business Logic Layer holds all Bussiness-related
    > validation of input, as well as the CRUDs for insert/delete/update on a
    > table.
     
    The Business Layer method can call The Service Layer method and the SL
    method call the DAL with the DAL methods doing CURD operations against
    the data stor.
     
    Or it could be the BLL methods calling the DAL methods with the DAL
    again doing CRUD operations against the data stor.
    >
    > Now finally the question, where exactly do I treat select querys to the
    > database? usually they are made through a congregation of tables, so
    > they might not fit in any of the Business Logics classes.
     
    They belong in the DAL.
    >
    > Plus, one needs to filter those selects, and go again into field
    > validation. Maybe all filters are used, maybe none, so what would be the
    > ideal solution? a class just for query handling?
     
    It sounds like BLL logic.
     
    The Service Layer will be shown to you in the link. Also, you see MVP
    being used with Web Form or Windows form application using the same
    backend of BLL, SL and DAL.
     
     The MVC is for WEB UI based solutions.
     
     MVP can be used for Web and Windows desktop UI(s).
     
     
    • Marked as answer by Ariel Nessi Wednesday, September 21, 2011 5:32 PM
    Monday, September 19, 2011 11:32 PM
  • Plus, one needs to filter those selects, and go again into field validation. Maybe all filters are used, maybe none, so what would be the ideal solution? a class just for query handling?
    If you mean field validation in the UI, you can handle this in the UI. For instance, you can see this link for ASP field validation and this link for Winform ValidationProviders.

    If you mean field validation in the database, you can use CHECK constraints.

    Kind regards,

    aelassas.free.fr
    Tuesday, September 20, 2011 10:32 AM
  • You could create a c# library and called it a data access library and have all you sql related select * from table, exec stored proc in there.

    You could create class objects from the data Table and then have all the business logic in business layer (valildating, filtering, comparing)

     

    Tuesday, September 20, 2011 11:32 AM
  • Thanks for the reply darnold924 !

    I was told MVC its built for really big projects, anyway for bigger projects than the ones i work on right now. Not saying its the absolute truth just saying that maybe MVC its a bit overkill for me.

    There's one thing i can't really see yet,

    database object lives only in the DAL layer *assuming that there is no SL, which i'll have to read upon* so when DAL returns, it returns a datatable object, or any other object, now the BLL would filter this object ? isn't it more performatic to filter it through SQL Where statement? insted of something like Datatable.filter? or it nothing to worry about. Or is BLL supposed to build a where statement string and pass it to the DAL ? as far as i red dynamic SQL its not really a good thing to have, even if you validate it.

     

    Link. Fr,

     

    sorry i'm not talking about UI field validation, but as for which layer should hold views and their filtering.

     

    Codeguide,

    Right, that's what darnold said, in a very suscint form, if i got you two right. so please read above

     

    Thank you all for the help


    Ariel Nessi

    Edit :

    After searching I found the SqlParam class, which serves me purpose i was looking for, in any case someone is puzzled with the same question i was, give it a read.

    If i understand well, one can pass sqlparameters as a parameter to the DAL object which takes this object and passes it to any stored procedure you may be running. Pretty much like a 2D array with the parameter name in the procedure and the parameter value. This way DAL doesn't needs to understand BLL fields and BLL doesn't needs any database objects or alike.

    thanks darnold for the insight of what goes where, which led me to a cleaner research

    • Edited by Ariel Nessi Wednesday, September 21, 2011 5:32 PM
    Wednesday, September 21, 2011 1:42 PM