I’m on the hunt for some brilliant design model that will outsmart the incredibly frustrating limitation of circular dependencies in Visual Studio. (is that really necessary?!)

I want to follow a model that will allow me to create generic code to handle (say, filling a dataset and displaying it on a form) from *any* form.

If anyone out there has seen a good example or a smart article, please post a link.

I’ll keep looking – if I find or work out a solution, I’ll post it here.

11 Responses to “VB.NET: Avoiding Circular Dependencies”


  1. create a module or helper class, create a function in said class that accepts a gridview and a dataset, populate. that’s not that tough.

  2. hobbylobby Says:

    [edit:]
    I asked around at school and it appears that I’m going to need the Model-View-Controller design pattern to do what I want. …it’s unfortunate that we didn’t talk about that in school. multi-tier design, however, was thankfully drilled into us at every turn.
    [/edit:]

    I said that the problem was with circular dependencies, but what I probably should have said is that I need to better understand a design model that will support loose coupling of my classes and methods to avoid redundant code across multiple forms.

    I have something like the following:

    FormClasses
    –> form1
    –> form2

    BusinessClasses
    –> apple
    –> orange

    DBIO_Classes
    –> access_IO
    –> sql_IO

    UtilityClasses
    –> validators
    –> dataBuilderMethods
    –> textBoxMethods

    my desire is to do what Steve McConnell explains in Code Complete as loose coupling.

    I want to put (don’t have it there now, but want to put) all the code that handles getting the dataset from access_IO, binding the dataset to the grid (on any form), displaying the data, populating the highlighted datarow in editable textboxes, etc, all from the dataBuilderMethod class.

    so the goal would be to have a brief method that kicks off the chain of events in the dataBuilderMethod class from any form.

    the trouble is that doing so requires that the utilityClass has references set to the formClass, DBIO_class, businessClass. all of which vb forbids since that would create a circular reference.

    either this requires a trick that I haven’t learned about yet, or the overall structure that I have already created simply won’t allow me to do that.


  3. i think i understand what you’re trying to do, and i think you’re trying to get too fancy… while adherance to the structure you have set up is good, sometimes straying slightly isn’t such a terrible thing, so long as it’s controlled and in moderation.

    what i do in my apps is i have a module with a few functions called Get[...]Data where the brackets are replaced by what the return type is, for instance, GetDataViewData(sql as string), GetMySQLDataReaderData(sql as string), etc, and in each one i access the data how i need to and it’s returned in the format i need it in. what you could do is create a polymorphic subroutine in said module called BindGV(gv as GridView, data as WhateverDataSources) and have it populate and run whatever code you need to in there.

    it’s possible i don’t completely understand what you’re trying to do, but from what i’ve gathered, the solution is easier than you’re making it out to be.

  4. hobbylobby Says:

    I just got an awesome book called
    Head First Design Patterns
    ISBN-10: 0596007124
    which I think will help a lot – and boost my overall programming skills to the next level ( about time ). I’ll review it here soon.

    I was taught to always build around the 3-tier design scheme:
    Forms, Classes, & DataAccessLayer (DAL).

    By the end of my first semester of VB.NET I was totally convinced of the power and flexibility of doing that, but recently I’ve been bothered by the in-flexibility of that scheme – (which all springs from those nasty circular dependency errors).

    As far as data access, I have a DAL project that contains a few classes – Access_IO and SQL_IO. then I call CRUD methods in those classes to return datasets to my forms – or use the CRUD methods to update, delete… CRUD stuff.

    so, I do this:
    from the form code:
    dim ds as dataset = DAL.Access_IO.getCallLog

    the Access_IO class then has:
    public function getCallLog() as dataset

    are we talking about doing the same thing two different ways?

    You could be right, I might be making this too complex. After reading some more in my new book, I think I’ll have a better idea about how design patterns might/might not make my life easier.


  5. I’ve recently gotten into the source code for BlogEngine.net (http://www.dotnetblogengine.net/) and I think that they may have what you’re looking for there, although it’s all in C#. Anyways, it’s a free download of professional .NET programming (much of which is WAY over my head, haha) that may help you out.

  6. hobbylobby Says:

    thanks for the tip about dotnetblogengine.

    about a year ago I was scouring the net looking for open source projects in .net and didn’t find anything that looked apealing.

    this might be fun to dig into though. c# really isn’t *that* different from vb…

    ( I added your blog to my roll – nice stuff ya got going on over there! )

    :)


  7. oh, nice! thanks :) i will be posting a review on blogengine.net in a few days. it’s actually quite easy to modify, once you get used to all the crazy convolutedness. although, it may be easy for you! thanks again for the add :)

  8. hobbylobby Says:

    “although, it may be easy for you!”

    doubt it seriously :)

    I DL’d the source code and haven’t had a chance to even open it.
    not sure when I will. :(

  9. lovelyncezar Says:

    Thanks for this great post – I don?t think I could say anything else that would do it justice.

    Ed Hardy


  10. There is a simple solution for this problem, please refer to http://forums.asp.net/p/653304/3425873.aspx#3425873

    Regards,

    TheCodeaholic.

  11. Oes Tsetnoc Says:

    This is interesting article I will bookmark this.
    Oes Tsetnoc


Leave a Reply