SitePoint Sponsor

User Tag List

Results 1 to 14 of 14
  1. #1
    Resident OCD goofball! bronze trophy Serenarules's Avatar
    Join Date
    Dec 2002
    Posts
    1,911
    Mentioned
    26 Post(s)
    Tagged
    0 Thread(s)

    You're only as good as your tools...most of the time.

    Well, I took a step back today, and start mapping things out for my current project in notepad. That was three hours ago and I'm still at it.

    I'm surprised how much clearer certain things become once you start doing this. I just wish I had better modelling tools. This could've been done a long time ago had I access to them. One can get lost, or simply frustrated, if they just sit down and begin coding with a vague idea in their head.

    Being able to design your applications layers, namespaces, objects, methods, and their relationships before you even start coding is a great thing. Especially if it is integrated and can automatically generate stubs for you.

    Can anybody suggest a good free tool that does this? Or is there one in VS2008Pro that I am unaware of?

  2. #2
    Non-Member thewebhostingdir's Avatar
    Join Date
    Oct 2005
    Posts
    703
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It is always better to develop the main logic first before we move to the implementing the project. The best modelling is UML. We have been using Eclipse UML2 Tools in the past. However, we then switched to the Microsoft Visio.

  3. #3
    Resident OCD goofball! bronze trophy Serenarules's Avatar
    Join Date
    Dec 2002
    Posts
    1,911
    Mentioned
    26 Post(s)
    Tagged
    0 Thread(s)
    Well, it's later in the day now (actually gone into the next day) and I am probably even more wary now than I was before, though at least I have a solid basis for my confusion, and am better prepared to explain why I am so confused. Hopefully somebody can clear things up for me once and for all.

    After I took to pen, paper, and notepad for a great many hours today, I started looking around at various options for me. Several things stood out.

    While seeing what was out there, I ran across this code in a DD app:


    DynamicDataRoute("{table}/{action}.aspx")


    This made me think. In the mvc model, is my CateogryController supposed to be doing the same kind of thing: wrapping a table? If so, then I'm doing it all wrong. Either that, or mvc isn't what I thought it was for. My controllers act like switchboards for an entire area of my application, sometimes inolving many table. Sometimes, even the actions make use of several tables. Even the presentation models need more than a single entity, or a set of the same entity passed in. At times, I may need up to 10 whole sets of data passed in. It's made it real tiresome for me. Imagine this:

    return View(new SomePresentation(obj1, obj2, obj3 ... obj8));

    if each one of those is a result to a service layer call, then things get real messy real quick, both in the service and controller, as well as the presentation itself. Not to mention that some of those are optional, or conditional. That means I need to have overloaded constructors to support all the permutations. With the count of presentation models rising into the 100's now, things are beginning to seem just a bit rediculous.

    Another issues that I saw was that all the service layer classes seemed to mirror the controllers. If a controller had an add method, so did the service, if it had a locate method, so did the service. The funny thing is, these were becoming quite fat themselves. What's the point of having them if they get fatter as the controller get slimmer? It's like having a slim controller call a fat version of itself. So I'm I guess I'm still a little bonkers on this call.

  4. #4
    SitePoint Evangelist praetor's Avatar
    Join Date
    Aug 2005
    Posts
    479
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Unfortunately many sample applications are extremely basic ones, just to demonstrate how to use X or Y feature. From my experience (both with php and asp.net) almost all tutorials are a quick way to do this or that, without a proper application architecture. It's no wonder that many applications are a spaghetti mess regardless of the platform.

    Being able to design your applications layers, namespaces, objects, methods, and their relationships before you even start coding is a great thing. Especially if it is integrated and can automatically generate stubs for you.
    Yes that would mean some UML, but try to see if you can learn and use TTD . It's not just testing code is designing by testing.

  5. #5
    Resident OCD goofball! bronze trophy Serenarules's Avatar
    Join Date
    Dec 2002
    Posts
    1,911
    Mentioned
    26 Post(s)
    Tagged
    0 Thread(s)
    Well, I can agree there. It appears I still have a LOT to learn here before I even attempt this project. One thing I could really use is a downloadable real world project. I tried watching the "Building the Storefront" thing at asp.net and I was lost after the first time he hit the testing phase. I then tried a few of the other videos and they were just too basic. I really do learn best, as strange as it may seem, by tearing something apart that already exists. Are you aware of a sample app I can download? Something that demonstrates everything from repository to presentation layers? I just 'know' I'm doing it all wrong, because if it feels wrong, it probably is. And it feels way wrong...

  6. #6
    SitePoint Evangelist praetor's Avatar
    Join Date
    Aug 2005
    Posts
    479
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm the type who learns by doing it (and from tutorials) so I don't know about a sample app. But I think you can download Rob's storefront to take a look.

  7. #7
    SitePoint Guru pufa's Avatar
    Join Date
    Oct 2004
    Location
    Portugal, Lisboa
    Posts
    947
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    MVC Sample Apps
    http://code.google.com/p/codebettercanvas/
    http://code.google.com/p/codecampserver/
    http://code.google.com/p/sharp-architecture/
    http://www.codeplex.com/oxite

    DDD samples (Read the book if haven't)
    http://dddsample.sourceforge.net/ -> Java version
    http://code.google.com/p/ndddsample/ -> .Net port


    Books
    http://www.amazon.com/Pro-ASP-NET-Fr...ref=pd_ys_iyr3 (The MVC book that I liked the most)

    SOLID - (these two are my favorite programming books)
    http://www.amazon.com/Clean-Code-Han...ef=pd_ys_iyr23
    http://www.amazon.com/Principles-Pat...ef=pd_ys_iyr37


    "You're only as good as your tools... most of the time."

    Tools may help... and they are only has good has you are.
    Ciao, Rui...

  8. #8
    Resident OCD goofball! bronze trophy Serenarules's Avatar
    Join Date
    Dec 2002
    Posts
    1,911
    Mentioned
    26 Post(s)
    Tagged
    0 Thread(s)
    Pufa, how do you access the google code samples? I visited the links, but did not see a way to download them.

    P-man (praetor), I learned a great deal within the first few minutes of browsing the storefront code. However, I am not sure the majority of people here would agree with his construction. It would seem that he thinks more like me, and this is evident by viewing the current project code. It is completely different from what was shown in his videos.

    The first thing I learned is not to take the MS samples too literally. I was trying to force all my services and repositories to mirror theirs. This meant the service constructors all took an IModelStateWrapper and a single ISomethingRepository object. For some reason, I thought this was the pattern, so I was getting confused when a service needed access to more than one repository. Then I saw his samples, and the services had as many constructor params as needed.

    The second thing I noticed is that his entity models weren't all that slim. They weren't just get; set; fields as I was trying to make mine. Some even had properties and methods that returned calculations and other things that manipulated the get; set; properties that the model did contain.

    The third thing is the he didn't use L2S or the EF. He used sqlclient at the base. This is what I had original intended to use myself, and I think I'll be returning to that, instead of linq.

    The fourth thing is that his view all inherit from viewpage. There are no presentation classes. What he did do, however, was a bit more interesting. He created a custom controller base class and added his own property called SiteData which held additional info that might be needed during the lifespan of the request. In my case, this would be where I'd hold SelectList data and stuff like that. This makes a ton of sense.

    The fifth thing I noticed is that his service objects tended to delegate db processes out to the various repositories that it references. The controller actions were still used to set additional entity data that might not have been set by the user while filling out the html form. For instance, setting the date on a newly placed order before sending it to repository.SaveItem(entity). So yes, his controller actions were quite fat in that I don't think I saw one with less than at least ten lines of code in it.

    I'm going to want to look at a few more samples though before I backup my current code and start over with a fresh slate. This time, I'll be designing one unit at a time, and testing with asserts. I want to do what's logical and most beneficial for the project, and if that means slightly bending the rules, so be it. I just need to be able to justify it.

    [ADDED AFTER POST]

    I just tried a unit test on my category object. It's my very first one. Ever. I actually discovered that the property values are actually null until set, so I added initializers to the constructor. Now the test passes. This is pretty cool actually...

    [TestMethod]
    publicvoid DefaultCategoryTest()
    {
    // create an instance
    Category c = newCategory();
    // do we have it?
    Assert.IsNotNull(c);
    // is it the right type?
    Assert.IsInstanceOfType(c, typeof(Category));
    // are the properties of the right type?
    Assert.IsInstanceOfType(c.ID, typeof(int));
    Assert.IsInstanceOfType(c.Sequence, typeof(int));
    Assert.IsInstanceOfType(c.Name, typeof(string));
    Assert.IsInstanceOfType(c.Enabled, typeof(bool));
    Assert.IsInstanceOfType(c.Visible, typeof(bool));
    // do they have the expected default values?
    Assert.AreEqual(c.ID, 0);
    Assert.AreEqual(c.Sequence, 0);
    Assert.AreEqual(c.Name, "");
    Assert.AreEqual(c.Enabled, false);
    Assert.AreEqual(c.Visible, false);


    }
    Last edited by Serenarules; Jul 26, 2009 at 11:37.

  9. #9
    SitePoint Guru pufa's Avatar
    Join Date
    Oct 2004
    Location
    Portugal, Lisboa
    Posts
    947
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    http://tortoisesvn.net/

    install and then in win explorer rigth click on a folder and do "svn checkout", paste the project svn url and it should pull the code.
    Ciao, Rui...

  10. #10
    always learning . . .
    Join Date
    Nov 2003
    Location
    UK
    Posts
    821
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Work in progress but looking nice.

    http://atomsite.net/

    I'm not familiar with MVC either. Just starting out with it myself. The above site is looking promising, though I'd like to get experienced peoples thoughts on whether the above is a good learning source.

  11. #11
    SitePoint Zealot
    Join Date
    May 2004
    Location
    Jersey
    Posts
    175
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Serenarules View Post
    Pufa, how do you access the google code samples? I visited the links, but did not see a way to download them.
    You don't have to download the entire source, you can view it online. Hit the source link on the google code pages (as well as codeplex and sourceforge) and then click browse, then navigate through the src directory. E.g. http://code.google.com/p/codebetterc...wse/#svn/trunk
    Matt Daly

  12. #12
    Resident OCD goofball! bronze trophy Serenarules's Avatar
    Join Date
    Dec 2002
    Posts
    1,911
    Mentioned
    26 Post(s)
    Tagged
    0 Thread(s)
    Ah thanks! I wasn't relishing having to install something just to access a site.

    Having looked at several samples now, and compared the similarities and differences, with the community agreed-upon conventions in mind, I have restructured my application project and have begun working through it from bottom to top. I now have a separate project in the solution for Entities, Repositories, Services, Utilities and Modules, and finally the mvc web app, whose Models folder / namespace I consider the place where the presentation models will go. As I go through, I will be unit testing each and every component, at every layer. I've already found a few places where my free-form thinking introduced extra complexity. Even at the simple entity model layer. Adjustments to the database were made, and I was off running again. In addition, everthing is an implementation of some kind of public interface this time. I did this to better facilitate the direct injection of various elements into service layer constructors, as I know I will be needing them later.

    I am sure I'll return with a question or two at some point, but when I do, rest assured I will be in a much better position to describe the issue.

    Thanks again guys.

  13. #13
    SitePoint Evangelist
    Join Date
    Apr 2008
    Location
    Dublin, Ireland
    Posts
    461
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I would highly recommend you take a look at Sharp Architecture linked above. Theres definitely a learning curve to it but if you read the docs carefully I think you'll see the benefits of it. It includes a VS template that creates several projects for you and gives you an easy way of creating your entities using T4Toolbox - it will generate your classes, tests, controller and several views based on editing the one .tt file and running it for each entity and using some good DDD practices with a base Entity, basic Repository interface and Fluent nHibernate auto-mapping not to mention nHibernate Validation.

  14. #14
    Resident OCD goofball! bronze trophy Serenarules's Avatar
    Join Date
    Dec 2002
    Posts
    1,911
    Mentioned
    26 Post(s)
    Tagged
    0 Thread(s)
    Hm, well...I downloaded it and looked at the src/SharpArch solution as well as the Northwind sample and I have to say I know enough to say it's well out of my league and always will be. Thanks, but I won't be looking at that any further. I am sure it works wonders for those who write and maintain mission critical apps, but the little things I do are just for friends. Even if I was to ever try and market something, it would have to be something the average Joe could maintain and change. While I attempt to use interfaces and abstracts where I can, it has to be simple enough so that the mere beginner in asp.net could load the project, look at a .cs file and say "oh, this inherits from ISuchandsuch, and look, there it is, right below this file, in the same folder." The sad fact is though, everything I said aside, I can only see but so far into a project. Interface, abstract and then concrete. No multiple inheritances, or spreading things around too thinly. I loose sight of the forest due to all the trees. That's just how I am.

    [EDIT]

    For what it's worth, I installed the things the docs told me too, set the connection string (db already exists), and set the startup project. Compiled fine, ran fine. All except the scafolding thing. All it did was create and empty file. Er...um...not a real great impression based on the installation instructions.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •