locked
Is a sequence diagram of this kind symptomatic of design errors? RRS feed

  • Question

  • User-545631939 posted

    Gurus!

    One of my seniors has handed me a design document of a project he worked on, and asked me to replicate the same in my project as well. The sequence diagram showing interactions between his classes is exactly like the following:

      View               Controller        WCF                DAL

      |  |

      |  |------------>|  |

      |  |                    |  |------------>|  |

      |  |                    |  |                    |  |------------>|  |

      |  |                    |  |                    |  |                    |  |

      |  |                    |  |                    |  |<------------|  |

      |  |                    |  |<------------|  |

      |  |<------------|  |

      |  |

    Somewhy, I am not comfortable with the interactions shown above. Sequence diagrams are not that simplistic are they? Does an interaction like the above reveal design errors? Does such an interaction among any 4 classes indicate that the class design follows the well known principles of OOD, such as the SOLID principles, the tell dont ask principle, and others?

    Please advise me Gurus, somewhy, from the moment I saw this diagram, I have been a bit uncomfortable. Is my hunch about somethng beng missing in it right?

    Novice Kid

    Tuesday, February 5, 2013 12:19 AM

Answers

  • User-525215917 posted

    Does the view really interact with the controller at the beginning?

    This seems weird to me too. Controller should interact with service and after this interaction it should just return view with model that is used in view.

    The kind of interaction between classes like shown in first post is not anything unusual. In the case of three-tier architecture you have following layers:

    • DAL - data access layer (takes care of querying and data persistence)
    • BLL - business logic layer (carries actual business logic using domain classes, in your case it should be WCF)
    • PL - presentation layer (this is actual application with user-interface)

    By example, when user clicks button to save data then click is handled by PL that calls some method of BLL class and this class makes call to DAL. In some cases there can be additional layer called application services layer that isolates domain from applications.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, February 6, 2013 12:04 PM

All replies

  • User-525215917 posted

    To validate such high-level architecture one must also know the context where this architecture will be applied.

    WCF is often used when there are more than one client application and using web services makes sense under current circumstances. So the question is why WCF is there? Is it requirement or is it there for good reason? Why client application is not using DAL directly? Are there limitations? And so on, so on, so on.

    The better you describe the situation the more accure will be answer :)

    Tuesday, February 5, 2013 5:22 PM
  • User-545631939 posted

    WCF is often used when there are more than one client application and using web services makes sense under current circumstances. So the question is why WCF is there? Is it requirement or is it there for good reason? Why client application is not using DAL directly? Are there limitations?

     

    Yes Guru! There are multiple clients.

    Basically if you could give me your opinion of whether any 4 or 5 classes interacting in the above manner is ok, or is it indicative of something wrong deep inside, that would be fine. By the way, don't you think that kind of interaction is suggestive of procedural programming? I have never ever seen a sequence diagram like that before. Novice as I am, something tells me not everything is ok with it. What do my Gurus say?

    Novice Kid

    Wednesday, February 6, 2013 2:01 AM
  • User-525215917 posted

    In my practice WCF comes in when:

    • there are external applications that are not allowed to access data directly
    • data lives in restricted segment of network and only way to access it is through web service
    • there is need for one data access point for application (let's say some apps doesn't support easily using your DAL but they can use easily web services - by example external data support in SharePoint)

    As much as possible I'm trying to avoid using web services until the point where web service is the only way to go.

    Main complexities:

    • using web services means higher need for server resources (you go across process boundaries)
    • you have to write service layer code with additional set of classes that are serializable
    • if web service is heavily used then it needs different scaling than usual web applications

    But again... there are always situations where web services are best solution to use. It depends on how much control you have over applications that use data and if there are client applications that are not under your control or that must work with limited set of data due to some agreements or requirements.

    Wednesday, February 6, 2013 4:14 AM
  • User-545631939 posted

    In my practice WCF comes in when

    Guru DigiMortal,

    Actually my question is not so much about WCF as it is about the class interactions being ok from a design point of view. In place of View, Controller, WCF Proxy and DAL, please read Class A, Class B, Class C and Class D. Is it possible to diagnose a flaw from the interaction as depicted above?

    But nevertheless, thanks a lot for your reply! I greatly appreciate your trying to help me. Your comments on inserting a WCF layer is new knowledge for me and I will keep it in mind whenever I am asked to design a solution.

    Advance thanks to all Gurus who have stopped by and are going to stop by!

    Novice Kid

     

    Wednesday, February 6, 2013 4:30 AM
  • User1109032460 posted

    This diagram is an example that represents millions of web sites and their interactions, with one caveat.

    Does the view really interact with the controller at the beginning?

    In a modern ASP.NET MVC application, this wouldn't happen: the routing infrastructure would locate the Controller and call its ActionMethod, not the View. The Controller would then choose the View, causing its instantiation.

    Other than that, it looks reasonable enough to me.

    One question to raise, though, is whether the design reflects Martin Fowler's TransactionScript pattern. Generally, this is easy to get going with, but tends to weaken over time due to the duplication of code that can occur.

    Wednesday, February 6, 2013 8:22 AM
  • User-525215917 posted

    Does the view really interact with the controller at the beginning?

    This seems weird to me too. Controller should interact with service and after this interaction it should just return view with model that is used in view.

    The kind of interaction between classes like shown in first post is not anything unusual. In the case of three-tier architecture you have following layers:

    • DAL - data access layer (takes care of querying and data persistence)
    • BLL - business logic layer (carries actual business logic using domain classes, in your case it should be WCF)
    • PL - presentation layer (this is actual application with user-interface)

    By example, when user clicks button to save data then click is handled by PL that calls some method of BLL class and this class makes call to DAL. In some cases there can be additional layer called application services layer that isolates domain from applications.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, February 6, 2013 12:04 PM